[gimp] app: layers-mask-edit only works with a single layer selected.



commit 696fb34cc50321a2390102c307ea5e8864e306fc
Author: Jehan <jehan girinstud io>
Date:   Thu Jul 30 22:30:17 2020 +0200

    app: layers-mask-edit only works with a single layer selected.

 app/actions/layers-actions.c  |  5 +----
 app/actions/layers-commands.c | 19 +++++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index f5af63f710..a32a1a1789 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -765,7 +765,6 @@ layers_actions_update (GimpActionGroup *group,
   GList         *layers         = NULL;
   GList         *iter           = NULL;
   GimpLayer     *layer          = NULL;
-  GimpLayerMask *mask           = NULL;     /*  layer mask             */
   gboolean       fs             = FALSE;    /*  floating sel           */
   gboolean       ac             = FALSE;    /*  active channel         */
   gboolean       sel            = FALSE;
@@ -988,8 +987,6 @@ layers_actions_update (GimpActionGroup *group,
 
           gimp_action_group_set_action_active (group, action, TRUE);
 
-          mask       = gimp_layer_get_mask (layer);
-
           text_layer = gimp_item_is_text_layer (GIMP_ITEM (layer));
         }
     }
@@ -1093,7 +1090,7 @@ layers_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("layers-mask-show",    n_layers > 0 && !fs && !ac && have_masks);
   SET_SENSITIVE ("layers-mask-disable", n_layers > 0 && !fs && !ac && have_masks);
 
-  SET_ACTIVE ("layers-mask-edit",    mask && gimp_layer_get_edit_mask (layer));
+  SET_ACTIVE ("layers-mask-edit",    n_layers == 1 && have_masks && gimp_layer_get_edit_mask (layers->data));
   SET_ACTIVE ("layers-mask-show",    all_masks_shown);
   SET_ACTIVE ("layers-mask-disable", all_masks_disabled);
 
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index d3359e7220..752e9e25f7 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -1502,16 +1502,19 @@ layers_mask_edit_cmd_callback (GimpAction *action,
                                gpointer    data)
 {
   GimpImage *image;
-  GimpLayer *layer;
-  return_if_no_layer (image, layer, data);
+  GList     *layers;
+  GList     *iter;
+  gboolean   active = g_variant_get_boolean (value);
+  return_if_no_layers (image, layers, data);
 
-  if (gimp_layer_get_mask (layer))
-    {
-      gboolean active = g_variant_get_boolean (value);
+  /* Multiple-layer selection cannot edit masks. */
+  active = active && (g_list_length (layers) == 1);
 
-      gimp_layer_set_edit_mask (layer, active);
-      gimp_image_flush (image);
-    }
+  for (iter = layers; iter; iter = iter->next)
+    if (gimp_layer_get_mask (iter->data))
+      gimp_layer_set_edit_mask (iter->data, active);
+
+  gimp_image_flush (image);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]