[gimp] Add status bar feedback for keyboard changes to brush paramaters.



commit 40fde28a620f4009ac207528deb0b6de9950ab36
Author: Stephen Griffiths <scgmk4 hotmail com>
Date:   Mon Apr 27 19:01:11 2009 +1000

    Add status bar feedback for keyboard changes to brush paramaters.
    
    * app/actions/context-commands.c:
    include core/gimptoolinfo.h
    include pain/gimppaintoptions.h
    
    context_opacity_cmd_callback()
    context_brush_spacing_cmd_callback()
    context_brush_spikes_cmd_callback()
    context_brush_hardness_cmd_callback()
    context_brush_aspect_cmd_callback()
    use 'action_select_property()' for statusbar feedback
    
    * app/core/gimpbrush.c: added translable string for brush spacing
    * app/paint/gimppaintoptions.c: add blurb to prop double brush-aspect-ratio
---
 app/actions/context-commands.c |   81 +++++++++++++++++++---------------------
 app/core/gimpbrush.c           |    3 +-
 app/paint/gimppaintoptions.c   |    2 +-
 3 files changed, 41 insertions(+), 45 deletions(-)

diff --git a/app/actions/context-commands.c b/app/actions/context-commands.c
index 3b18a0f..1ec0d86 100644
--- a/app/actions/context-commands.c
+++ b/app/actions/context-commands.c
@@ -31,6 +31,9 @@
 #include "core/gimpcontext.h"
 #include "core/gimpdatafactory.h"
 #include "core/gimplist.h"
+#include "core/gimptoolinfo.h"
+
+#include "paint/gimppaintoptions.h"
 
 #include "widgets/gimpdialogfactory.h"
 #include "widgets/gimpsessioninfo.h"
@@ -367,17 +370,20 @@ context_opacity_cmd_callback (GtkAction *action,
                               gint       value,
                               gpointer   data)
 {
-  GimpContext *context;
-  gdouble      opacity;
+  GimpContext  *context;
+  GimpToolInfo *tool_info;
   return_if_no_context (context, data);
 
-  opacity = action_select_value ((GimpActionSelectType) value,
-                                 gimp_context_get_opacity (context),
-                                 GIMP_OPACITY_TRANSPARENT,
-                                 GIMP_OPACITY_OPAQUE,
-                                 GIMP_OPACITY_OPAQUE,
-                                 1.0 / 255.0, 0.01, 0.1, 0.0, FALSE);
-  gimp_context_set_opacity (context, opacity);
+  tool_info = gimp_context_get_tool (context);
+
+  if (tool_info && GIMP_IS_TOOL_OPTIONS (tool_info->tool_options))
+    {
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (tool_info->tool_options),
+                              "opacity",
+                              1.0 / 255.0, 0.01, 0.1, FALSE);
+    }
 }
 
 void
@@ -478,17 +484,18 @@ context_brush_spacing_cmd_callback (GtkAction *action,
 {
   GimpContext *context;
   GimpBrush   *brush;
-  gint         spacing;
   return_if_no_context (context, data);
 
   brush = gimp_context_get_brush (context);
-  spacing = gimp_brush_get_spacing (brush);
-  spacing = action_select_value ((GimpActionSelectType) value,
-                                 spacing,
-                                 1.0, 5000.0, 20.0,
-                                 1.0, 5.0, 20.0, 0.0, FALSE);
-  gimp_brush_set_spacing (brush, spacing);
 
+  if (GIMP_IS_BRUSH (brush) && GIMP_DATA (brush)->writable)
+    {
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (brush),
+                              "spacing",
+                              1.0, 5.0, 20.0, FALSE);
+    }
 }
 
 void
@@ -574,15 +581,11 @@ context_brush_spikes_cmd_callback (GtkAction *action,
 
   if (GIMP_IS_BRUSH_GENERATED (brush) && GIMP_DATA (brush)->writable)
     {
-      GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
-      gint                spikes;
-
-      spikes = gimp_brush_generated_get_spikes (generated);
-      spikes = action_select_value ((GimpActionSelectType) value,
-                                    spikes,
-                                    2.0, 20.0, 2.0,
-                                    0.0, 1.0, 4.0, 0.0, FALSE);
-      gimp_brush_generated_set_spikes (generated, spikes);
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (brush),
+                              "spikes",
+                              0.0, 1.0, 4.0, FALSE);
     }
 }
 
@@ -599,15 +602,11 @@ context_brush_hardness_cmd_callback (GtkAction *action,
 
   if (GIMP_IS_BRUSH_GENERATED (brush) && GIMP_DATA (brush)->writable)
     {
-      GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
-      gdouble             hardness;
-
-      hardness = gimp_brush_generated_get_hardness (generated);
-      hardness = action_select_value ((GimpActionSelectType) value,
-                                      hardness,
-                                      0.0, 1.0, 1.0,
-                                      0.001, 0.01, 0.1, 0.0, FALSE);
-      gimp_brush_generated_set_hardness (generated, hardness);
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (brush),
+                              "hardness",
+                              0.001, 0.01, 0.1, FALSE);
     }
 }
 
@@ -624,15 +623,11 @@ context_brush_aspect_cmd_callback (GtkAction *action,
 
   if (GIMP_IS_BRUSH_GENERATED (brush) && GIMP_DATA (brush)->writable)
     {
-      GimpBrushGenerated *generated = GIMP_BRUSH_GENERATED (brush);
-      gdouble             aspect;
-
-      aspect = gimp_brush_generated_get_aspect_ratio (generated);
-      aspect = action_select_value ((GimpActionSelectType) value,
-                                    aspect,
-                                    1.0, 20.0, 1.0,
-                                    0.1, 1.0, 4.0, 0.0, FALSE);
-      gimp_brush_generated_set_aspect_ratio (generated, aspect);
+      action_select_property ((GimpActionSelectType) value,
+                              action_data_get_display (data),
+                              G_OBJECT (brush),
+                              "aspect-ratio",
+                              0.1, 1.0, 4.0, FALSE);
     }
 }
 
diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c
index 417162b..f463770 100644
--- a/app/core/gimpbrush.c
+++ b/app/core/gimpbrush.c
@@ -132,7 +132,8 @@ gimp_brush_class_init (GimpBrushClass *klass)
   klass->spacing_changed           = NULL;
 
   g_object_class_install_property (object_class, PROP_SPACING,
-                                   g_param_spec_double ("spacing", NULL, NULL,
+                                   g_param_spec_double ("spacing", NULL,
+                                                        _("Brush Spacing"),
                                                         1.0, 5000.0, 20.0,
                                                         GIMP_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT));
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 091ffae..96dd741 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -247,7 +247,7 @@ gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
                                    GIMP_PARAM_STATIC_STRINGS);
 
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_ASPECT_RATIO,
-                                   "brush-aspect-ratio", NULL,
+                                   "brush-aspect-ratio", _("Brush Aspect Ratio"),
                                    0.01, 10.0, DEFAULT_BRUSH_ASPECT_RATIO,
                                    GIMP_PARAM_STATIC_STRINGS);
   GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_BRUSH_ANGLE,



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