[gimp] libgimp: add gimp_image_list_selected_drawables().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: add gimp_image_list_selected_drawables().
- Date: Thu, 20 Oct 2022 21:17:15 +0000 (UTC)
commit 8f288bf722bfcf790ad32fe427562010bf189638
Author: Jehan <jehan girinstud io>
Date: Thu Oct 20 23:03:33 2022 +0200
libgimp: add gimp_image_list_selected_drawables().
Similar to other functions, we want a variant which returns a GList.
libgimp/gimp.def | 1 +
libgimp/gimpimage.c | 38 ++++++++++++++++++++++++++++++++++++++
libgimp/gimpimage.h | 2 ++
3 files changed, 41 insertions(+)
---
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 0e2aec5062..d7fa4b85b9 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -451,6 +451,7 @@ EXPORTS
gimp_image_list_channels
gimp_image_list_layers
gimp_image_list_selected_channels
+ gimp_image_list_selected_drawables
gimp_image_list_selected_layers
gimp_image_list_selected_vectors
gimp_image_list_vectors
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index 43db416634..844a76935a 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -524,6 +524,44 @@ gimp_image_list_vectors (GimpImage *image)
return g_list_reverse (list);
}
+/**
+ * gimp_image_list_selected_drawables:
+ * @image: The image.
+ *
+ * Returns the list of drawables selected in the specified image.
+ *
+ * This procedure returns the list of drawables selected in the specified
+ * image.
+ * These can be either a list of layers or a list of channels (a list mixing
+ * layers and channels is not possible), or it can be a layer mask (a list
+ * containing only a layer mask as single item), if a layer mask is in edit
+ * mode.
+ *
+ * Returns: (element-type GimpItem) (transfer container):
+ * The list of selected drawables in the image.
+ * The returned list must be freed with g_list_free(). Layer
+ * elements belong to libgimp and must not be freed.
+ *
+ * Since: 3.0
+ **/
+GList *
+gimp_image_list_selected_drawables (GimpImage *image)
+{
+ GimpItem **drawables;
+ gint num_drawables;
+ GList *list = NULL;
+ gint i;
+
+ drawables = gimp_image_get_selected_drawables (image, &num_drawables);
+
+ for (i = 0; i < num_drawables; i++)
+ list = g_list_prepend (list, drawables[i]);
+
+ g_free (drawables);
+
+ return g_list_reverse (list);
+}
+
/**
* gimp_image_get_colormap:
* @image: The image.
diff --git a/libgimp/gimpimage.h b/libgimp/gimpimage.h
index b2de76785d..545ac9eee1 100644
--- a/libgimp/gimpimage.h
+++ b/libgimp/gimpimage.h
@@ -56,6 +56,8 @@ GList * gimp_image_list_selected_vectors (GimpImage *image);
gboolean gimp_image_take_selected_vectors (GimpImage *image,
GList *vectors);
+GList * gimp_image_list_selected_drawables(GimpImage *image);
+
guchar * gimp_image_get_colormap (GimpImage *image,
gint *num_colors);
gboolean gimp_image_set_colormap (GimpImage *image,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]