[gimp] app: layers-resize and layers-scale work on one layer at once.



commit 0f1f8b7b459c8b01e30f49af27b7d787bb959655
Author: Jehan <jehan girinstud io>
Date:   Thu Jul 30 21:26:13 2020 +0200

    app: layers-resize and layers-scale work on one layer at once.
    
    Making these actions multi-layer aware here means checking only exactly
    1 layer is selected as these actions have GUI which shows dimensions and
    preview (for the layer dimension action, i.e. layers-resize).

 app/actions/layers-actions.c  | 10 +++-------
 app/actions/layers-commands.c | 14 ++++++++++++--
 2 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index b2349ee872..f5af63f710 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -773,8 +773,6 @@ layers_actions_update (GimpActionGroup *group,
   gboolean       lock_alpha     = TRUE;
   gboolean       can_lock_alpha = FALSE;
   gboolean       text_layer     = FALSE;
-  gboolean       writable       = FALSE;
-  gboolean       movable        = FALSE;
   gboolean       bs_mutable     = FALSE; /* At least 1 selected layers' blend space is mutable.     */
   gboolean       cs_mutable     = FALSE; /* At least 1 selected layers' composite space is mutable. */
   gboolean       cm_mutable     = FALSE; /* At least 1 selected layers' composite mode is mutable.  */
@@ -990,9 +988,7 @@ layers_actions_update (GimpActionGroup *group,
 
           gimp_action_group_set_action_active (group, action, TRUE);
 
-          mask           = gimp_layer_get_mask (layer);
-          writable       = ! gimp_item_is_content_locked (GIMP_ITEM (layer));
-          movable        = ! gimp_item_is_position_locked (GIMP_ITEM (layer));
+          mask       = gimp_layer_get_mask (layer);
 
           text_layer = gimp_item_is_text_layer (GIMP_ITEM (layer));
         }
@@ -1059,9 +1055,9 @@ layers_actions_update (GimpActionGroup *group,
   SET_VISIBLE   ("layers-text-to-vectors",    text_layer && !ac);
   SET_VISIBLE   ("layers-text-along-vectors", text_layer && !ac);
 
-  SET_SENSITIVE ("layers-resize",          writable && movable && !ac);
+  SET_SENSITIVE ("layers-resize",          n_layers == 1 && all_writable && all_movable && !ac);
   SET_SENSITIVE ("layers-resize-to-image", all_writable && all_movable && !ac);
-  SET_SENSITIVE ("layers-scale",           writable && movable && !ac);
+  SET_SENSITIVE ("layers-scale",           n_layers == 1 && all_writable && all_movable && !ac);
 
   SET_SENSITIVE ("layers-crop-to-selection", all_writable && all_movable && sel);
   SET_SENSITIVE ("layers-crop-to-content",   all_writable && all_movable);
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 926e85447c..d3359e7220 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -1061,13 +1061,18 @@ layers_resize_cmd_callback (GimpAction *action,
 {
   GimpImage *image;
   GimpLayer *layer;
+  GList     *layers;
   GtkWidget *widget;
   GtkWidget *dialog;
-  return_if_no_layer (image, layer, data);
+  return_if_no_layers (image, layers, data);
   return_if_no_widget (widget, data);
 
 #define RESIZE_DIALOG_KEY "gimp-resize-dialog"
 
+  g_return_if_fail (g_list_length (layers) == 1);
+
+  layer = layers->data;
+
   dialog = dialogs_get_dialog (G_OBJECT (layer), RESIZE_DIALOG_KEY);
 
   if (! dialog)
@@ -1131,14 +1136,19 @@ layers_scale_cmd_callback (GimpAction *action,
                            gpointer    data)
 {
   GimpImage *image;
+  GList     *layers;
   GimpLayer *layer;
   GtkWidget *widget;
   GtkWidget *dialog;
-  return_if_no_layer (image, layer, data);
+  return_if_no_layers (image, layers, data);
   return_if_no_widget (widget, data);
 
 #define SCALE_DIALOG_KEY "gimp-scale-dialog"
 
+  g_return_if_fail (g_list_length (layers) == 1);
+
+  layer = layers->data;
+
   dialog = dialogs_get_dialog (G_OBJECT (layer), SCALE_DIALOG_KEY);
 
   if (! dialog)


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