[gimp] Move get_item_by_tattoo() and by_name() functions from GimpImage to GimpItemStack



commit 251ee3a7bedc527784c804bc7a7281535f301688
Author: Michael Natterer <mitch gimp org>
Date:   Sun Aug 2 01:39:51 2009 +0200

    Move get_item_by_tattoo() and by_name() functions from GimpImage to GimpItemStack

 app/core/gimpimage.c     |   74 +++++++--------------------------------------
 app/core/gimpitemstack.c |   64 +++++++++++++++++++++++++++++++++++++++
 app/core/gimpitemstack.h |    4 ++
 3 files changed, 80 insertions(+), 62 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index e9a0e97..30fe046 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2913,41 +2913,14 @@ gimp_image_get_vectors_by_index (const GimpImage *image,
                                                             index);
 }
 
-static GimpItem *
-gimp_image_get_item_by_tattoo (GimpContainer *items,
-                               GimpTattoo     tattoo)
-{
-  GList *list;
-
-  for (list = GIMP_LIST (items)->list; list; list = g_list_next (list))
-    {
-      GimpItem      *item = list->data;
-      GimpContainer *children;
-
-      if (gimp_item_get_tattoo (item) == tattoo)
-        return item;
-
-      children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
-
-      if (children)
-        {
-          item = gimp_image_get_item_by_tattoo (children, tattoo);
-
-          if (item)
-            return item;
-        }
-    }
-
-  return NULL;
-}
-
 GimpLayer *
 gimp_image_get_layer_by_tattoo (const GimpImage *image,
                                 GimpTattoo       tattoo)
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
-  return GIMP_LAYER (gimp_image_get_item_by_tattoo (image->layers, tattoo));
+  return GIMP_LAYER (gimp_item_stack_get_item_by_tattoo (GIMP_ITEM_STACK (image->layers),
+                                                         tattoo));
 }
 
 GimpChannel *
@@ -2956,7 +2929,8 @@ gimp_image_get_channel_by_tattoo (const GimpImage *image,
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
-  return GIMP_CHANNEL (gimp_image_get_item_by_tattoo (image->channels, tattoo));
+  return GIMP_CHANNEL (gimp_item_stack_get_item_by_tattoo (GIMP_ITEM_STACK (image->channels),
+                                                           tattoo));
 }
 
 GimpVectors *
@@ -2965,35 +2939,8 @@ gimp_image_get_vectors_by_tattoo (const GimpImage *image,
 {
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
-  return GIMP_VECTORS (gimp_image_get_item_by_tattoo (image->vectors, tattoo));
-}
-
-static GimpItem *
-gimp_image_get_item_by_name (GimpContainer *items,
-                             const gchar   *name)
-{
-  GList *list;
-
-  for (list = GIMP_LIST (items)->list; list; list = g_list_next (list))
-    {
-      GimpItem      *item = list->data;
-      GimpContainer *children;
-
-      if (! strcmp (gimp_object_get_name (GIMP_OBJECT (item)), name))
-        return item;
-
-      children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
-
-      if (children)
-        {
-          item = gimp_image_get_item_by_name (children, name);
-
-          if (item)
-            return item;
-        }
-    }
-
-  return NULL;
+  return GIMP_VECTORS (gimp_item_stack_get_item_by_tattoo (GIMP_ITEM_STACK (image->vectors),
+                                                           tattoo));
 }
 
 GimpLayer *
@@ -3003,7 +2950,8 @@ gimp_image_get_layer_by_name (const GimpImage *image,
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (name != NULL, NULL);
 
-  return GIMP_LAYER (gimp_image_get_item_by_name (image->layers, name));
+  return GIMP_LAYER (gimp_item_stack_get_item_by_name (GIMP_ITEM_STACK (image->layers),
+                                                       name));
 }
 
 GimpChannel *
@@ -3013,7 +2961,8 @@ gimp_image_get_channel_by_name (const GimpImage *image,
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (name != NULL, NULL);
 
-  return GIMP_CHANNEL (gimp_image_get_item_by_name (image->channels, name));
+  return GIMP_CHANNEL (gimp_item_stack_get_item_by_name (GIMP_ITEM_STACK (image->channels),
+                                                         name));
 }
 
 GimpVectors *
@@ -3023,7 +2972,8 @@ gimp_image_get_vectors_by_name (const GimpImage *image,
   g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
   g_return_val_if_fail (name != NULL, NULL);
 
-  return GIMP_VECTORS (gimp_image_get_item_by_name (image->vectors, name));
+  return GIMP_VECTORS (gimp_item_stack_get_item_by_name (GIMP_ITEM_STACK (image->vectors),
+                                                         name));
 }
 
 gboolean
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index 7f8d58c..112b89a 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -20,6 +20,8 @@
 
 #include "config.h"
 
+#include <string.h>
+
 #include <gegl.h>
 
 #include "core-types.h"
@@ -151,6 +153,68 @@ gimp_item_stack_get_item_list (GimpItemStack *stack)
   return g_list_reverse (result);
 }
 
+GimpItem *
+gimp_item_stack_get_item_by_tattoo (GimpItemStack *stack,
+                                    GimpTattoo     tattoo)
+{
+  GList *list;
+
+  g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), NULL);
+
+  for (list = GIMP_LIST (stack)->list; list; list = g_list_next (list))
+    {
+      GimpItem      *item = list->data;
+      GimpContainer *children;
+
+      if (gimp_item_get_tattoo (item) == tattoo)
+        return item;
+
+      children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
+
+      if (children)
+        {
+          item = gimp_item_stack_get_item_by_tattoo (GIMP_ITEM_STACK (children),
+                                                     tattoo);
+
+          if (item)
+            return item;
+        }
+    }
+
+  return NULL;
+}
+
+GimpItem *
+gimp_item_stack_get_item_by_name (GimpItemStack *stack,
+                                  const gchar   *name)
+{
+  GList *list;
+
+  g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), NULL);
+
+  for (list = GIMP_LIST (stack)->list; list; list = g_list_next (list))
+    {
+      GimpItem      *item = list->data;
+      GimpContainer *children;
+
+      if (! strcmp (gimp_object_get_name (GIMP_OBJECT (item)), name))
+        return item;
+
+      children = gimp_viewable_get_children (GIMP_VIEWABLE (item));
+
+      if (children)
+        {
+          item = gimp_item_stack_get_item_by_name (GIMP_ITEM_STACK (children),
+                                                   name);
+
+          if (item)
+            return item;
+        }
+    }
+
+  return NULL;
+}
+
 static void
 gimp_item_stack_invalidate_preview (GimpViewable *viewable)
 {
diff --git a/app/core/gimpitemstack.h b/app/core/gimpitemstack.h
index c6f73f5..29cc91e 100644
--- a/app/core/gimpitemstack.h
+++ b/app/core/gimpitemstack.h
@@ -48,6 +48,10 @@ GType           gimp_item_stack_get_type            (void) G_GNUC_CONST;
 GimpContainer * gimp_item_stack_new                 (GType          item_type);
 
 GList         * gimp_item_stack_get_item_list       (GimpItemStack *stack);
+GimpItem      * gimp_item_stack_get_item_by_tattoo  (GimpItemStack *stack,
+                                                     GimpTattoo     tattoo);
+GimpItem      * gimp_item_stack_get_item_by_name    (GimpItemStack *stack,
+                                                     const gchar   *name);
 
 void            gimp_item_stack_invalidate_previews (GimpItemStack *stack);
 



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