[gimp] app: Alpha to Selection will warn when the resulting selection is empty.



commit 72334646645db0a5495f31d6eb446d3e93e046fe
Author: Jehan <jehan girinstud io>
Date:   Mon May 25 17:40:57 2020 +0200

    app: Alpha to Selection will warn when the resulting selection is empty.
    
    Proposed by Aryeom to make it more obvious of a possible issue when
    running "Alpha to Selection" and ending up with an empty selection
    (which is useless hence may means there might have been a problem in
    one's workflow).
    This warning will also occur for similar actions (i.e. the
    Add|Substract|Intersect Alpha to|from|with Selection actions).

 app/actions/layers-commands.c | 9 +++++++++
 1 file changed, 9 insertions(+)
---
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 4b5b69af95..d6a107b3ff 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -1621,9 +1621,11 @@ layers_alpha_to_selection_cmd_callback (GimpAction *action,
                                         gpointer    data)
 {
   GimpImage      *image;
+  GimpDisplay    *display;
   GList          *layers;
   GimpChannelOps  operation;
   return_if_no_layers (image, layers, data);
+  return_if_no_display (display, data);
 
   operation = (GimpChannelOps) g_variant_get_int32 (value);
 
@@ -1649,6 +1651,13 @@ layers_alpha_to_selection_cmd_callback (GimpAction *action,
   gimp_channel_combine_items (gimp_image_get_mask (image),
                               layers, operation);
   gimp_image_flush (image);
+
+  if (gimp_channel_is_empty (gimp_image_get_mask (image)))
+    {
+      gimp_message_literal (image->gimp, G_OBJECT (display),
+                            GIMP_MESSAGE_WARNING,
+                            _("Empty Selection"));
+    }
 }
 
 void


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