[gimp] Add gimp_item_stack_is_flat() which returns TRUE if it's not a tree



commit 1961036f5e0fd6de32551583c5615b7f4adfaead
Author: Michael Natterer <mitch gimp org>
Date:   Mon Sep 7 21:07:44 2009 +0200

    Add gimp_item_stack_is_flat() which returns TRUE if it's not a tree

 app/core/gimpitemstack.c |   18 ++++++++++++++++++
 app/core/gimpitemstack.h |    1 +
 2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index 035c61f..c315046 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -140,6 +140,24 @@ gimp_item_stack_get_n_items (GimpItemStack *stack)
   return n_items;
 }
 
+gboolean
+gimp_item_stack_is_flat (GimpItemStack *stack)
+{
+  GList *list;
+
+  g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), TRUE);
+
+  for (list = GIMP_LIST (stack)->list; list; list = g_list_next (list))
+    {
+      GimpViewable *viewable = list->data;
+
+      if (gimp_viewable_get_children (viewable))
+        return FALSE;
+    }
+
+  return TRUE;
+}
+
 GList *
 gimp_item_stack_get_item_iter (GimpItemStack *stack)
 {
diff --git a/app/core/gimpitemstack.h b/app/core/gimpitemstack.h
index 6ccd782..339d9b4 100644
--- a/app/core/gimpitemstack.h
+++ b/app/core/gimpitemstack.h
@@ -48,6 +48,7 @@ GType           gimp_item_stack_get_type            (void) G_GNUC_CONST;
 GimpContainer * gimp_item_stack_new                 (GType          item_type);
 
 gint            gimp_item_stack_get_n_items         (GimpItemStack *stack);
+gboolean        gimp_item_stack_is_flat             (GimpItemStack *stack);
 GList         * gimp_item_stack_get_item_iter       (GimpItemStack *stack);
 GList         * gimp_item_stack_get_item_list       (GimpItemStack *stack);
 GimpItem      * gimp_item_stack_get_item_by_tattoo  (GimpItemStack *stack,



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