[gimp] libgimp: new gimp_image_take_selected_layers().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimp: new gimp_image_take_selected_layers().
- Date: Wed, 24 Feb 2021 11:13:07 +0000 (UTC)
commit 6e7ce324469da1b793fbf056eaef8608c2a67177
Author: Jehan <jehan girinstud io>
Date: Wed Feb 24 12:06:45 2021 +0100
libgimp: new gimp_image_take_selected_layers().
Similar to gimp_image_set_selected_layers() except that it takes a GList
(instead of a C array) and also it takes ownership of the list pointer.
This makes it much easier to use in some specific situations.
libgimp/gimp.def | 1 +
libgimp/gimpimage.c | 29 +++++++++++++++++++++++++++++
libgimp/gimpimage.h | 2 ++
3 files changed, 32 insertions(+)
---
diff --git a/libgimp/gimp.def b/libgimp/gimp.def
index 11bc920960..7e240de143 100644
--- a/libgimp/gimp.def
+++ b/libgimp/gimp.def
@@ -488,6 +488,7 @@ EXPORTS
gimp_image_set_selected_layers
gimp_image_set_tattoo_state
gimp_image_set_unit
+ gimp_image_take_selected_layers
gimp_image_thaw_channels
gimp_image_thaw_layers
gimp_image_thaw_vectors
diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c
index 60ebfb1b4b..4ef82f9f6e 100644
--- a/libgimp/gimpimage.c
+++ b/libgimp/gimpimage.c
@@ -286,6 +286,35 @@ gimp_image_list_selected_layers (GimpImage *image)
return g_list_reverse (list);
}
+/**
+ * gimp_image_take_selected_layers:
+ * @image: The image.
+ * @layers: (transfer container): The list of layers to select.
+ *
+ * The layers are set as the selected layers in the image. Any previous
+ * selected layers or channels are unselected. An exception is a previously
+ * existing floating selection, in which case this procedure will return an
+ * execution error.
+ *
+ * Since: 3.0
+ **/
+void
+gimp_image_take_selected_layers (GimpImage *image,
+ GList *layers)
+{
+ GimpLayer **sel_layers;
+ GList *list;
+ gint i;
+
+ sel_layers = g_new0 (GimpLayer *, g_list_length (layers));
+ for (list = layers, i = 0; list; list = list->next, i++)
+ sel_layers[i] = list->data;
+
+ gimp_image_set_selected_layers (image, g_list_length (layers),
+ (const GimpLayer **) sel_layers);
+ g_list_free (layers);
+}
+
/**
* gimp_image_list_channels:
* @image: The image.
diff --git a/libgimp/gimpimage.h b/libgimp/gimpimage.h
index 8ed281514a..9a9f456408 100644
--- a/libgimp/gimpimage.h
+++ b/libgimp/gimpimage.h
@@ -78,6 +78,8 @@ GList * gimp_image_list_channels (GimpImage *image);
GList * gimp_image_list_vectors (GimpImage *image);
GList * gimp_image_list_selected_layers (GimpImage *image);
+void gimp_image_take_selected_layers (GimpImage *image,
+ GList *layers);
guchar * gimp_image_get_colormap (GimpImage *image,
gint *num_colors);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]