[gimp] Add functions for getting lists of all an image's items
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add functions for getting lists of all an image's items
- Date: Sat, 1 Aug 2009 20:03:18 +0000 (UTC)
commit 571d26a1982b95f65e3df69837a145c2a639a9f5
Author: Michael Natterer <mitch gimp org>
Date: Sat Aug 1 21:59:45 2009 +0200
Add functions for getting lists of all an image's items
* app/core/gimpitemstack.[ch]: add gimp_item_stack_get_item_list()
which returns a GList of all the stack's items, in depth-first
order if the stack is in fact a tree.
* app/core/gimpimage.[ch]: add gimp_image_get_layer_list(),
channel_list(), vectors_list() which use above new function.
app/core/gimpimage.c | 24 ++++++++++++++++++++++++
app/core/gimpimage.h | 4 ++++
app/core/gimpitemstack.c | 37 +++++++++++++++++++++++++++++++++++++
app/core/gimpitemstack.h | 2 ++
4 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 49212e7..717f78a 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -2665,6 +2665,30 @@ gimp_image_get_vectors_iter (const GimpImage *image)
return GIMP_LIST (image->vectors)->list;
}
+GList *
+gimp_image_get_layer_list (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return gimp_item_stack_get_item_list (GIMP_ITEM_STACK (image->layers));
+}
+
+GList *
+gimp_image_get_channel_list (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return gimp_item_stack_get_item_list (GIMP_ITEM_STACK (image->channels));
+}
+
+GList *
+gimp_image_get_vectors_list (const GimpImage *image)
+{
+ g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+
+ return gimp_item_stack_get_item_list (GIMP_ITEM_STACK (image->vectors));
+}
+
GimpDrawable *
gimp_image_get_active_drawable (const GimpImage *image)
{
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 04259df..5b00135 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -425,6 +425,10 @@ GList * gimp_image_get_layer_iter (const GimpImage *image);
GList * gimp_image_get_channel_iter (const GimpImage *image);
GList * gimp_image_get_vectors_iter (const GimpImage *image);
+GList * gimp_image_get_layer_list (const GimpImage *image);
+GList * gimp_image_get_channel_list (const GimpImage *image);
+GList * gimp_image_get_vectors_list (const GimpImage *image);
+
GimpDrawable * gimp_image_get_active_drawable (const GimpImage *image);
GimpLayer * gimp_image_get_active_layer (const GimpImage *image);
GimpChannel * gimp_image_get_active_channel (const GimpImage *image);
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index 9363417..7f8d58c 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -114,6 +114,43 @@ gimp_item_stack_new (GType item_type)
NULL);
}
+GList *
+gimp_item_stack_get_item_list (GimpItemStack *stack)
+{
+ GList *list;
+ GList *result = NULL;
+
+ g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), NULL);
+
+ for (list = GIMP_LIST (stack)->list;
+ list;
+ list = g_list_next (list))
+ {
+ GimpViewable *viewable = list->data;
+ GimpContainer *children;
+
+ result = g_list_prepend (result, viewable);
+
+ children = gimp_viewable_get_children (viewable);
+
+ if (children)
+ {
+ GList *child_list;
+
+ child_list = gimp_item_stack_get_item_list (GIMP_ITEM_STACK (children));
+
+ while (child_list)
+ {
+ result = g_list_prepend (result, child_list->data);
+
+ child_list = g_list_remove (child_list, child_list->data);
+ }
+ }
+ }
+
+ return g_list_reverse (result);
+}
+
static void
gimp_item_stack_invalidate_preview (GimpViewable *viewable)
{
diff --git a/app/core/gimpitemstack.h b/app/core/gimpitemstack.h
index 9b92de1..c6f73f5 100644
--- a/app/core/gimpitemstack.h
+++ b/app/core/gimpitemstack.h
@@ -47,6 +47,8 @@ struct _GimpItemStackClass
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);
+
void gimp_item_stack_invalidate_previews (GimpItemStack *stack);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]