Commit d1ca165b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

add new functions gimp_image_get_layer_iter(), channel_iter() and

2008-11-02  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage.[ch]: add new functions
	gimp_image_get_layer_iter(), channel_iter() and vectors_iter()
	which return the GList inside the resp. GimpList.

	* app/actions/channels-actions.c
	* app/actions/layers-actions.c
	* app/actions/vectors-actions.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-crop.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-flip.c
	* app/core/gimpimage-item-list.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-rotate.c
	* app/core/gimpimage-scale.c
	* app/core/gimpimage.c
	* app/core/gimpimage.h
	* app/core/gimpprojection-construct.c
	* app/display/gimpdisplayshell-draw.c
	* app/file/file-open.c
	* app/tools/gimpaligntool.c
	* app/tools/gimpdrawtool.c
	* app/vectors/gimpvectors-compat.c
	* app/vectors/gimpvectors-export.c
	* app/widgets/gimplayertreeview.c
	* app/xcf/xcf-save.c
	* tools/pdbgen/pdb/image.pdb: use the new functions instead of
	peeking both into the image and the list. Remove inclusions of
	"gimplist.h" or change them into "gimpcontainer.h" if needed.

	* app/pdb/image-cmds.c: regenerated.


svn path=/trunk/; revision=27524
parent c14c84ba
2008-11-02 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.[ch]: add new functions
gimp_image_get_layer_iter(), channel_iter() and vectors_iter()
which return the GList inside the resp. GimpList.
* app/actions/channels-actions.c
* app/actions/layers-actions.c
* app/actions/vectors-actions.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-crop.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-flip.c
* app/core/gimpimage-item-list.c
* app/core/gimpimage-merge.c
* app/core/gimpimage-resize.c
* app/core/gimpimage-rotate.c
* app/core/gimpimage-scale.c
* app/core/gimpimage.c
* app/core/gimpimage.h
* app/core/gimpprojection-construct.c
* app/display/gimpdisplayshell-draw.c
* app/file/file-open.c
* app/tools/gimpaligntool.c
* app/tools/gimpdrawtool.c
* app/vectors/gimpvectors-compat.c
* app/vectors/gimpvectors-export.c
* app/widgets/gimplayertreeview.c
* app/xcf/xcf-save.c
* tools/pdbgen/pdb/image.pdb: use the new functions instead of
peeking both into the image and the list. Remove inclusions of
"gimplist.h" or change them into "gimpcontainer.h" if needed.
* app/pdb/image-cmds.c: regenerated.
2008-11-02 Michael Natterer <mitch@gimp.org>
* app/core/gimpdrawablestack.[ch]: add "update" signal with the
......
......@@ -26,7 +26,6 @@
#include "actions-types.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimpcomponenteditor.h"
......@@ -145,7 +144,7 @@ void
channels_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image = action_data_get_image (data);
GimpImage *image = action_data_get_image (data);
GimpChannel *channel = NULL;
gboolean fs = FALSE;
gboolean component = FALSE;
......@@ -169,7 +168,7 @@ channels_actions_update (GimpActionGroup *group,
{
GList *list;
list = g_list_find (GIMP_LIST (image->channels)->list, channel);
list = g_list_find (gimp_image_get_channel_iter (image), channel);
if (list)
{
......
......@@ -28,7 +28,6 @@
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimplayermask.h"
#include "core/gimplist.h"
#include "text/gimptextlayer.h"
......@@ -467,7 +466,7 @@ void
layers_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image = action_data_get_image (data);
GimpImage *image = action_data_get_image (data);
GimpLayer *layer = NULL;
GimpLayerMask *mask = NULL; /* layer mask */
gboolean fs = FALSE; /* floating sel */
......@@ -497,7 +496,7 @@ layers_actions_update (GimpActionGroup *group,
lock_alpha = gimp_layer_get_lock_alpha (layer);
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
list = g_list_find (GIMP_LIST (image->layers)->list, layer);
list = g_list_find (gimp_image_get_layer_iter (image), layer);
if (list)
{
......
......@@ -27,7 +27,6 @@
#include "core/gimpchannel.h"
#include "core/gimpimage.h"
#include "core/gimplist.h"
#include "widgets/gimpactiongroup.h"
#include "widgets/gimphelp-ids.h"
......@@ -237,7 +236,7 @@ void
vectors_actions_update (GimpActionGroup *group,
gpointer data)
{
GimpImage *image = action_data_get_image (data);
GimpImage *image = action_data_get_image (data);
GimpVectors *vectors = NULL;
gint n_vectors = 0;
gboolean mask_empty = TRUE;
......@@ -263,7 +262,7 @@ vectors_actions_update (GimpActionGroup *group,
visible = gimp_item_get_visible (item);
linked = gimp_item_get_linked (item);
list = g_list_find (GIMP_LIST (image->vectors)->list, vectors);
list = g_list_find (gimp_image_get_vectors_iter (image), vectors);
if (list)
{
......
......@@ -145,13 +145,13 @@
#include "base/tile-manager.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpdrawable.h"
#include "gimpdrawable-convert.h"
#include "gimpimage.h"
#include "gimpimage-colormap.h"
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimplist.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimppalette.h"
......@@ -798,7 +798,7 @@ gimp_image_convert (GimpImage *image,
gimp_set_busy (image->gimp);
n_layers = g_list_length (GIMP_LIST (image->layers)->list);
n_layers = gimp_container_num_children (GIMP_CONTAINER (image->layers));
switch (new_type)
{
......@@ -870,7 +870,7 @@ gimp_image_convert (GimpImage *image,
num_found_cols = 0;
/* Build the histogram */
for (list = GIMP_LIST (image->layers)->list, nth_layer = 0;
for (list = gimp_image_get_layer_iter (image), nth_layer = 0;
list;
list = g_list_next (list), nth_layer++)
{
......@@ -955,7 +955,7 @@ gimp_image_convert (GimpImage *image,
if (quantobj)
quantobj->n_layers = n_layers;
for (list = GIMP_LIST (image->layers)->list, nth_layer = 0;
for (list = gimp_image_get_layer_iter (image), nth_layer = 0;
list;
list = g_list_next (list), nth_layer++)
{
......@@ -1031,7 +1031,7 @@ gimp_image_convert (GimpImage *image,
remap_table, &num_entries);
/* Convert all layers */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......
......@@ -36,7 +36,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "gimppickable.h"
#include "gimpsamplepoint.h"
......@@ -147,7 +146,7 @@ gimp_image_crop (GimpImage *image,
NULL);
/* Resize all channels */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -157,7 +156,7 @@ gimp_image_crop (GimpImage *image,
}
/* Resize all vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -171,7 +170,7 @@ gimp_image_crop (GimpImage *image,
width, height, -x1, -y1);
/* crop all layers */
list = GIMP_LIST (image->layers)->list;
list = gimp_image_get_layer_iter (image);
while (list)
{
......
......@@ -37,7 +37,6 @@
#include "gimpimage-sample-points.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplist.h"
#include "gimpparasitelist.h"
#include "gimpsamplepoint.h"
......@@ -105,7 +104,7 @@ gimp_image_duplicate (GimpImage *image)
}
/* Copy the layers */
for (list = GIMP_LIST (image->layers)->list, count = 0;
for (list = gimp_image_get_layer_iter (image), count = 0;
list;
list = g_list_next (list))
{
......@@ -141,7 +140,7 @@ gimp_image_duplicate (GimpImage *image)
}
/* Copy the channels */
for (list = GIMP_LIST (image->channels)->list, count = 0;
for (list = gimp_image_get_channel_iter (image), count = 0;
list;
list = g_list_next (list))
{
......@@ -166,7 +165,7 @@ gimp_image_duplicate (GimpImage *image)
}
/* Copy any vectors */
for (list = GIMP_LIST (image->vectors)->list, count = 0;
for (list = gimp_image_get_vectors_iter (image), count = 0;
list;
list = g_list_next (list))
{
......
......@@ -23,6 +23,7 @@
#include "core-types.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpguide.h"
#include "gimpimage.h"
......@@ -32,7 +33,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpitem.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
......@@ -69,15 +69,15 @@ gimp_image_flip (GimpImage *image,
return;
}
progress_max = (image->channels->num_children +
image->layers->num_children +
image->vectors->num_children +
progress_max = (gimp_container_num_children (image->channels) +
gimp_container_num_children (image->layers) +
gimp_container_num_children (image->vectors) +
1 /* selection */);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_FLIP, NULL);
/* Flip all channels */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -90,7 +90,7 @@ gimp_image_flip (GimpImage *image,
}
/* Flip all vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -110,7 +110,7 @@ gimp_image_flip (GimpImage *image,
gimp_progress_set_value (progress, progress_current++ / progress_max);
/* Flip all layers */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......
......@@ -27,7 +27,6 @@
#include "gimpimage-item-list.h"
#include "gimpimage-undo.h"
#include "gimpitem.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimp-intl.h"
......@@ -172,7 +171,7 @@ gimp_image_item_list_get_list (const GimpImage *image,
if (type & GIMP_ITEM_TYPE_LAYERS)
{
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -185,7 +184,7 @@ gimp_image_item_list_get_list (const GimpImage *image,
if (type & GIMP_ITEM_TYPE_CHANNELS)
{
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -198,7 +197,7 @@ gimp_image_item_list_get_list (const GimpImage *image,
if (type & GIMP_ITEM_TYPE_VECTORS)
{
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......
......@@ -35,6 +35,7 @@
#include "vectors/gimpvectors.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-colorhash.h"
......@@ -43,7 +44,6 @@
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplayermask.h"
#include "gimplist.h"
#include "gimpmarshal.h"
#include "gimpparasitelist.h"
#include "gimpundostack.h"
......@@ -81,7 +81,7 @@ gimp_image_merge_visible_layers (GimpImage *image,
had_floating_sel = TRUE;
}
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -151,7 +151,7 @@ gimp_image_flatten (GimpImage *image,
if (gimp_image_floating_sel (image))
floating_sel_anchor (image->floating_sel);
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -186,7 +186,7 @@ gimp_image_merge_down (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
for (list = GIMP_LIST (image->layers)->list, layer_list = NULL;
for (list = gimp_image_get_layer_iter (image), layer_list = NULL;
list && !layer_list;
list = g_list_next (list))
{
......@@ -236,7 +236,7 @@ gimp_image_merge_visible_vectors (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -584,7 +584,7 @@ gimp_image_merge_layers (GimpImage *image,
/* if the type is flatten, remove all the remaining layers */
if (merge_type == GIMP_FLATTEN_IMAGE)
{
list = GIMP_LIST (image->layers)->list;
list = gimp_image_get_layer_iter (image);
while (list)
{
layer = list->data;
......
......@@ -23,6 +23,7 @@
#include "core-types.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpguide.h"
......@@ -34,7 +35,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
......@@ -79,9 +79,9 @@ gimp_image_resize_with_layers (GimpImage *image,
gimp_set_busy (image->gimp);
progress_max = (image->channels->num_children +
image->layers->num_children +
image->vectors->num_children +
progress_max = (gimp_container_num_children (image->channels) +
gimp_container_num_children (image->layers) +
gimp_container_num_children (image->vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
......@@ -111,7 +111,7 @@ gimp_image_resize_with_layers (GimpImage *image,
NULL);
/* Resize all channels */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -125,7 +125,7 @@ gimp_image_resize_with_layers (GimpImage *image,
}
/* Resize all vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -146,7 +146,7 @@ gimp_image_resize_with_layers (GimpImage *image,
gimp_progress_set_value (progress, progress_current++ / progress_max);
/* Reposition all layers */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -241,7 +241,7 @@ gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
GimpProgress *progress)
{
GList *list = GIMP_LIST (image->layers)->list;
GList *list = gimp_image_get_layer_iter (image);
GimpItem *item;
gint min_x, max_x;
gint min_y, max_y;
......
......@@ -23,6 +23,7 @@
#include "core-types.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpcontext.h"
#include "gimpguide.h"
#include "gimpimage.h"
......@@ -32,7 +33,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimpitem.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpsamplepoint.h"
......@@ -79,9 +79,9 @@ gimp_image_rotate (GimpImage *image,
center_x = previous_image_width / 2.0;
center_y = previous_image_height / 2.0;
progress_max = (image->channels->num_children +
image->layers->num_children +
image->vectors->num_children +
progress_max = (gimp_container_num_children (image->channels) +
gimp_container_num_children (image->layers) +
gimp_container_num_children (image->vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
......@@ -114,7 +114,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all channels */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -130,7 +130,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -167,7 +167,7 @@ gimp_image_rotate (GimpImage *image,
}
/* Rotate all layers */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......
......@@ -25,6 +25,7 @@
#include "base/tile-manager.h"
#include "gimp.h"
#include "gimpcontainer.h"
#include "gimpguide.h"
#include "gimpimage.h"
#include "gimpimage-guides.h"
......@@ -34,7 +35,6 @@
#include "gimpimage-undo.h"
#include "gimpimage-undo-push.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "gimpprogress.h"
#include "gimpprojection.h"
#include "gimpsamplepoint.h"
......@@ -71,9 +71,9 @@ gimp_image_scale (GimpImage *image,
sub_progress = gimp_sub_progress_new (progress);
progress_steps = (image->channels->num_children +
image->layers->num_children +
image->vectors->num_children +
progress_steps = (gimp_container_num_children (image->channels) +
gimp_container_num_children (image->layers) +
gimp_container_num_children (image->vectors) +
1 /* selection */);
g_object_freeze_notify (G_OBJECT (image));
......@@ -104,7 +104,7 @@ gimp_image_scale (GimpImage *image,
NULL);
/* Scale all channels */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -119,7 +119,7 @@ gimp_image_scale (GimpImage *image,
}
/* Scale all vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -142,7 +142,7 @@ gimp_image_scale (GimpImage *image,
interpolation_type, sub_progress);
/* Scale all layers */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -331,7 +331,7 @@ gimp_image_scale_check (const GimpImage *image,
if (new_size > current_size && new_size > max_memsize)
return GIMP_IMAGE_SCALE_TOO_BIG;
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......
......@@ -1067,7 +1067,9 @@ gimp_image_size_changed (GimpViewable *viewable)
(GFunc) gimp_viewable_size_changed,
NULL);
for (list = GIMP_LIST (image->layers)->list; list; list = g_list_next (list))
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (list->data));
......@@ -2376,7 +2378,7 @@ gimp_image_set_tattoo_state (GimpImage *image,
g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE);
/* Check that the layer tattoos don't overlap with channel or vector ones */
for (list = GIMP_LIST (image->layers)->list;
for (list = gimp_image_get_layer_iter (image);
list;
list = g_list_next (list))
{
......@@ -2394,7 +2396,7 @@ gimp_image_set_tattoo_state (GimpImage *image,
}
/* Now check that the channel and vectors tattoos don't overlap */
for (list = GIMP_LIST (image->channels)->list;
for (list = gimp_image_get_channel_iter (image);
list;
list = g_list_next (list))
{
......@@ -2409,7 +2411,7 @@ gimp_image_set_tattoo_state (GimpImage *image,
}
/* Find the max tattoo value in the vectors */
for (list = GIMP_LIST (image->vectors)->list;
for (list = gimp_image_get_vectors_iter (image);
list;
list = g_list_next (list))
{
......@@ -2510,6 +2512,30 @@ gimp_image_get_vectors (const GimpImage *image)
return image->vectors;
}
GList *
gimp_image_get_layer_iter (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return GIMP_LIST (image->layers)->list;
}
GList *
gimp_image_get_channel_iter (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return GIMP_LIST (image->channels)->list;
}
GList *
gimp_image_get_vectors_iter (const GimpImage *image)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);