[gimp] Use gimp_item_get_index() all over the place



commit 88f49a5ddbd94e7516a7d28333b0aeb64a78325e
Author: Michael Natterer <mitch gimp org>
Date:   Sat Aug 1 20:49:55 2009 +0200

    Use gimp_item_get_index() all over the place
    
    Remove gimp_image_get_layer,channel,vectors_index() and
    use the new function everywhere.

 app/core/gimpchannelpropundo.c    |    4 ++--
 app/core/gimpchannelundo.c        |    3 +--
 app/core/gimpimage-merge.c        |    2 +-
 app/core/gimpimage.c              |   35 +----------------------------------
 app/core/gimpimage.h              |    7 -------
 app/core/gimplayerpropundo.c      |    4 ++--
 app/core/gimplayerundo.c          |    3 +--
 app/vectors/gimpvectorspropundo.c |    4 ++--
 app/vectors/gimpvectorsundo.c     |    3 +--
 app/widgets/gimpchanneltreeview.c |    6 ++----
 app/widgets/gimplayertreeview.c   |    7 +++----
 app/widgets/gimpvectorstreeview.c |    3 +--
 12 files changed, 17 insertions(+), 64 deletions(-)
---
diff --git a/app/core/gimpchannelpropundo.c b/app/core/gimpchannelpropundo.c
index fd10895..1d9eb62 100644
--- a/app/core/gimpchannelpropundo.c
+++ b/app/core/gimpchannelpropundo.c
@@ -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);
diff --git a/app/core/gimpchannelundo.c b/app/core/gimpchannelundo.c
index 49a4401..1a8114c 100644
--- a/app/core/gimpchannelundo.c
+++ b/app/core/gimpchannelundo.c
@@ -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);
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 4a441b5..c71a474 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -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;
 
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index ba876e8..a8fd8a3 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -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;
     }
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 0f21da4..04259df 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -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,
diff --git a/app/core/gimplayerpropundo.c b/app/core/gimplayerpropundo.c
index 6b97338..5e793e7 100644
--- a/app/core/gimplayerpropundo.c
+++ b/app/core/gimplayerpropundo.c
@@ -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);
diff --git a/app/core/gimplayerundo.c b/app/core/gimplayerundo.c
index 0fdf6b7..31502f4 100644
--- a/app/core/gimplayerundo.c
+++ b/app/core/gimplayerundo.c
@@ -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);
diff --git a/app/vectors/gimpvectorspropundo.c b/app/vectors/gimpvectorspropundo.c
index bf125b4..508524e 100644
--- a/app/vectors/gimpvectorspropundo.c
+++ b/app/vectors/gimpvectorspropundo.c
@@ -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);
diff --git a/app/vectors/gimpvectorsundo.c b/app/vectors/gimpvectorsundo.c
index 63b8148..5f8e730 100644
--- a/app/vectors/gimpvectorsundo.c
+++ b/app/vectors/gimpvectorsundo.c
@@ -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);
diff --git a/app/widgets/gimpchanneltreeview.c b/app/widgets/gimpchanneltreeview.c
index 89abfc5..9d43b56 100644
--- a/app/widgets/gimpchanneltreeview.c
+++ b/app/widgets/gimpchanneltreeview.c
@@ -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++;
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 4c8a27a..e413c4b 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -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++;
diff --git a/app/widgets/gimpvectorstreeview.c b/app/widgets/gimpvectorstreeview.c
index b240a6e..55f72ba 100644
--- a/app/widgets/gimpvectorstreeview.c
+++ b/app/widgets/gimpvectorstreeview.c
@@ -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++;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]