[gimp/mypaint-brush: 6/10] app: connect the MyPaint brush radius to the tool tip size action



commit cb4a85b7f62b0e363162eed851d7dab7a818afe8
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 3 22:37:30 2014 +0200

    app: connect the MyPaint brush radius to the tool tip size action

 app/actions/tools-actions.c  |   13 +++++++++++++
 app/actions/tools-commands.c |   22 ++++++++++++++++++++++
 app/actions/tools-commands.h |    4 ++++
 app/tools/gimpmybrushtool.c  |    4 +++-
 app/widgets/gimpaction.c     |    1 +
 5 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/app/actions/tools-actions.c b/app/actions/tools-actions.c
index 26fb26e..e94bec1 100644
--- a/app/actions/tools-actions.c
+++ b/app/actions/tools-actions.c
@@ -185,6 +185,14 @@ static const GimpEnumActionEntry tools_airbrush_flow_actions[] =
     NULL }
 };
 
+static const GimpEnumActionEntry tools_mybrush_radius_actions[] =
+{
+  { "tools-mybrush-radius-set", GIMP_STOCK_TOOL_MYBRUSH,
+    "Set MyPaint Brush Radius", NULL, NULL,
+    GIMP_ACTION_SELECT_SET, TRUE,
+    NULL }
+};
+
 static const GimpEnumActionEntry tools_foreground_select_brush_size_actions[] =
 {
   { "tools-foreground-select-brush-size-set",
@@ -498,6 +506,11 @@ tools_actions_setup (GimpActionGroup *group)
                                       G_CALLBACK (tools_airbrush_flow_cmd_callback));
 
   gimp_action_group_add_enum_actions (group, NULL,
+                                      tools_mybrush_radius_actions,
+                                      G_N_ELEMENTS (tools_mybrush_radius_actions),
+                                      G_CALLBACK (tools_mybrush_radius_cmd_callback));
+
+  gimp_action_group_add_enum_actions (group, NULL,
                                       tools_foreground_select_brush_size_actions,
                                       G_N_ELEMENTS (tools_foreground_select_brush_size_actions),
                                       G_CALLBACK (tools_fg_select_brush_size_cmd_callback));
diff --git a/app/actions/tools-commands.c b/app/actions/tools-commands.c
index 93a7071..605c93d 100644
--- a/app/actions/tools-commands.c
+++ b/app/actions/tools-commands.c
@@ -31,6 +31,7 @@
 
 #include "paint/gimpinkoptions.h"
 #include "paint/gimpairbrushoptions.h"
+#include "paint/gimpmybrushoptions.h"
 
 #include "widgets/gimpenumaction.h"
 #include "widgets/gimpuimanager.h"
@@ -294,6 +295,27 @@ tools_airbrush_flow_cmd_callback (GtkAction *action,
 }
 
 void
+tools_mybrush_radius_cmd_callback (GtkAction *action,
+                                    gint       value,
+                                    gpointer   data)
+{
+  GimpContext  *context;
+  GimpToolInfo *tool_info;
+  return_if_no_context (context, data);
+
+  tool_info = gimp_context_get_tool (context);
+
+  if (tool_info && GIMP_IS_MYBRUSH_OPTIONS (tool_info->tool_options))
+    {
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (tool_info->tool_options),
+                              "radius",
+                              0.1, 0.1, 0.5, 1.0, FALSE);
+    }
+}
+
+void
 tools_fg_select_brush_size_cmd_callback (GtkAction *action,
                                          gint       value,
                                          gpointer   data)
diff --git a/app/actions/tools-commands.h b/app/actions/tools-commands.h
index ddabf76..24c2de5 100644
--- a/app/actions/tools-commands.h
+++ b/app/actions/tools-commands.h
@@ -54,6 +54,10 @@ void   tools_airbrush_flow_cmd_callback             (GtkAction   *action,
                                                      gint         value,
                                                      gpointer     data);
 
+void   tools_mybrush_radius_cmd_callback            (GtkAction   *action,
+                                                     gint         value,
+                                                     gpointer     data);
+
 void   tools_fg_select_brush_size_cmd_callback      (GtkAction   *action,
                                                      gint         value,
                                                      gpointer     data);
diff --git a/app/tools/gimpmybrushtool.c b/app/tools/gimpmybrushtool.c
index b436bbd..5e31ac2 100644
--- a/app/tools/gimpmybrushtool.c
+++ b/app/tools/gimpmybrushtool.c
@@ -80,7 +80,9 @@ gimp_mybrush_tool_init (GimpMybrushTool *mybrush_tool)
 {
   GimpTool *tool = GIMP_TOOL (mybrush_tool);
 
-  gimp_tool_control_set_tool_cursor   (tool->control, GIMP_TOOL_CURSOR_INK);
+  gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_INK);
+  gimp_tool_control_set_action_size (tool->control,
+                                     "tools/tools-mybrush-radius-set");
 
   gimp_paint_tool_enable_color_picker (GIMP_PAINT_TOOL (mybrush_tool),
                                        GIMP_COLOR_PICK_MODE_FOREGROUND);
diff --git a/app/widgets/gimpaction.c b/app/widgets/gimpaction.c
index 535963f..1d5b2d1 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -330,6 +330,7 @@ gimp_action_is_gui_blacklisted (const gchar *action_name)
       "tools-ink-blob-size-",
       "tools-ink-blob-aspect-",
       "tools-ink-blob-angle-",
+      "tools-mybrush-radius-",
       "tools-foreground-select-brush-size-",
       "tools-transform-preview-opacity-",
       "tools-warp-effect-size-"


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