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

app: add gimp_item_stack_get_item_by_path()

which finds an item by its path as returned by gimp_item_get_path().
parent 3762e03b
......@@ -233,6 +233,39 @@ gimp_item_stack_get_item_by_tattoo (GimpItemStack *stack,
return NULL;
GimpItem *
gimp_item_stack_get_item_by_path (GimpItemStack *stack,
GList *path)
GimpContainer *container;
GimpItem *item = NULL;
g_return_val_if_fail (GIMP_IS_ITEM_STACK (stack), NULL);
g_return_val_if_fail (path != NULL, NULL);
container = GIMP_CONTAINER (stack);
while (path)
guint32 i = GPOINTER_TO_UINT (path->data);
item = GIMP_ITEM (gimp_container_get_child_by_index (container, i));
g_return_val_if_fail (GIMP_IS_ITEM (item), item);
if (path->next)
container = gimp_viewable_get_children (GIMP_VIEWABLE (item));
g_return_val_if_fail (GIMP_IS_ITEM_STACK (container), item);
path = path->next;
return item;
GimpItem *
gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
GList *path,
......@@ -53,6 +53,8 @@ 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,
GimpTattoo tattoo);
GimpItem * gimp_item_stack_get_item_by_path (GimpItemStack *stack,
GList *path);
GimpItem * gimp_item_stack_get_parent_by_path (GimpItemStack *stack,
GList *path,
gint *index);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment