[gimp] app: make "Alpha to Selection" multi-layer aware.
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make "Alpha to Selection" multi-layer aware.
- Date: Mon, 18 May 2020 10:23:33 +0000 (UTC)
commit 645d80123acf8eb83f44795a0ff0bb8746b28cc8
Author: Jehan <jehan girinstud io>
Date: Mon May 18 12:22:08 2020 +0200
app: make "Alpha to Selection" multi-layer aware.
Allows to select several layers and have their alpha channel to replace
the selection, or substract from it, etc.
app/actions/layers-actions.c | 8 ++++----
app/actions/layers-commands.c | 17 +++++++++++++----
2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index 57f3bbbfa5..f1ef10a145 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -1094,10 +1094,10 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-mask-selection-subtract", layer && !fs && !ac && mask);
SET_SENSITIVE ("layers-mask-selection-intersect", layer && !fs && !ac && mask);
- SET_SENSITIVE ("layers-alpha-selection-replace", layer && !fs && !ac);
- SET_SENSITIVE ("layers-alpha-selection-add", layer && !fs && !ac);
- SET_SENSITIVE ("layers-alpha-selection-subtract", layer && !fs && !ac);
- SET_SENSITIVE ("layers-alpha-selection-intersect", layer && !fs && !ac);
+ SET_SENSITIVE ("layers-alpha-selection-replace", n_layers > 0 && !fs && !ac);
+ SET_SENSITIVE ("layers-alpha-selection-add", n_layers > 0 && !fs && !ac);
+ SET_SENSITIVE ("layers-alpha-selection-subtract", n_layers > 0 && !fs && !ac);
+ SET_SENSITIVE ("layers-alpha-selection-intersect", n_layers > 0 && !fs && !ac);
#undef SET_VISIBLE
#undef SET_SENSITIVE
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 68574743a1..ee67147f05 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -1555,14 +1555,23 @@ layers_alpha_to_selection_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
- GimpLayer *layer;
+ GList *layers;
+ GList *iter;
GimpChannelOps operation;
- return_if_no_layer (image, layer, data);
+ return_if_no_layers (image, layers, data);
operation = (GimpChannelOps) g_variant_get_int32 (value);
- gimp_item_to_selection (GIMP_ITEM (layer), operation,
- TRUE, FALSE, 0.0, 0.0);
+ for (iter = layers; iter; iter = iter->next)
+ {
+ if (operation != GIMP_CHANNEL_OP_REPLACE || iter == layers)
+ gimp_item_to_selection (GIMP_ITEM (iter->data), operation,
+ TRUE, FALSE, 0.0, 0.0);
+ else
+ gimp_item_to_selection (GIMP_ITEM (iter->data),
+ GIMP_CHANNEL_OP_ADD,
+ TRUE, FALSE, 0.0, 0.0);
+ }
gimp_image_flush (image);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]