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.
This commit is contained in:
Jehan 2020-05-18 12:22:08 +02:00
parent 2dcd38c586
commit 645d80123a
2 changed files with 17 additions and 8 deletions

View File

@ -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

View File

@ -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);
}