[gimp/gimp-2-10] app: in all tools, blink lock box when the current item is locked



commit a8841a3c07170f88e672b58420c5fd83ccc045fa
Author: Ell <ell_se yahoo com>
Date:   Mon Dec 10 08:22:50 2018 -0500

    app: in all tools, blink lock box when the current item is locked
    
    In all tools, when the current item can't be edited due to its lock
    mask, use gimp_tools_blink_lock_box(), added in the previous
    commit,to blink the lock box of the corresponding dockable, in
    addition to showing an error message in the status bar, to hint at
    the source of the error.
    
    (cherry picked from commit 637105b962916bae90f3f71235b378ea79769504)

 app/display/gimptoolpath.c        |  8 ++++++++
 app/tools/gimpbucketfilltool.c    |  3 +++
 app/tools/gimpcagetool.c          |  3 +++
 app/tools/gimpcroptool.c          |  3 +++
 app/tools/gimpeditselectiontool.c |  2 ++
 app/tools/gimpfiltertool.c        |  3 +++
 app/tools/gimpgradienttool.c      |  3 +++
 app/tools/gimpmovetool.c          |  2 ++
 app/tools/gimppainttool.c         | 15 +++++++++++----
 app/tools/gimpselectiontool.c     |  4 ++++
 app/tools/gimptransformtool.c     |  3 +++
 app/tools/gimpwarptool.c          |  3 +++
 12 files changed, 48 insertions(+), 4 deletions(-)
---
diff --git a/app/display/gimptoolpath.c b/app/display/gimptoolpath.c
index 027ef9486e..276057c601 100644
--- a/app/display/gimptoolpath.c
+++ b/app/display/gimptoolpath.c
@@ -37,6 +37,8 @@
 
 #include "widgets/gimpwidgets-utils.h"
 
+#include "tools/gimptools-utils.h"
+
 #include "gimpcanvashandle.h"
 #include "gimpcanvasitem-utils.h"
 #include "gimpcanvasline.h"
@@ -492,6 +494,8 @@ static gboolean
 gimp_tool_path_check_writable (GimpToolPath *path)
 {
   GimpToolPathPrivate *private = path->private;
+  GimpToolWidget      *widget  = GIMP_TOOL_WIDGET (path);
+  GimpDisplayShell    *shell   = gimp_tool_widget_get_shell (widget);
 
   if (gimp_item_is_content_locked (GIMP_ITEM (private->vectors)) ||
       gimp_item_is_position_locked (GIMP_ITEM (private->vectors)))
@@ -499,6 +503,10 @@ gimp_tool_path_check_writable (GimpToolPath *path)
       gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path),
                                    _("The active path is locked."));
 
+      /* FIXME: this should really be done by the tool */
+      gimp_tools_blink_lock_box (shell->display->gimp,
+                                 GIMP_ITEM (private->vectors));
+
       private->function = VECTORS_FINISHED;
 
       return FALSE;
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index 01989144f1..ee55344ab6 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -40,6 +40,7 @@
 #include "gimpbucketfilloptions.h"
 #include "gimpbucketfilltool.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -142,6 +143,8 @@ gimp_bucket_fill_tool_initialize (GimpTool     *tool,
     {
       g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                            _("The active layer's pixels are locked."));
+      if (error)
+        gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
       return FALSE;
     }
 
diff --git a/app/tools/gimpcagetool.c b/app/tools/gimpcagetool.c
index c1065f5c39..9ebb124663 100644
--- a/app/tools/gimpcagetool.c
+++ b/app/tools/gimpcagetool.c
@@ -50,6 +50,7 @@
 #include "gimpcagetool.h"
 #include "gimpcageoptions.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -225,6 +226,8 @@ gimp_cage_tool_initialize (GimpTool     *tool,
     {
       g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                            _("The active layer's pixels are locked."));
+      if (error)
+        gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
       return FALSE;
     }
 
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index bfb233b69d..40863f22f1 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -40,6 +40,7 @@
 #include "gimpcroptool.h"
 #include "gimprectangleoptions.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -458,6 +459,8 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
                 {
                   gimp_tool_message_literal (tool, tool->display,
                                              _("The active layer's pixels are locked."));
+                  gimp_tools_blink_lock_box (tool->display->gimp,
+                                             GIMP_ITEM (layer));
                   return;
                 }
 
diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c
index c9d46e4018..ec7231bfa2 100644
--- a/app/tools/gimpeditselectiontool.c
+++ b/app/tools/gimpeditselectiontool.c
@@ -56,6 +56,7 @@
 #include "gimpdrawtool.h"
 #include "gimpeditselectiontool.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 #include "tool_manager.h"
 
 #include "gimp-intl.h"
@@ -1195,6 +1196,7 @@ gimp_edit_selection_tool_translate (GimpTool          *tool,
   else if (locked_message)
     {
       gimp_tool_message_literal (tool, display, locked_message);
+      gimp_tools_blink_lock_box (display->gimp, item);
       return TRUE;
     }
 
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 2c589be38a..2fd6bd322e 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -72,6 +72,7 @@
 #include "gimpfiltertool-widgets.h"
 #include "gimpguidetool.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 #include "tool_manager.h"
 
 #include "gimp-intl.h"
@@ -273,6 +274,8 @@ gimp_filter_tool_initialize (GimpTool     *tool,
     {
       g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                            _("The active layer's pixels are locked."));
+      if (error)
+        gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
       return FALSE;
     }
 
diff --git a/app/tools/gimpgradienttool.c b/app/tools/gimpgradienttool.c
index c3050ba2ad..741a68e22d 100644
--- a/app/tools/gimpgradienttool.c
+++ b/app/tools/gimpgradienttool.c
@@ -51,6 +51,7 @@
 #include "gimpgradienttool.h"
 #include "gimpgradienttool-editor.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -252,6 +253,8 @@ gimp_gradient_tool_initialize (GimpTool     *tool,
     {
       g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
                            _("The active layer's pixels are locked."));
+      if (error)
+        gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
       return FALSE;
     }
 
diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c
index 393d51f903..afd2666c8b 100644
--- a/app/tools/gimpmovetool.c
+++ b/app/tools/gimpmovetool.c
@@ -56,6 +56,7 @@
 #include "gimpmoveoptions.h"
 #include "gimpmovetool.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -336,6 +337,7 @@ gimp_move_tool_button_press (GimpTool            *tool,
   else if (locked_message)
     {
       gimp_tool_message_literal (tool, display, locked_message);
+      gimp_tools_blink_lock_box (display->gimp, active_item);
       gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
       return;
     }
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 3b37769505..b303831019 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -53,6 +53,7 @@
 #include "gimppainttool.h"
 #include "gimppainttool-paint.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -105,6 +106,7 @@ static GimpCanvasItem *
 
 static gboolean  gimp_paint_tool_check_alpha (GimpPaintTool         *paint_tool,
                                               GimpDrawable          *drawable,
+                                              GimpDisplay           *display,
                                               GError               **error);
 
 static void   gimp_paint_tool_hard_notify    (GimpPaintOptions      *options,
@@ -282,10 +284,11 @@ gimp_paint_tool_button_press (GimpTool            *tool,
     {
       gimp_tool_message_literal (tool, display,
                                  _("The active layer's pixels are locked."));
+      gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
       return;
     }
 
-  if (! gimp_paint_tool_check_alpha (paint_tool, drawable, &error))
+  if (! gimp_paint_tool_check_alpha (paint_tool, drawable, display, &error))
     {
       GtkWidget *options_gui;
       GtkWidget *mode_box;
@@ -485,9 +488,9 @@ gimp_paint_tool_cursor_update (GimpTool         *tool,
       GimpImage    *image    = gimp_display_get_image (display);
       GimpDrawable *drawable = gimp_image_get_active_drawable (image);
 
-      if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))      ||
-          gimp_item_is_content_locked (GIMP_ITEM (drawable))         ||
-          ! gimp_paint_tool_check_alpha (paint_tool, drawable, NULL) ||
+      if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))               ||
+          gimp_item_is_content_locked (GIMP_ITEM (drawable))                  ||
+          ! gimp_paint_tool_check_alpha (paint_tool, drawable, display, NULL) ||
           ! gimp_item_is_visible (GIMP_ITEM (drawable)))
         {
           modifier        = GIMP_CURSOR_MODIFIER_BAD;
@@ -821,6 +824,7 @@ gimp_paint_tool_get_outline (GimpPaintTool *paint_tool,
 static gboolean
 gimp_paint_tool_check_alpha (GimpPaintTool  *paint_tool,
                              GimpDrawable   *drawable,
+                             GimpDisplay    *display,
                              GError        **error)
 {
   GimpPaintToolClass *klass = GIMP_PAINT_TOOL_GET_CLASS (paint_tool);
@@ -843,6 +847,9 @@ gimp_paint_tool_check_alpha (GimpPaintTool  *paint_tool,
             error, GIMP_ERROR, GIMP_FAILED,
             _("The active layer's alpha channel is locked."));
 
+          if (error)
+            gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
+
           return FALSE;
         }
     }
diff --git a/app/tools/gimpselectiontool.c b/app/tools/gimpselectiontool.c
index bf75d9769f..96396091bd 100644
--- a/app/tools/gimpselectiontool.c
+++ b/app/tools/gimpselectiontool.c
@@ -38,6 +38,7 @@
 #include "gimpselectiontool.h"
 #include "gimpselectionoptions.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -451,6 +452,9 @@ gimp_selection_tool_check (GimpSelectionTool  *sel_tool,
           g_set_error (error, GIMP_ERROR, GIMP_FAILED,
                        _("The active layer's pixels are locked."));
 
+          if (error)
+            gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
+
           return FALSE;
         }
       break;
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index c91f6d0883..1ace39b5d9 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -46,6 +46,7 @@
 #include "widgets/gimpwidgets-utils.h"
 
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 #include "gimptransformoptions.h"
 #include "gimptransformtool.h"
 
@@ -569,6 +570,8 @@ gimp_transform_tool_check_active_item (GimpTransformTool  *tr_tool,
   if (locked_message)
     {
       g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, locked_message);
+      if (error)
+        gimp_tools_blink_lock_box (display->gimp, item);
       return NULL;
     }
 
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index f01f4b63a4..74075bbd88 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -48,6 +48,7 @@
 #include "gimpwarptool.h"
 #include "gimpwarpoptions.h"
 #include "gimptoolcontrol.h"
+#include "gimptools-utils.h"
 
 #include "gimp-intl.h"
 
@@ -629,6 +630,8 @@ gimp_warp_tool_can_stroke (GimpWarpTool *wt,
         {
           gimp_tool_message_literal (tool, display,
                                      _("The active layer's pixels are locked."));
+
+          gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
         }
 
       return FALSE;


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