Commit f9c8bea3 authored by Michael Natterer's avatar Michael Natterer 😴

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.
parent 3d547c0a
......@@ -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)
......@@ -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);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment