Commit 9e131cb2 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

converted gimage->layers and gimage->channels to GimpLists.

2001-02-19  Sven Neumann  <sven@gimp.org>

	* app/gimpimage.[ch]: converted gimage->layers and gimage->channels
	to GimpLists.

	* app/channel_ops.c
	* app/channels_dialog.c
	* app/commands.c
	* app/convert.c
	* app/floating_sel.c
	* app/gdisplay.c
	* app/gimpdrawable.c
	* app/layers_dialog.c
	* app/resize.c
	* app/undo.c
	* app/xcf.c
	* app/pdb/display_cmds.c
	* app/pdb/image_cmds.c
	* app/pdb/layer_cmds.c
	* app/tools/crop.c
	* app/tools/edit_selection.c
	* tools/pdbgen/pdb/display.pdb
	* tools/pdbgen/pdb/image.pdb
	* tools/pdbgen/pdb/layer.pdb: changed accordingly
parent 6e9296c5
2001-02-19 Sven Neumann <sven@gimp.org>
* app/gimpimage.[ch]: converted gimage->layers and gimage->channels
to GimpLists.
* app/channel_ops.c
* app/channels_dialog.c
* app/commands.c
* app/convert.c
* app/floating_sel.c
* app/gdisplay.c
* app/gimpdrawable.c
* app/layers_dialog.c
* app/resize.c
* app/undo.c
* app/xcf.c
* app/pdb/display_cmds.c
* app/pdb/image_cmds.c
* app/pdb/layer_cmds.c
* app/tools/crop.c
* app/tools/edit_selection.c
* tools/pdbgen/pdb/display.pdb
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/layer.pdb: changed accordingly
2001-02-19 Michael Natterer <mitch@gimp.org>
* app/gimpcontainer.[ch] (gimp_container_insert): new function.
......
......@@ -938,7 +938,8 @@ layers_previous_cmd_callback (GtkWidget *widget,
current_layer =
gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer - 1);
new_layer = gimp_container_get_child_by_index (gdisp->gimage->layers,
current_layer - 1);
if (new_layer)
{
......@@ -961,7 +962,8 @@ layers_next_cmd_callback (GtkWidget *widget,
current_layer =
gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer + 1);
new_layer = gimp_container_get_child_by_index (gdisp->gimage->layers,
current_layer + 1);
if (new_layer)
{
......
......@@ -38,6 +38,7 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "paint_funcs.h"
#include "parasitelist.h"
#include "path.h"
......@@ -573,8 +574,7 @@ duplicate (GimpImage *gimage)
GimpLayer *layer, *new_layer;
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GSList *list;
GList *glist;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
......@@ -606,13 +606,11 @@ duplicate (GimpImage *gimage)
}
/* Copy the layers */
list = gimage->layers;
count = 0;
layer = NULL;
while (list)
for (list = GIMP_LIST (gimage->layers)->list, count = 0;
list;
list = g_list_next (list), count++)
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
new_layer = gimp_layer_copy (layer, FALSE);
......@@ -635,22 +633,21 @@ duplicate (GimpImage *gimage)
if (gimage->floating_sel == layer)
floating_layer = new_layer;
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
if (floating_sel_drawable == GIMP_DRAWABLE (layer))
new_floating_sel_drawable = GIMP_DRAWABLE (new_layer);
/* Add the layer */
if (floating_layer != new_layer)
gimp_image_add_layer (new_gimage, new_layer, count++);
gimp_image_add_layer (new_gimage, new_layer, count);
}
/* Copy the channels */
list = gimage->channels;
count = 0;
while (list)
for (list = GIMP_LIST (gimage->channels)->list, count = 0;
list;
list = g_list_next (list), count++)
{
channel = (GimpChannel *) list->data;
list = g_slist_next (list);
new_channel = gimp_channel_copy (channel);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_channel), new_gimage);
......@@ -662,17 +659,19 @@ duplicate (GimpImage *gimage)
if (gimage->active_channel == channel)
active_channel = (new_channel);
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
if (floating_sel_drawable == GIMP_DRAWABLE (channel))
new_floating_sel_drawable = GIMP_DRAWABLE (new_channel);
/* Add the channel */
gimp_image_add_channel (new_gimage, new_channel, count++);
gimp_image_add_channel (new_gimage, new_channel, count);
}
/* Copy the selection mask */
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (gimage->selection_mask)),
pixel_region_init (&srcPR,
gimp_drawable_data (GIMP_DRAWABLE (gimage->selection_mask)),
0, 0, gimage->width, gimage->height, FALSE);
pixel_region_init (&destPR, gimp_drawable_data (GIMP_DRAWABLE (new_gimage->selection_mask)),
pixel_region_init (&destPR,
gimp_drawable_data (GIMP_DRAWABLE (new_gimage->selection_mask)),
0, 0, gimage->width, gimage->height, TRUE);
copy_region (&srcPR, &destPR);
new_gimage->selection_mask->bounds_known = FALSE;
......@@ -697,13 +696,11 @@ duplicate (GimpImage *gimage)
}
/* Copy any Guides */
glist = gimage->guides;
while (glist)
for (list = gimage->guides; list; list = g_list_next (list))
{
Guide* new_guide;
guide = (Guide*) glist->data;
glist = g_list_next (glist);
guide = (Guide*) list->data;
switch (guide->orientation)
{
......
......@@ -36,6 +36,7 @@
#include "gimage_mask.h"
#include "gimpchannel.h"
#include "gimpdnd.h"
#include "gimplist.h"
#include "gimprc.h"
#include "gimpui.h"
#include "layers_dialogP.h"
......@@ -443,7 +444,8 @@ channels_dialog_update (GimpImage* gimage)
{
GimpChannel *channel;
ChannelWidget *cw;
GSList *list;
GSList *slist;
GList *list;
GList *item_list;
if (!channelsD || channelsD->gimage == gimage)
......@@ -456,13 +458,14 @@ channels_dialog_update (GimpImage* gimage)
gtk_list_clear_items (GTK_LIST (channelsD->channel_list), 0, -1);
suspend_gimage_notify--;
list = channelsD->channel_widgets;
while (list)
for (slist = channelsD->channel_widgets; slist;)
{
cw = (ChannelWidget *) list->data;
list = g_slist_next (list);
cw = (ChannelWidget *) slist->data;
slist = g_slist_next (slist);
channel_widget_delete (cw);
}
channelsD->channel_widgets = NULL;
/* Find the preview extents */
......@@ -522,7 +525,9 @@ channels_dialog_update (GimpImage* gimage)
channelsD->num_components++;
/* The auxillary image channels */
for (list = gimage->channels; list; list = g_slist_next (list))
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
/* create a channel list item */
channel = (GimpChannel *) list->data;
......@@ -544,7 +549,8 @@ channels_dialog_flush (void)
GimpImage *gimage;
GimpChannel *channel;
ChannelWidget *cw;
GSList *list;
GList *list;
GSList *slist;
gint pos;
if (!channelsD || !(gimage = channelsD->gimage))
......@@ -561,14 +567,19 @@ channels_dialog_flush (void)
else
{
/* Set all current channel widgets to visited = FALSE */
for (list = channelsD->channel_widgets; list; list = g_slist_next (list))
for (slist = channelsD->channel_widgets;
slist;
slist = g_slist_next (slist))
{
cw = (ChannelWidget *) list->data;
cw = (ChannelWidget *) slist->data;
cw->visited = FALSE;
}
/* Add any missing channels */
for (list = gimage->channels; list; list = g_slist_next (list))
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
cw = channel_widget_get_ID (channel);
......@@ -584,11 +595,11 @@ channels_dialog_flush (void)
}
/* Remove any extraneous auxillary channels */
list = channelsD->channel_widgets;
while (list)
for (slist = channelsD->channel_widgets; slist;)
{
cw = (ChannelWidget *) list->data;
list = g_slist_next (list);
cw = (ChannelWidget *) slist->data;
slist = g_slist_next (slist);
if (cw->visited == FALSE && cw->type == AUXILLARY_CHANNEL)
{
/* will only be true for auxillary channels */
......@@ -598,7 +609,9 @@ channels_dialog_flush (void)
/* Switch positions of items if necessary */
pos = 0;
for (list = gimage->channels; list; list = g_slist_next (list))
for (list = GIMP_LIST (gimage->channels)->list;
list;
list = g_list_next (list))
{
channel = (GimpChannel *) list->data;
channels_dialog_position_channel (channel, pos++);
......
......@@ -938,7 +938,8 @@ layers_previous_cmd_callback (GtkWidget *widget,
current_layer =
gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer - 1);
new_layer = gimp_container_get_child_by_index (gdisp->gimage->layers,
current_layer - 1);
if (new_layer)
{
......@@ -961,7 +962,8 @@ layers_next_cmd_callback (GtkWidget *widget,
current_layer =
gimp_image_get_layer_index (gdisp->gimage, gdisp->gimage->active_layer);
new_layer = gimp_image_get_layer_by_index (gdisp->gimage, current_layer + 1);
new_layer = gimp_container_get_child_by_index (gdisp->gimage->layers,
current_layer + 1);
if (new_layer)
{
......
......@@ -555,8 +555,7 @@ convert_to_indexed (GimpImage *gimage)
if (dialog->num_cols == 256)
{
if ((! gimp_image_is_empty (gimage)) &&
(gimage->layers->next ||
gimp_layer_has_alpha ((GimpLayer *) gimage->layers->data)))
GIMP_IMAGE_TYPE_HAS_ALPHA (gimage->base_type))
{
dialog->num_cols = 255;
}
......@@ -753,9 +752,8 @@ convert_to_indexed (GimpImage *gimage)
/* if the image isn't non-alpha/layered, set the default number of
colours to one less than max, to leave room for a transparent index
for transparent/animated GIFs */
if ((! gimp_image_is_empty (gimage)) &&
(gimage->layers->next ||
gimp_layer_has_alpha ((GimpLayer *) gimage->layers->data)))
if (! gimp_image_is_empty (gimage) &&
GIMP_IMAGE_TYPE_HAS_ALPHA (gimage->base_type))
{
frame = gtk_frame_new (_("[ Warning ]"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
......@@ -1186,10 +1184,10 @@ convert_image (GImage *gimage,
GimpLayer *layer;
GimpLayer *floating_layer;
GimpImageBaseType old_type;
GSList *list;
GList *list;
GimpImageType new_layer_type;
int new_layer_bytes;
int has_alpha;
gint new_layer_bytes;
gboolean has_alpha;
TileManager *new_tiles;
quantobj = NULL;
......@@ -1241,11 +1239,12 @@ convert_image (GImage *gimage,
num_found_cols = 0;
/* Build the histogram */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
if (old_type == GRAY)
generate_histogram_gray (quantobj->histogram, layer, alpha_dither);
else
......@@ -1307,11 +1306,11 @@ convert_image (GImage *gimage,
}
/* Convert all layers */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
has_alpha = gimp_layer_has_alpha (layer);
switch (new_type)
......@@ -1391,11 +1390,11 @@ convert_image (GImage *gimage,
quantobj->index_used_count, remap_table, &num_entries);
/* Convert all layers */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
remap_indexed_layer (layer, remap_table, num_entries);
}
......
......@@ -38,6 +38,7 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "paint_funcs.h"
#include "parasitelist.h"
#include "path.h"
......@@ -573,8 +574,7 @@ duplicate (GimpImage *gimage)
GimpLayer *layer, *new_layer;
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GSList *list;
GList *glist;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
......@@ -606,13 +606,11 @@ duplicate (GimpImage *gimage)
}
/* Copy the layers */
list = gimage->layers;
count = 0;
layer = NULL;
while (list)
for (list = GIMP_LIST (gimage->layers)->list, count = 0;
list;
list = g_list_next (list), count++)
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
new_layer = gimp_layer_copy (layer, FALSE);
......@@ -635,22 +633,21 @@ duplicate (GimpImage *gimage)
if (gimage->floating_sel == layer)
floating_layer = new_layer;
if (floating_sel_drawable == GIMP_DRAWABLE(layer))
new_floating_sel_drawable = GIMP_DRAWABLE(new_layer);
if (floating_sel_drawable == GIMP_DRAWABLE (layer))
new_floating_sel_drawable = GIMP_DRAWABLE (new_layer);
/* Add the layer */
if (floating_layer != new_layer)
gimp_image_add_layer (new_gimage, new_layer, count++);
gimp_image_add_layer (new_gimage, new_layer, count);
}
/* Copy the channels */
list = gimage->channels;
count = 0;
while (list)
for (list = GIMP_LIST (gimage->channels)->list, count = 0;
list;
list = g_list_next (list), count++)
{
channel = (GimpChannel *) list->data;
list = g_slist_next (list);
new_channel = gimp_channel_copy (channel);
gimp_drawable_set_gimage (GIMP_DRAWABLE (new_channel), new_gimage);
......@@ -662,17 +659,19 @@ duplicate (GimpImage *gimage)
if (gimage->active_channel == channel)
active_channel = (new_channel);
if (floating_sel_drawable == GIMP_DRAWABLE(channel))
new_floating_sel_drawable = GIMP_DRAWABLE(new_channel);
if (floating_sel_drawable == GIMP_DRAWABLE (channel))
new_floating_sel_drawable = GIMP_DRAWABLE (new_channel);
/* Add the channel */
gimp_image_add_channel (new_gimage, new_channel, count++);
gimp_image_add_channel (new_gimage, new_channel, count);
}
/* Copy the selection mask */
pixel_region_init (&srcPR, gimp_drawable_data (GIMP_DRAWABLE (gimage->selection_mask)),
pixel_region_init (&srcPR,
gimp_drawable_data (GIMP_DRAWABLE (gimage->selection_mask)),
0, 0, gimage->width, gimage->height, FALSE);
pixel_region_init (&destPR, gimp_drawable_data (GIMP_DRAWABLE (new_gimage->selection_mask)),
pixel_region_init (&destPR,
gimp_drawable_data (GIMP_DRAWABLE (new_gimage->selection_mask)),
0, 0, gimage->width, gimage->height, TRUE);
copy_region (&srcPR, &destPR);
new_gimage->selection_mask->bounds_known = FALSE;
......@@ -697,13 +696,11 @@ duplicate (GimpImage *gimage)
}
/* Copy any Guides */
glist = gimage->guides;
while (glist)
for (list = gimage->guides; list; list = g_list_next (list))
{
Guide* new_guide;
guide = (Guide*) glist->data;
glist = g_list_next (glist);
guide = (Guide*) list->data;
switch (guide->orientation)
{
......
......@@ -35,6 +35,7 @@
#include "gimpdrawable-preview.h"
#include "gimpimage.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "gimppreviewcache.h"
#include "gimpparasite.h"
#include "paint_funcs.h"
......@@ -191,7 +192,7 @@ gimp_drawable_name_changed (GimpObject *object)
{
GimpDrawable *drawable;
GimpDrawable *drawable2;
GSList *list, *list2, *base_list;
GList *list, *list2, *base_list;
gint unique_ext = 0;
gchar *ext;
gchar *new_name = NULL;
......@@ -201,17 +202,20 @@ gimp_drawable_name_changed (GimpObject *object)
drawable = GIMP_DRAWABLE (object);
/* if no other layers to check name against */
if (drawable->gimage == NULL || drawable->gimage->layers == NULL)
if (drawable->gimage == NULL ||
gimp_image_is_empty (drawable->gimage))
return;
if (GIMP_IS_LAYER (drawable))
base_list = drawable->gimage->layers;
base_list = GIMP_LIST (drawable->gimage->layers)->list;
else if (GIMP_IS_CHANNEL (drawable))
base_list = drawable->gimage->channels;
base_list = GIMP_LIST (drawable->gimage->channels)->list;
else
base_list = NULL;
for (list = base_list; list; list = g_slist_next (list))
for (list = base_list;
list;
list = g_list_next (list))
{
drawable2 = GIMP_DRAWABLE (list->data);
......@@ -256,7 +260,7 @@ gimp_drawable_name_changed (GimpObject *object)
GIMP_OBJECT (drawable)->name,
unique_ext);
for (list2 = base_list; list2; list2 = g_slist_next (list2))
for (list2 = base_list; list2; list2 = g_list_next (list2))
{
drawable2 = GIMP_DRAWABLE (list2->data);
......
......@@ -555,8 +555,7 @@ convert_to_indexed (GimpImage *gimage)
if (dialog->num_cols == 256)
{
if ((! gimp_image_is_empty (gimage)) &&
(gimage->layers->next ||
gimp_layer_has_alpha ((GimpLayer *) gimage->layers->data)))
GIMP_IMAGE_TYPE_HAS_ALPHA (gimage->base_type))
{
dialog->num_cols = 255;
}
......@@ -753,9 +752,8 @@ convert_to_indexed (GimpImage *gimage)
/* if the image isn't non-alpha/layered, set the default number of
colours to one less than max, to leave room for a transparent index
for transparent/animated GIFs */
if ((! gimp_image_is_empty (gimage)) &&
(gimage->layers->next ||
gimp_layer_has_alpha ((GimpLayer *) gimage->layers->data)))
if (! gimp_image_is_empty (gimage) &&
GIMP_IMAGE_TYPE_HAS_ALPHA (gimage->base_type))
{
frame = gtk_frame_new (_("[ Warning ]"));
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
......@@ -1186,10 +1184,10 @@ convert_image (GImage *gimage,
GimpLayer *layer;
GimpLayer *floating_layer;
GimpImageBaseType old_type;
GSList *list;
GList *list;
GimpImageType new_layer_type;
int new_layer_bytes;
int has_alpha;
gint new_layer_bytes;
gboolean has_alpha;
TileManager *new_tiles;
quantobj = NULL;
......@@ -1241,11 +1239,12 @@ convert_image (GImage *gimage,
num_found_cols = 0;
/* Build the histogram */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
if (old_type == GRAY)
generate_histogram_gray (quantobj->histogram, layer, alpha_dither);
else
......@@ -1307,11 +1306,11 @@ convert_image (GImage *gimage,
}
/* Convert all layers */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
has_alpha = gimp_layer_has_alpha (layer);
switch (new_type)
......@@ -1391,11 +1390,11 @@ convert_image (GImage *gimage,
quantobj->index_used_count, remap_table, &num_entries);
/* Convert all layers */
list = gimage->layers;
while (list)
for (list = GIMP_LIST (gimage->layers)->list;
list;
list = g_list_next (list))
{
layer = (GimpLayer *) list->data;
list = g_slist_next (list);
remap_indexed_layer (layer, remap_table, num_entries);
}
......
......@@ -38,6 +38,7 @@
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "paint_funcs.h"
#include "parasitelist.h"
#include "path.h"
......@@ -573,8 +574,7 @@ duplicate (GimpImage *gimage)
GimpLayer *layer, *new_layer;
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GSList *list;
GList *glist;
GList *list;
Guide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
......@@ -606,13 +606,11 @@ duplicate (GimpImage *gimage)
}
/* Copy the layers */
list = gimage->layers;
count = 0;
layer = NULL;
while (list)
for (list = GIMP_LIST (gimage->layers)->list, count = 0;