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



commit 4f065c370c82c36cdd8af1ad58af9f58ed0a3757
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 bb88890..7649575 100644
--- a/app/actions/tools-actions.c
+++ b/app/actions/tools-actions.c
@@ -121,6 +121,14 @@ static const GimpEnumActionEntry tools_ink_blob_angle_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",
@@ -425,6 +433,11 @@ tools_actions_setup (GimpActionGroup *group)
                                       G_CALLBACK (tools_ink_blob_angle_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 6fc6cf6..e64ea79 100644
--- a/app/actions/tools-commands.c
+++ b/app/actions/tools-commands.c
@@ -30,6 +30,7 @@
 #include "core/gimptoolinfo.h"
 
 #include "paint/gimpinkoptions.h"
+#include "paint/gimpmybrushoptions.h"
 
 #include "widgets/gimpenumaction.h"
 #include "widgets/gimpuimanager.h"
@@ -251,6 +252,27 @@ tools_ink_blob_angle_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 cfeca2e..01588cb 100644
--- a/app/actions/tools-commands.h
+++ b/app/actions/tools-commands.h
@@ -47,6 +47,10 @@ void   tools_ink_blob_angle_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 df847ef..e05e6f2 100644
--- a/app/widgets/gimpaction.c
+++ b/app/widgets/gimpaction.c
@@ -336,6 +336,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]