Use gimp_item_get_index() all over the place

Remove gimp_image_get_layer,channel,vectors_index() and
use the new function everywhere.
This commit is contained in:
Michael Natterer 2009-08-01 20:49:55 +02:00
parent a3cb1191b9
commit 88f49a5ddb
12 changed files with 17 additions and 64 deletions

View File

@ -80,7 +80,7 @@ gimp_channel_prop_undo_constructor (GType type,
switch (GIMP_UNDO (object)->undo_type)
{
case GIMP_UNDO_CHANNEL_REPOSITION:
channel_prop_undo->position = gimp_image_get_channel_index (image, channel);
channel_prop_undo->position = gimp_item_get_index (GIMP_ITEM (channel));
break;
case GIMP_UNDO_CHANNEL_COLOR:
@ -110,7 +110,7 @@ gimp_channel_prop_undo_pop (GimpUndo *undo,
{
gint position;
position = gimp_image_get_channel_index (undo->image, channel);
position = gimp_item_get_index (GIMP_ITEM (channel));
gimp_image_position_channel (undo->image, channel,
channel_prop_undo->position,
FALSE, NULL);

View File

@ -188,8 +188,7 @@ gimp_channel_undo_pop (GimpUndo *undo,
/* remove channel */
/* record the current position */
channel_undo->prev_position = gimp_image_get_channel_index (undo->image,
channel);
channel_undo->prev_position = gimp_item_get_index (GIMP_ITEM (channel));
gimp_image_remove_channel (undo->image, channel, FALSE,
channel_undo->prev_channel);

View File

@ -259,7 +259,7 @@ gimp_image_merge_visible_vectors (GimpImage *image,
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (vectors)));
target_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
GIMP_TYPE_VECTORS));
pos = gimp_image_get_vectors_index (image, vectors);
pos = gimp_item_get_index (GIMP_ITEM (vectors));
gimp_image_remove_vectors (image, vectors, TRUE, NULL);
cur_item = cur_item->next;

View File

@ -2848,39 +2848,6 @@ gimp_image_active_vectors_changed (GimpImage *image)
g_signal_emit (image, gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0);
}
gint
gimp_image_get_layer_index (const GimpImage *image,
const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
g_return_val_if_fail (GIMP_IS_LAYER (layer), -1);
return gimp_container_get_child_index (image->layers,
GIMP_OBJECT (layer));
}
gint
gimp_image_get_channel_index (const GimpImage *image,
const GimpChannel *channel)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
g_return_val_if_fail (GIMP_IS_CHANNEL (channel), -1);
return gimp_container_get_child_index (image->channels,
GIMP_OBJECT (channel));
}
gint
gimp_image_get_vectors_index (const GimpImage *image,
const GimpVectors *vectors)
{
g_return_val_if_fail (GIMP_IS_IMAGE (image), -1);
g_return_val_if_fail (GIMP_IS_VECTORS (vectors), -1);
return gimp_container_get_child_index (image->vectors,
GIMP_OBJECT (vectors));
}
GimpLayer *
gimp_image_get_layer_by_index (const GimpImage *image,
gint index)
@ -3185,7 +3152,7 @@ gimp_image_add_layers (GimpImage *image,
GimpLayer *active_layer = gimp_image_get_active_layer (image);
if (active_layer)
position = gimp_image_get_layer_index (image, active_layer);
position = gimp_item_get_index (GIMP_ITEM (active_layer));
else
position = 0;
}

View File

@ -442,13 +442,6 @@ void gimp_image_active_layer_changed (GimpImage *image);
void gimp_image_active_channel_changed (GimpImage *image);
void gimp_image_active_vectors_changed (GimpImage *image);
gint gimp_image_get_layer_index (const GimpImage *image,
const GimpLayer *layer);
gint gimp_image_get_channel_index (const GimpImage *image,
const GimpChannel *channel);
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,

View File

@ -80,7 +80,7 @@ gimp_layer_prop_undo_constructor (GType type,
switch (GIMP_UNDO (object)->undo_type)
{
case GIMP_UNDO_LAYER_REPOSITION:
layer_prop_undo->position = gimp_image_get_layer_index (image, layer);
layer_prop_undo->position = gimp_item_get_index (GIMP_ITEM (layer));
break;
case GIMP_UNDO_LAYER_MODE:
@ -118,7 +118,7 @@ gimp_layer_prop_undo_pop (GimpUndo *undo,
{
gint position;
position = gimp_image_get_layer_index (undo->image, layer);
position = gimp_item_get_index (GIMP_ITEM (layer));
gimp_image_position_layer (undo->image, layer,
layer_prop_undo->position,
FALSE, NULL);

View File

@ -188,8 +188,7 @@ gimp_layer_undo_pop (GimpUndo *undo,
/* remove layer */
/* record the current position */
layer_undo->prev_position = gimp_image_get_layer_index (undo->image,
layer);
layer_undo->prev_position = gimp_item_get_index (GIMP_ITEM (layer));
gimp_image_remove_layer (undo->image, layer, FALSE,
layer_undo->prev_layer);

View File

@ -79,7 +79,7 @@ gimp_vectors_prop_undo_constructor (GType type,
switch (GIMP_UNDO (object)->undo_type)
{
case GIMP_UNDO_VECTORS_REPOSITION:
vectors_prop_undo->position = gimp_image_get_vectors_index (image, vectors);
vectors_prop_undo->position = gimp_item_get_index (GIMP_ITEM (vectors));
break;
default:
@ -105,7 +105,7 @@ gimp_vectors_prop_undo_pop (GimpUndo *undo,
{
gint position;
position = gimp_image_get_vectors_index (undo->image, vectors);
position = gimp_item_get_index (GIMP_ITEM (vectors));
gimp_image_position_vectors (undo->image, vectors,
vectors_prop_undo->position,
FALSE, NULL);

View File

@ -189,8 +189,7 @@ gimp_vectors_undo_pop (GimpUndo *undo,
/* remove vectors */
/* record the current position */
vectors_undo->prev_position = gimp_image_get_vectors_index (undo->image,
vectors);
vectors_undo->prev_position = gimp_item_get_index (GIMP_ITEM (vectors));
gimp_image_remove_vectors (undo->image, vectors, FALSE,
vectors_undo->prev_vectors);

View File

@ -225,8 +225,7 @@ gimp_channel_tree_view_drop_viewable (GimpContainerTreeView *tree_view,
if (dest_viewable)
{
index = gimp_image_get_channel_index (gimp_item_tree_view_get_image (item_view),
GIMP_CHANNEL (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;
@ -264,8 +263,7 @@ gimp_channel_tree_view_drop_component (GimpContainerTreeView *tree_view,
if (dest_viewable)
{
index = gimp_image_get_channel_index (gimp_item_tree_view_get_image (item_view),
GIMP_CHANNEL (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;

View File

@ -720,7 +720,7 @@ gimp_layer_tree_view_drop_uri_list (GimpContainerTreeView *view,
if (dest_viewable)
{
index = gimp_image_get_layer_index (image, GIMP_LAYER (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;
@ -783,8 +783,7 @@ gimp_layer_tree_view_drop_component (GimpContainerTreeView *tree_view,
if (dest_viewable)
{
index = gimp_image_get_layer_index (gimp_item_tree_view_get_image (item_view),
GIMP_LAYER (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;
@ -819,7 +818,7 @@ gimp_layer_tree_view_drop_pixbuf (GimpContainerTreeView *tree_view,
if (dest_viewable)
{
index = gimp_image_get_layer_index (image, GIMP_LAYER (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;

View File

@ -235,8 +235,7 @@ gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view,
if (dest_viewable)
{
index = gimp_image_get_vectors_index (image,
GIMP_VECTORS (dest_viewable));
index = gimp_item_get_index (GIMP_ITEM (dest_viewable));
if (drop_pos == GTK_TREE_VIEW_DROP_AFTER)
index++;