Commit 3d547c0a authored by Michael Natterer's avatar Michael Natterer 😴

Add gimp_item_get_path(), to be used in XCF saving

Returns a GList of guint indices that describe the path to an item in
an item tree, pretty much like GtkTreePath does for GtkTreeModels.
parent 37768e25
......@@ -733,6 +733,35 @@ gimp_item_get_index (GimpItem *item)
return -1;
}
GList *
gimp_item_get_path (GimpItem *item)
{
GimpContainer *container;
GList *path = NULL;
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
g_return_val_if_fail (gimp_item_is_attached (item), NULL);
container = gimp_item_get_container (item);
while (container)
{
guint32 index = gimp_container_get_child_index (container,
GIMP_OBJECT (item));
path = g_list_prepend (path, GUINT_TO_POINTER (index));
item = GIMP_ITEM (gimp_viewable_get_parent (GIMP_VIEWABLE (item)));
if (item)
container = gimp_item_get_container (item);
else
container = NULL;
}
return path;
}
/**
* gimp_item_duplicate:
* @item: The #GimpItem to duplicate.
......
......@@ -146,6 +146,7 @@ gboolean gimp_item_is_attached (const GimpItem *item);
GimpContainer * gimp_item_get_container (GimpItem *item);
GList * gimp_item_get_container_iter (GimpItem *item);
gint gimp_item_get_index (GimpItem *item);
GList * gimp_item_get_path (GimpItem *item);
void gimp_item_configure (GimpItem *item,
GimpImage *image,
......
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