[gimp] app: add gimp_image_equal_selected_drawables().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_image_equal_selected_drawables().
- Date: Tue, 26 May 2020 12:16:21 +0000 (UTC)
commit 661f057603a00982ef2c150eb44f4171bf0ab5e7
Author: Jehan <jehan girinstud io>
Date: Mon May 25 11:21:17 2020 +0200
app: add gimp_image_equal_selected_drawables().
This can be used in various places where we want to check whether a
previously saved list of drawables is still the same list of selected
drawables. It used to be easily done with an equality test with a single
active drawable, but not anymore with a list of selected drawables.
app/core/gimpimage.c | 36 ++++++++++++++++++++++++++++++++++++
app/core/gimpimage.h | 3 +++
2 files changed, 39 insertions(+)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 9f4faf112e..335d8c3341 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -4479,6 +4479,42 @@ gimp_image_set_active_vectors (GimpImage *image,
return active_vectors;
}
+/**
+ * gimp_image_equal_selected_drawables:
+ * @image:
+ * @drawables:
+ *
+ * Compare the list of @drawables with the selected drawables in @image
+ * (i.e. the result of gimp_image_equal_selected_drawables()).
+ * The order of the @drawables does not matter, only if the size and
+ * contents of the list is the same.
+ */
+gboolean
+gimp_image_equal_selected_drawables (GimpImage *image,
+ GList *drawables)
+{
+ GList *selected_drawables;
+ GList *iter;
+ gboolean equal = FALSE;
+
+ selected_drawables = gimp_image_get_selected_drawables (image);
+
+ if (g_list_length (drawables) == g_list_length (selected_drawables))
+ {
+ equal = TRUE;
+
+ for (iter = drawables; iter; iter = iter->next)
+ if (! g_list_find (selected_drawables, iter->data))
+ {
+ equal = FALSE;
+ break;
+ }
+ }
+ g_list_free (selected_drawables);
+
+ return equal;
+}
+
GList *
gimp_image_get_selected_drawables (GimpImage *image)
{
diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h
index 58e1be8eaa..49fb50bb03 100644
--- a/app/core/gimpimage.h
+++ b/app/core/gimpimage.h
@@ -379,6 +379,9 @@ void gimp_image_unset_selected_channels (GimpImage *image);
GimpVectors * gimp_image_set_active_vectors (GimpImage *image,
GimpVectors *vectors);
+gboolean gimp_image_equal_selected_drawables (GimpImage *image,
+ GList *drawables);
+
GList * gimp_image_get_selected_drawables (GimpImage *image);
GList * gimp_image_get_selected_layers (GimpImage *image);
GList * gimp_image_get_selected_channels (GimpImage *image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]