[gimp] Add gimp_item_stack_get_parent_by_path(), for use un XCF loading
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add gimp_item_stack_get_parent_by_path(), for use un XCF loading
- Date: Sun, 30 Aug 2009 19:00:03 +0000 (UTC)
commit f9c8bea36833b61e60b0db135c5a904d8279243e
Author: Michael Natterer <mitch gimp org>
Date: Sun Aug 30 20:58:24 2009 +0200
Add gimp_item_stack_get_parent_by_path(), for use un XCF loading
The opposite of gimp_item_get_path(), just that it doesn't return an
item, it returns a parent item and an index that can be used to add
the item to an item tree.
app/core/gimpitemstack.c | 43 +++++++++++++++++++++++++++++++++++++++++++
app/core/gimpitemstack.h | 3 +++
2 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpitemstack.c b/app/core/gimpitemstack.c
index b8963e4..b4384e2 100644
--- a/app/core/gimpitemstack.c
+++ b/app/core/gimpitemstack.c
@@ -247,6 +247,49 @@ gimp_item_stack_get_item_by_name (GimpItemStack *stack,
return NULL;
}
+GimpItem *
+gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
+ GList *path,
+ gint *index)
+{
+ GimpItem *parent = NULL;
+ guint32 i;
+
+ g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ i = GPOINTER_TO_UINT (path->data);
+
+ if (index)
+ *index = i;
+
+ while (path->next)
+ {
+ GimpObject *child;
+ GimpContainer *children;
+
+ child = gimp_container_get_child_by_index (GIMP_CONTAINER (stack), i);
+
+ g_return_val_if_fail (GIMP_IS_ITEM (child), parent);
+
+ children = gimp_viewable_get_children (GIMP_VIEWABLE (child));
+
+ g_return_val_if_fail (GIMP_IS_ITEM_STACK (children), parent);
+
+ parent = GIMP_ITEM (child);
+ stack = GIMP_ITEM_STACK (children);
+
+ path = path->next;
+
+ i = GPOINTER_TO_UINT (path->data);
+
+ if (index)
+ *index = i;
+ }
+
+ return parent;
+}
+
static void
gimp_item_stack_invalidate_preview (GimpViewable *viewable)
{
diff --git a/app/core/gimpitemstack.h b/app/core/gimpitemstack.h
index 6dbcba2..6ccd782 100644
--- a/app/core/gimpitemstack.h
+++ b/app/core/gimpitemstack.h
@@ -54,6 +54,9 @@ 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);
+GimpItem * gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
+ GList *path,
+ gint *index);
void gimp_item_stack_invalidate_previews (GimpItemStack *stack);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]