add new functions gimp_image_get_layer_by_index(), _channel_by_index() and

2008-10-10  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage.[ch]: add new functions
	gimp_image_get_layer_by_index(), _channel_by_index() and
	_vectors_by_index().

	* app/core/gimpprojection-construct.c
	* app/display/gimpdisplayshell-layer-select.c
	* app/xcf/xcf-load.c: use them instead of looking the items up
	in image->container and casting the return value.


svn path=/trunk/; revision=27206
This commit is contained in:
Michael Natterer 2008-10-10 11:45:00 +00:00 committed by Michael Natterer
parent f2a6b781e4
commit dba9e0c5e8
6 changed files with 56 additions and 15 deletions

View File

@ -1,3 +1,14 @@
2008-10-10 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage.[ch]: add new functions
gimp_image_get_layer_by_index(), _channel_by_index() and
_vectors_by_index().
* app/core/gimpprojection-construct.c
* app/display/gimpdisplayshell-layer-select.c
* app/xcf/xcf-load.c: use them instead of looking the items up
in image->container and casting the return value.
2008-10-10 Michael Natterer <mitch@gimp.org>
* app/core/gimplayer.c (gimp_layer_translate)

View File

@ -1599,7 +1599,7 @@ gimp_image_has_alpha (const GimpImage *image)
g_return_val_if_fail (GIMP_IS_IMAGE (image), TRUE);
layer = (GimpLayer *) gimp_container_get_child_by_index (image->layers, 0);
layer = gimp_image_get_layer_by_index (image, 0);
return ((gimp_container_num_children (image->layers) > 1) ||
(layer && gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))));
@ -2780,6 +2780,36 @@ gimp_image_get_vectors_index (const GimpImage *image,
GIMP_OBJECT (vectors));
}
GimpLayer *
gimp_image_get_layer_by_index (const GimpImage *image,
gint index)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return (GimpLayer *) gimp_container_get_child_by_index (image->layers,
index);
}
GimpChannel *
gimp_image_get_channel_by_index (const GimpImage *image,
gint index)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return (GimpChannel *) gimp_container_get_child_by_index (image->channels,
index);
}
GimpVectors *
gimp_image_get_vectors_by_index (const GimpImage *image,
gint index)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
return (GimpVectors *) gimp_container_get_child_by_index (image->vectors,
index);
}
static GimpItem *
gimp_image_get_item_by_tattoo (GimpContainer *items,
GimpTattoo tattoo)
@ -3005,8 +3035,7 @@ gimp_image_remove_layer (GimpImage *image,
{
index = CLAMP (index, 0, n_children - 1);
active_layer = (GimpLayer *)
gimp_container_get_child_by_index (image->layers, index);
active_layer = gimp_image_get_layer_by_index (image, index);
}
else
{
@ -3318,8 +3347,7 @@ gimp_image_remove_channel (GimpImage *image,
{
index = CLAMP (index, 0, n_children - 1);
active_channel = (GimpChannel *)
gimp_container_get_child_by_index (image->channels, index);
active_channel = gimp_image_get_channel_by_index (image, index);
}
else
{
@ -3546,8 +3574,7 @@ gimp_image_remove_vectors (GimpImage *image,
{
index = CLAMP (index, 0, n_children - 1);
active_vectors = (GimpVectors *)
gimp_container_get_child_by_index (image->vectors, index);
active_vectors = gimp_image_get_vectors_by_index (image, index);
}
else
{

View File

@ -443,6 +443,13 @@ gint gimp_image_get_channel_index (const GimpImage *image,
gint gimp_image_get_vectors_index (const GimpImage *image,
const GimpVectors *vectors);
GimpLayer * gimp_image_get_layer_by_index (const GimpImage *image,
gint index);
GimpChannel * gimp_image_get_channel_by_index (const GimpImage *image,
gint index);
GimpVectors * gimp_image_get_vectors_by_index (const GimpImage *image,
gint index);
GimpLayer * gimp_image_get_layer_by_tattoo (const GimpImage *image,
GimpTattoo tattoo);
GimpChannel * gimp_image_get_channel_by_tattoo (const GimpImage *image,

View File

@ -101,8 +101,7 @@ gimp_projection_construct (GimpProjection *proj,
{
GimpDrawable *layer;
layer = GIMP_DRAWABLE (gimp_container_get_child_by_index (image->layers,
0));
layer = GIMP_DRAWABLE (gimp_image_get_layer_by_index (image, 0));
if (gimp_drawable_has_alpha (layer) &&
(gimp_item_get_visible (GIMP_ITEM (layer))) &&

View File

@ -212,8 +212,7 @@ layer_select_advance (LayerSelect *layer_select,
else if (index >= gimp_container_num_children (layer_select->image->layers))
index = 0;
next_layer = (GimpLayer *)
gimp_container_get_child_by_index (layer_select->image->layers, index);
next_layer = gimp_image_get_layer_by_index (layer_select->image, index);
if (next_layer && next_layer != current_layer)
{

View File

@ -1529,8 +1529,7 @@ xcf_load_old_paths (XcfInfo *info,
while (num_paths-- > 0)
xcf_load_old_path (info, image);
active_vectors = (GimpVectors *)
gimp_container_get_child_by_index (image->vectors, last_selected_row);
active_vectors = gimp_image_get_vectors_by_index (image, last_selected_row);
if (active_vectors)
gimp_image_set_active_vectors (image, active_vectors);
@ -1670,8 +1669,7 @@ xcf_load_vectors (XcfInfo *info,
if (! xcf_load_vector (info, image))
return FALSE;
active_vectors = (GimpVectors *)
gimp_container_get_child_by_index (image->vectors, active_index);
active_vectors = gimp_image_get_vectors_by_index (image, active_index);
if (active_vectors)
gimp_image_set_active_vectors (image, active_vectors);