[gimp] Add gimp_image_item_list_filter()
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] Add gimp_image_item_list_filter()
- Date: Tue, 25 Aug 2009 19:31:06 +0000 (UTC)
commit cb1e3afba45075dbc0ac1aaa1cf74278e96a0941
Author: Michael Natterer <mitch gimp org>
Date: Tue Aug 25 15:36:03 2009 +0200
Add gimp_image_item_list_filter()
New function takes a GList of items as returned by
gimp_image_item_list_get_list() and can filter out items that:
- have lock_content set to TRUE.
- are children of items that are also in the list (to avoid
transforming group items *and* their children, because
the group items already do that for us).
app/core/gimpimage-item-list.c | 68 ++++++++++++++++++++++++++++++++++++++++
app/core/gimpimage-item-list.h | 5 +++
2 files changed, 73 insertions(+), 0 deletions(-)
---
diff --git a/app/core/gimpimage-item-list.c b/app/core/gimpimage-item-list.c
index b4f0a43..5360c2f 100644
--- a/app/core/gimpimage-item-list.c
+++ b/app/core/gimpimage-item-list.c
@@ -216,3 +216,71 @@ gimp_image_item_list_get_list (const GimpImage *image,
return g_list_reverse (return_list);
}
+
+static GList *
+gimp_image_item_list_remove_children (GList *list,
+ const GimpItem *parent)
+{
+ GList *l = list;
+
+ while (l)
+ {
+ GimpItem *item = l->data;
+
+ l = g_list_next (l);
+
+ if (gimp_viewable_is_ancestor (GIMP_VIEWABLE (parent),
+ GIMP_VIEWABLE (item)))
+ {
+ list = g_list_remove (list, item);
+ }
+ }
+
+ return list;
+}
+
+GList *
+gimp_image_item_list_filter (const GimpItem *exclude,
+ GList *list,
+ gboolean remove_children,
+ gboolean remove_locked)
+{
+ GList *l;
+
+ g_return_val_if_fail (exclude == NULL || GIMP_IS_ITEM (exclude), NULL);
+
+ if (! list)
+ return NULL;
+
+ if (exclude)
+ list = gimp_image_item_list_remove_children (list, exclude);
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GimpItem *item = l->data;
+ GList *next;
+
+ next = gimp_image_item_list_remove_children (g_list_next (l), item);
+
+ l->next = next;
+ if (next)
+ next->prev = l;
+ }
+
+ if (remove_locked)
+ {
+ l = list;
+
+ while (l)
+ {
+ GimpItem *item = l->data;
+
+ l = g_list_next (l);
+
+ if (gimp_item_get_lock_content (item))
+ list = g_list_remove (list, item);
+ }
+ }
+
+ return list;
+}
diff --git a/app/core/gimpimage-item-list.h b/app/core/gimpimage-item-list.h
index 60e5341..7053bd4 100644
--- a/app/core/gimpimage-item-list.h
+++ b/app/core/gimpimage-item-list.h
@@ -52,5 +52,10 @@ GList * gimp_image_item_list_get_list (const GimpImage *image,
GimpItemTypeMask type,
GimpItemSet set);
+GList * gimp_image_item_list_filter (const GimpItem *exclude,
+ GList *list,
+ gboolean remove_children,
+ gboolean remove_locked);
+
#endif /* __GIMP_IMAGE_ITEM_LIST_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]