[gimp] app: in the paint tools, blink mode box when the current mode is invalid



commit 464bf1b0a9ccbc64064a63dec4727371b1109b20
Author: Ell <ell_se yahoo com>
Date:   Mon Dec 10 07:51:39 2018 -0500

    app: in the paint tools, blink mode box when the current mode is invalid
    
    In the paint tools, when the current paint mode is invalid, i.e.,
    when it requires an alpha channel, but the the current drawable has
    no alpha channel, or its alpha channel is locked, blink the paint-
    mode box widget in the tool options, in addition to showing an
    error message in the status bar, to hint at the source of the
    error.

 app/tools/gimppaintoptions-gui.c | 10 ++++++++++
 app/tools/gimppaintoptions-gui.h |  4 +++-
 app/tools/gimppainttool.c        | 14 ++++++++++++++
 3 files changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/app/tools/gimppaintoptions-gui.c b/app/tools/gimppaintoptions-gui.c
index b34008dffd..7955438ef7 100644
--- a/app/tools/gimppaintoptions-gui.c
+++ b/app/tools/gimppaintoptions-gui.c
@@ -114,6 +114,9 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
   gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 0);
   gtk_widget_show (menu);
 
+  g_object_set_data (G_OBJECT (vbox),
+                     "gimp-paint-options-gui-paint-mode-box", menu);
+
   if (tool_type == GIMP_TYPE_ERASER_TOOL     ||
       tool_type == GIMP_TYPE_CONVOLVE_TOOL   ||
       tool_type == GIMP_TYPE_DODGE_BURN_TOOL ||
@@ -286,6 +289,13 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
   return vbox;
 }
 
+GtkWidget *
+gimp_paint_options_gui_get_paint_mode_box (GtkWidget *options_gui)
+{
+  return g_object_get_data (G_OBJECT (options_gui),
+                            "gimp-paint-options-gui-paint-mode-box");
+}
+
 
 /*  private functions  */
 
diff --git a/app/tools/gimppaintoptions-gui.h b/app/tools/gimppaintoptions-gui.h
index 57d8af88c7..d747bbe576 100644
--- a/app/tools/gimppaintoptions-gui.h
+++ b/app/tools/gimppaintoptions-gui.h
@@ -19,7 +19,9 @@
 #define __GIMP_PAINT_OPTIONS_GUI_H__
 
 
-GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options);
+GtkWidget * gimp_paint_options_gui                    (GimpToolOptions *tool_options);
+
+GtkWidget * gimp_paint_options_gui_get_paint_mode_box (GtkWidget       *options_gui);
 
 
 #endif /* __GIMP_PAINT_OPTIONS_GUI_H__ */
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 335904dfaa..3b37769505 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -49,6 +49,7 @@
 #include "display/gimpdisplayshell-utils.h"
 
 #include "gimpcoloroptions.h"
+#include "gimppaintoptions-gui.h"
 #include "gimppainttool.h"
 #include "gimppainttool-paint.h"
 #include "gimptoolcontrol.h"
@@ -256,6 +257,7 @@ gimp_paint_tool_button_press (GimpTool            *tool,
 {
   GimpDrawTool     *draw_tool  = GIMP_DRAW_TOOL (tool);
   GimpPaintTool    *paint_tool = GIMP_PAINT_TOOL (tool);
+  GimpPaintOptions *options    = GIMP_PAINT_TOOL_GET_OPTIONS (tool);
   GimpDisplayShell *shell      = gimp_display_get_shell (display);
   GimpImage        *image      = gimp_display_get_image (display);
   GimpDrawable     *drawable   = gimp_image_get_active_drawable (image);
@@ -285,8 +287,20 @@ gimp_paint_tool_button_press (GimpTool            *tool,
 
   if (! gimp_paint_tool_check_alpha (paint_tool, drawable, &error))
     {
+      GtkWidget *options_gui;
+      GtkWidget *mode_box;
+
       gimp_tool_message_literal (tool, display, error->message);
+
+      options_gui = gimp_tools_get_tool_options_gui (
+                      GIMP_TOOL_OPTIONS (options));
+      mode_box    = gimp_paint_options_gui_get_paint_mode_box (options_gui);
+
+      if (gtk_widget_is_sensitive (mode_box))
+        gimp_widget_blink (mode_box);
+
       g_clear_error (&error);
+
       return;
     }
 


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