[gimp] app: separate handling of reverse-gradient from paint dynamics



commit 4300612962717a168e3b3cfdf30327ca68976e01
Author: Michael Natterer <mitch gimp org>
Date:   Tue Dec 6 22:32:23 2011 +0100

    app: separate handling of reverse-gradient from paint dynamics
    
    because it belongs to the gradient and should be changed whenever the
    gradient gets changed.
    
    Introduce gimp_paint_options_copy_gradient_props() and call it at the
    right places in the tool manager.

 app/paint/gimppaintoptions.c |   35 ++++++++++++++++++++++++-----------
 app/paint/gimppaintoptions.h |    6 +++---
 app/tools/tool_manager.c     |   11 +++++++++++
 3 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index 9b62e24..67724e0 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -745,19 +745,16 @@ gimp_paint_options_copy_dynamics_props (GimpPaintOptions *src,
   GimpUnit        fade_unit;
   GimpRepeatMode  fade_repeat;
 
-  gboolean        gradient_reverse;
-
   g_return_if_fail (GIMP_IS_PAINT_OPTIONS (src));
   g_return_if_fail (GIMP_IS_PAINT_OPTIONS (dest));
 
-    g_object_get (src,
-                  "dynamics-expanded", &dynamics_expanded,
-                  "fade-reverse", &fade_reverse,
-                  "fade-length", &fade_length,
-                  "fade-unit", &fade_unit,
-                  "fade-repeat", &fade_repeat,
-                  "gradient-reverse", &gradient_reverse,
-                  NULL);
+  g_object_get (src,
+                "dynamics-expanded", &dynamics_expanded,
+                "fade-reverse", &fade_reverse,
+                "fade-length", &fade_length,
+                "fade-unit", &fade_unit,
+                "fade-repeat", &fade_repeat,
+                NULL);
 
   g_object_set (dest,
                 "dynamics-expanded", dynamics_expanded,
@@ -765,7 +762,23 @@ gimp_paint_options_copy_dynamics_props (GimpPaintOptions *src,
                 "fade-length", fade_length,
                 "fade-unit", fade_unit,
                 "fade-repeat", fade_repeat,
-                "gradient-reverse", gradient_reverse,
+                NULL);
+}
+
+void
+gimp_paint_options_copy_gradient_props (GimpPaintOptions *src,
+                                        GimpPaintOptions *dest)
+{
+  gboolean  gradient_reverse;
+
+  g_return_if_fail (GIMP_IS_PAINT_OPTIONS (src));
+  g_return_if_fail (GIMP_IS_PAINT_OPTIONS (dest));
+
+  g_object_get (src,
+                "gradient-reverse", &gradient_reverse,
                 NULL);
 
+  g_object_set (dest,
+                "gradient-reverse", gradient_reverse,
+                NULL);
 }
diff --git a/app/paint/gimppaintoptions.h b/app/paint/gimppaintoptions.h
index 95fda9d..ea03e0e 100644
--- a/app/paint/gimppaintoptions.h
+++ b/app/paint/gimppaintoptions.h
@@ -131,12 +131,12 @@ gboolean gimp_paint_options_get_gradient_color (GimpPaintOptions *paint_options,
 GimpBrushApplicationMode
              gimp_paint_options_get_brush_mode (GimpPaintOptions *paint_options);
 
-void       gimp_paint_options_copy_brush_props (GimpPaintOptions *src,
+void    gimp_paint_options_copy_brush_props    (GimpPaintOptions *src,
                                                 GimpPaintOptions *dest);
-
 void    gimp_paint_options_copy_dynamics_props (GimpPaintOptions *src,
                                                 GimpPaintOptions *dest);
-
+void    gimp_paint_options_copy_gradient_props (GimpPaintOptions *src,
+                                                GimpPaintOptions *dest);
 
 
 #endif  /*  __GIMP_PAINT_OPTIONS_H__  */
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 405aee1..920c4fd 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -679,6 +679,10 @@ tool_manager_preset_changed (GimpContext     *user_context,
       if (config->global_dynamics && preset->use_dynamics)
         gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src),
                                                 GIMP_PAINT_OPTIONS (dest));
+
+      if (config->global_gradient && preset->use_gradient)
+        gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src),
+                                                GIMP_PAINT_OPTIONS (dest));
     }
 }
 
@@ -743,6 +747,10 @@ tool_manager_connect_options (GimpToolManager *tool_manager,
           if (config->global_dynamics)
             gimp_paint_options_copy_dynamics_props (tool_manager->shared_paint_options,
                                                     GIMP_PAINT_OPTIONS (tool_info->tool_options));
+
+          if (config->global_gradient)
+            gimp_paint_options_copy_gradient_props (tool_manager->shared_paint_options,
+                                                    GIMP_PAINT_OPTIONS (tool_info->tool_options));
         }
     }
 }
@@ -764,6 +772,9 @@ tool_manager_disconnect_options (GimpToolManager *tool_manager,
 
           gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (tool_info->tool_options),
                                                   tool_manager->shared_paint_options);
+
+          gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (tool_info->tool_options),
+                                                  tool_manager->shared_paint_options);
         }
 
       gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), NULL);



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