[gimp] Add utility function gimp_layer_get_container()



commit f4f5fc5f5575090c9adaabe6a9661de86b6477be
Author: Michael Natterer <mitch gimp org>
Date:   Sat Aug 1 19:27:45 2009 +0200

    Add utility function gimp_layer_get_container()
    
    The new function returns a layer's container, which is either its
    parent viewable's children, or image->layers. Scheduled for being
    moved to a virtual function on GimpItem.

 app/core/gimplayer.c |   22 ++++++++++++++++++++++
 app/core/gimplayer.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 64c986d..406c2d9 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -2039,3 +2039,25 @@ gimp_layer_get_lock_alpha (const GimpLayer *layer)
 
   return layer->lock_alpha;
 }
+
+GimpContainer *
+gimp_layer_get_container (const GimpLayer *layer)
+{
+  GimpViewable *parent;
+
+  g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
+
+  parent = gimp_viewable_get_parent (GIMP_VIEWABLE (layer));
+
+  if (parent)
+    return gimp_viewable_get_children (parent);
+
+  if (gimp_item_is_attached (GIMP_ITEM (layer)))
+    {
+      GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
+
+      return gimp_image_get_layers (image);
+    }
+
+  return NULL;
+}
diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h
index b092b82..ca66ead 100644
--- a/app/core/gimplayer.h
+++ b/app/core/gimplayer.h
@@ -137,5 +137,7 @@ void            gimp_layer_set_lock_alpha      (GimpLayer            *layer,
                                                 gboolean              push_undo);
 gboolean        gimp_layer_get_lock_alpha      (const GimpLayer      *layer);
 
+GimpContainer * gimp_layer_get_container       (const GimpLayer      *layer);
+
 
 #endif /* __GIMP_LAYER_H__ */



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