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.
This commit is contained in:
Ell
2018-12-10 08:22:50 -05:00
parent 9bdaec3a49
commit 637105b962
12 changed files with 48 additions and 4 deletions

View File

@ -37,6 +37,8 @@
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
#include "tools/gimptools-utils.h"
#include "gimpcanvashandle.h" #include "gimpcanvashandle.h"
#include "gimpcanvasitem-utils.h" #include "gimpcanvasitem-utils.h"
#include "gimpcanvasline.h" #include "gimpcanvasline.h"
@ -492,6 +494,8 @@ static gboolean
gimp_tool_path_check_writable (GimpToolPath *path) gimp_tool_path_check_writable (GimpToolPath *path)
{ {
GimpToolPathPrivate *private = path->private; 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)) || if (gimp_item_is_content_locked (GIMP_ITEM (private->vectors)) ||
gimp_item_is_position_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), gimp_tool_widget_set_status (GIMP_TOOL_WIDGET (path),
_("The active path is locked.")); _("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; private->function = VECTORS_FINISHED;
return FALSE; return FALSE;

View File

@ -55,6 +55,7 @@
#include "gimpbucketfilltool.h" #include "gimpbucketfilltool.h"
#include "gimpcoloroptions.h" #include "gimpcoloroptions.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -292,6 +293,8 @@ gimp_bucket_fill_tool_initialize (GimpTool *tool,
{ {
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }

View File

@ -50,6 +50,7 @@
#include "gimpcagetool.h" #include "gimpcagetool.h"
#include "gimpcageoptions.h" #include "gimpcageoptions.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -225,6 +226,8 @@ gimp_cage_tool_initialize (GimpTool *tool,
{ {
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }

View File

@ -40,6 +40,7 @@
#include "gimpcroptool.h" #include "gimpcroptool.h"
#include "gimprectangleoptions.h" #include "gimprectangleoptions.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -458,6 +459,8 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
{ {
gimp_tool_message_literal (tool, tool->display, gimp_tool_message_literal (tool, tool->display,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
gimp_tools_blink_lock_box (tool->display->gimp,
GIMP_ITEM (layer));
return; return;
} }

View File

@ -56,6 +56,7 @@
#include "gimpdrawtool.h" #include "gimpdrawtool.h"
#include "gimpeditselectiontool.h" #include "gimpeditselectiontool.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "tool_manager.h" #include "tool_manager.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -1196,6 +1197,7 @@ gimp_edit_selection_tool_translate (GimpTool *tool,
else if (locked_message) else if (locked_message)
{ {
gimp_tool_message_literal (tool, display, locked_message); gimp_tool_message_literal (tool, display, locked_message);
gimp_tools_blink_lock_box (display->gimp, item);
return TRUE; return TRUE;
} }

View File

@ -72,6 +72,7 @@
#include "gimpfiltertool-widgets.h" #include "gimpfiltertool-widgets.h"
#include "gimpguidetool.h" #include "gimpguidetool.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "tool_manager.h" #include "tool_manager.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -273,6 +274,8 @@ gimp_filter_tool_initialize (GimpTool *tool,
{ {
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }

View File

@ -51,6 +51,7 @@
#include "gimpgradienttool.h" #include "gimpgradienttool.h"
#include "gimpgradienttool-editor.h" #include "gimpgradienttool-editor.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -252,6 +253,8 @@ gimp_gradient_tool_initialize (GimpTool *tool,
{ {
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }

View File

@ -56,6 +56,7 @@
#include "gimpmoveoptions.h" #include "gimpmoveoptions.h"
#include "gimpmovetool.h" #include "gimpmovetool.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -336,6 +337,7 @@ gimp_move_tool_button_press (GimpTool *tool,
else if (locked_message) else if (locked_message)
{ {
gimp_tool_message_literal (tool, display, 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); gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
return; return;
} }

View File

@ -53,6 +53,7 @@
#include "gimppainttool.h" #include "gimppainttool.h"
#include "gimppainttool-paint.h" #include "gimppainttool-paint.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -105,6 +106,7 @@ static GimpCanvasItem *
static gboolean gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool, static gboolean gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpDisplay *display,
GError **error); GError **error);
static void gimp_paint_tool_hard_notify (GimpPaintOptions *options, 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, gimp_tool_message_literal (tool, display,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return; 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 *options_gui;
GtkWidget *mode_box; GtkWidget *mode_box;
@ -487,7 +490,7 @@ gimp_paint_tool_cursor_update (GimpTool *tool,
if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) || if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) ||
gimp_item_is_content_locked (GIMP_ITEM (drawable)) || gimp_item_is_content_locked (GIMP_ITEM (drawable)) ||
! gimp_paint_tool_check_alpha (paint_tool, drawable, NULL) || ! gimp_paint_tool_check_alpha (paint_tool, drawable, display, NULL) ||
! gimp_item_is_visible (GIMP_ITEM (drawable))) ! gimp_item_is_visible (GIMP_ITEM (drawable)))
{ {
modifier = GIMP_CURSOR_MODIFIER_BAD; modifier = GIMP_CURSOR_MODIFIER_BAD;
@ -821,6 +824,7 @@ gimp_paint_tool_get_outline (GimpPaintTool *paint_tool,
static gboolean static gboolean
gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool, gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
GimpDrawable *drawable, GimpDrawable *drawable,
GimpDisplay *display,
GError **error) GError **error)
{ {
GimpPaintToolClass *klass = GIMP_PAINT_TOOL_GET_CLASS (paint_tool); 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, error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's alpha channel is locked.")); _("The active layer's alpha channel is locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }
} }

View File

@ -38,6 +38,7 @@
#include "gimpselectiontool.h" #include "gimpselectiontool.h"
#include "gimpselectionoptions.h" #include "gimpselectionoptions.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -451,6 +452,9 @@ gimp_selection_tool_check (GimpSelectionTool *sel_tool,
g_set_error (error, GIMP_ERROR, GIMP_FAILED, g_set_error (error, GIMP_ERROR, GIMP_FAILED,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
if (error)
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
return FALSE; return FALSE;
} }
break; break;

View File

@ -46,6 +46,7 @@
#include "widgets/gimpwidgets-utils.h" #include "widgets/gimpwidgets-utils.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimptransformoptions.h" #include "gimptransformoptions.h"
#include "gimptransformtool.h" #include "gimptransformtool.h"
@ -572,6 +573,8 @@ gimp_transform_tool_check_active_item (GimpTransformTool *tr_tool,
if (locked_message) if (locked_message)
{ {
g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, 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; return NULL;
} }

View File

@ -48,6 +48,7 @@
#include "gimpwarptool.h" #include "gimpwarptool.h"
#include "gimpwarpoptions.h" #include "gimpwarpoptions.h"
#include "gimptoolcontrol.h" #include "gimptoolcontrol.h"
#include "gimptools-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -629,6 +630,8 @@ gimp_warp_tool_can_stroke (GimpWarpTool *wt,
{ {
gimp_tool_message_literal (tool, display, gimp_tool_message_literal (tool, display,
_("The active layer's pixels are locked.")); _("The active layer's pixels are locked."));
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
} }
return FALSE; return FALSE;