[gimp] app: don't let updating the gradient editor actions dirty the gradient



commit afc3d4281ecaabf2820d32fd4959e653da26175f
Author: Michael Natterer <mitch gimp org>
Date:   Tue Feb 24 20:58:19 2015 +0100

    app: don't let updating the gradient editor actions dirty the gradient
    
    ...at least not most of the time, gradients are beasts. Also some
    unrelated minor cleanup.

 app/actions/gradient-editor-commands.c |   50 ++++++++++++++++---------------
 1 files changed, 26 insertions(+), 24 deletions(-)
---
diff --git a/app/actions/gradient-editor-commands.c b/app/actions/gradient-editor-commands.c
index 86a723a..daa0a5f 100644
--- a/app/actions/gradient-editor-commands.c
+++ b/app/actions/gradient-editor-commands.c
@@ -113,16 +113,19 @@ gradient_editor_left_color_type_cmd_callback (GtkAction *action,
 {
   GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
   GimpGradient       *gradient;
-  gint                value;
+  GimpGradientColor   color_type;
 
   gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
-  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+  color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
-  if (gradient && value >= 0)
+  if (gradient        &&
+      color_type >= 0 &&
+      color_type !=
+      gimp_gradient_segment_get_left_color_type (gradient,
+                                                 editor->control_sel_l))
     {
-      GimpGradientColor color_type = value;
-      GimpRGB           color;
+      GimpRGB color;
 
       gimp_gradient_get_color_at (gradient,
                                   GIMP_DATA_EDITOR (editor)->context,
@@ -264,16 +267,19 @@ gradient_editor_right_color_type_cmd_callback (GtkAction *action,
 {
   GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
   GimpGradient       *gradient;
-  gint                value;
+  GimpGradientColor   color_type;
 
   gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
-  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+  color_type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
-  if (gradient && value >= 0)
+  if (gradient        &&
+      color_type >= 0 &&
+      color_type !=
+      gimp_gradient_segment_get_right_color_type (gradient,
+                                                  editor->control_sel_r))
     {
-      GimpGradientColor color_type = value;
-      GimpRGB           color;
+      GimpRGB color;
 
       gimp_gradient_get_color_at (gradient,
                                   GIMP_DATA_EDITOR (editor)->context,
@@ -374,18 +380,16 @@ gradient_editor_blending_func_cmd_callback (GtkAction *action,
                                             GtkAction *current,
                                             gpointer   data)
 {
-  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
-  GimpGradient       *gradient;
-  gint                value;
+  GimpGradientEditor      *editor = GIMP_GRADIENT_EDITOR (data);
+  GimpGradient            *gradient;
+  GimpGradientSegmentType  type;
 
   gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
-  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+  type = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
-  if (gradient && value >= 0)
+  if (gradient && type >= 0)
     {
-      GimpGradientSegmentType type = value;
-
       gimp_gradient_segment_range_set_blending_function (gradient,
                                                          editor->control_sel_l,
                                                          editor->control_sel_r,
@@ -398,18 +402,16 @@ gradient_editor_coloring_type_cmd_callback (GtkAction *action,
                                             GtkAction *current,
                                             gpointer   data)
 {
-  GimpGradientEditor *editor = GIMP_GRADIENT_EDITOR (data);
-  GimpGradient       *gradient;
-  gint                value;
+  GimpGradientEditor       *editor = GIMP_GRADIENT_EDITOR (data);
+  GimpGradient             *gradient;
+  GimpGradientSegmentColor  color;
 
   gradient = GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data);
 
-  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+  color = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
 
-  if (gradient && value >= 0)
+  if (gradient && color >= 0)
     {
-      GimpGradientSegmentColor color = value;
-
       gimp_gradient_segment_range_set_coloring_type (gradient,
                                                      editor->control_sel_l,
                                                      editor->control_sel_r,


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