[gimp] app: various gradient editor changes and fixes



commit 0f0da4c7120031a3fd43e39f364bc653f41039b4
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jan 7 15:09:17 2011 +0100

    app: various gradient editor changes and fixes
    
    - return TRUE from event handlers if we handled the event
    - remove the "instant update" toggle and feature
    - move the color area left of the labels now that the toggle is gone

 app/actions/gradient-editor-commands.c |    4 +-
 app/widgets/gimpgradienteditor.c       |   70 ++++++++------------------------
 app/widgets/gimpgradienteditor.h       |    3 -
 app/widgets/gimpviewrenderergradient.c |    6 +--
 app/widgets/gimpviewrenderergradient.h |    3 +-
 5 files changed, 21 insertions(+), 65 deletions(-)
---
diff --git a/app/actions/gradient-editor-commands.c b/app/actions/gradient-editor-commands.c
index 4b86f7a..7834e94 100644
--- a/app/actions/gradient-editor-commands.c
+++ b/app/actions/gradient-editor-commands.c
@@ -88,7 +88,7 @@ gradient_editor_left_color_cmd_callback (GtkAction *action,
                            gimp_dialog_factory_get_singleton (),
                            "gimp-gradient-editor-color-dialog",
                            &editor->control_sel_l->left_color,
-                           editor->instant_update, TRUE);
+                           TRUE, TRUE);
 
   g_signal_connect (editor->color_dialog, "destroy",
                     G_CALLBACK (gtk_widget_destroyed),
@@ -239,7 +239,7 @@ gradient_editor_right_color_cmd_callback (GtkAction *action,
                            gimp_dialog_factory_get_singleton (),
                            "gimp-gradient-editor-color-dialog",
                            &editor->control_sel_l->right_color,
-                           editor->instant_update, TRUE);
+                           TRUE, TRUE);
 
   g_signal_connect (editor->color_dialog, "destroy",
                     G_CALLBACK (gtk_widget_destroyed),
diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c
index a5fe306..7f48d42 100644
--- a/app/widgets/gimpgradienteditor.c
+++ b/app/widgets/gimpgradienteditor.c
@@ -80,7 +80,7 @@
 
 #define GRAD_VIEW_SIZE            96
 #define GRAD_CONTROL_HEIGHT       14
-#define GRAD_CURRENT_COLOR_WIDTH  64
+#define GRAD_CURRENT_COLOR_WIDTH  16
 
 #define GRAD_MOVE_TIME 150 /* ms between mouse click and detection of movement in gradient control */
 
@@ -136,8 +136,6 @@ static void   gradient_editor_control_drop_color    (GtkWidget          *widget,
                                                      gpointer            data);
 static void   gradient_editor_scrollbar_update      (GtkAdjustment      *adj,
                                                      GimpGradientEditor *editor);
-static void   gradient_editor_instant_update_update (GtkWidget          *widget,
-                                                     GimpGradientEditor *editor);
 
 static void   gradient_editor_set_hint              (GimpGradientEditor *editor,
                                                      const gchar        *str1,
@@ -291,7 +289,7 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
   GtkWidget      *frame;
   GtkWidget      *vbox;
   GtkWidget      *hbox;
-  GtkWidget      *button;
+  GtkWidget      *hint_vbox;
   GimpRGB         transp;
 
   gimp_rgba_set (&transp, 0.0, 0.0, 0.0, 0.0);
@@ -380,15 +378,11 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
                     editor);
 
   editor->scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (editor->scroll_data));
-  gtk_range_set_update_policy (GTK_RANGE (editor->scrollbar),
-                               GTK_UPDATE_CONTINUOUS);
   gtk_box_pack_start (GTK_BOX (editor), editor->scrollbar, FALSE, FALSE, 0);
   gtk_widget_show (editor->scrollbar);
 
-  /* Box for current color and instant update toggle */
-  editor->instant_update = TRUE;
-
-  hbox = gtk_hbox_new (FALSE, 6);
+  /* Box for current color and the hint labels */
+  hbox = gtk_hbox_new (FALSE, 2);
   gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
   gtk_widget_show (hbox);
 
@@ -407,22 +401,15 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
                                GRAD_CURRENT_COLOR_WIDTH, -1);
   gtk_widget_show (editor->current_color);
 
-  /* Instant update toggle */
-  button = gtk_check_button_new_with_label (_("Instant update"));
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
-                                editor->instant_update);
-  gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
-  gtk_widget_show (button);
+  /* Hint box */
+  hint_vbox = gtk_vbox_new (FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox), hint_vbox, TRUE, TRUE, 0);
+  gtk_widget_show (hint_vbox);
 
-  g_signal_connect (button, "toggled",
-                    G_CALLBACK (gradient_editor_instant_update_update),
-                    editor);
-
-  /* Hint bar */
-  editor->hint_label1 = gradient_hint_label_add (GTK_BOX (editor));
-  editor->hint_label2 = gradient_hint_label_add (GTK_BOX (editor));
-  editor->hint_label3 = gradient_hint_label_add (GTK_BOX (editor));
-  editor->hint_label4 = gradient_hint_label_add (GTK_BOX (editor));
+  editor->hint_label1 = gradient_hint_label_add (GTK_BOX (hint_vbox));
+  editor->hint_label2 = gradient_hint_label_add (GTK_BOX (hint_vbox));
+  editor->hint_label3 = gradient_hint_label_add (GTK_BOX (hint_vbox));
+  editor->hint_label4 = gradient_hint_label_add (GTK_BOX (hint_vbox));
 
   /* Initialize other data */
   editor->left_saved_segments = NULL;
@@ -788,27 +775,10 @@ gradient_editor_scrollbar_update (GtkAdjustment      *adjustment,
   gimp_view_renderer_gradient_set_offsets (renderer,
                                            gtk_adjustment_get_value (adjustment),
                                            gtk_adjustment_get_value (adjustment) +
-                                           gtk_adjustment_get_page_size (adjustment),
-                                           editor->instant_update);
-  gimp_gradient_editor_update (editor);
-}
+                                           gtk_adjustment_get_page_size (adjustment));
 
-static void
-gradient_editor_instant_update_update (GtkWidget          *widget,
-                                       GimpGradientEditor *editor)
-{
-  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
-    {
-      editor->instant_update = TRUE;
-      gtk_range_set_update_policy (GTK_RANGE (editor->scrollbar),
-                                   GTK_UPDATE_CONTINUOUS);
-    }
-  else
-    {
-      editor->instant_update = FALSE;
-      gtk_range_set_update_policy (GTK_RANGE (editor->scrollbar),
-                                   GTK_UPDATE_DELAYED);
-    }
+  gimp_view_renderer_update (GIMP_VIEW_RENDERER (renderer));
+  gimp_gradient_editor_update (editor);
 }
 
 static void
@@ -1096,9 +1066,6 @@ control_events (GtkWidget          *widget,
                   g_signal_handlers_block_by_func (gradient,
                                                    gimp_gradient_editor_gradient_dirty,
                                                    editor);
-
-                  if (! editor->instant_update)
-                    gimp_data_freeze (GIMP_DATA (gradient));
                 }
             }
         }
@@ -1146,9 +1113,6 @@ control_events (GtkWidget          *widget,
           {
             if (GIMP_DATA_EDITOR (editor)->data_editable)
               {
-                if (! editor->instant_update)
-                  gimp_data_thaw (GIMP_DATA (gradient));
-
                 g_signal_handlers_unblock_by_func (gradient,
                                                    gimp_gradient_editor_gradient_dirty,
                                                    editor);
@@ -1216,10 +1180,10 @@ control_events (GtkWidget          *widget,
       break;
 
     default:
-      break;
+      return FALSE;
     }
 
-  return FALSE;
+  return TRUE;
 }
 
 static gboolean
diff --git a/app/widgets/gimpgradienteditor.h b/app/widgets/gimpgradienteditor.h
index 9f4be26..e9b7272 100644
--- a/app/widgets/gimpgradienteditor.h
+++ b/app/widgets/gimpgradienteditor.h
@@ -63,9 +63,6 @@ struct _GimpGradientEditor
   guint           zoom_factor;
   GtkObject      *scroll_data;
 
-  /*  Instant update  */
-  gboolean        instant_update;
-
   /*  Color dialog  */
   GtkWidget      *color_dialog;
 
diff --git a/app/widgets/gimpviewrenderergradient.c b/app/widgets/gimpviewrenderergradient.c
index a0ff120..dc7c577 100644
--- a/app/widgets/gimpviewrenderergradient.c
+++ b/app/widgets/gimpviewrenderergradient.c
@@ -206,8 +206,7 @@ gimp_view_renderer_gradient_render (GimpViewRenderer *renderer,
 void
 gimp_view_renderer_gradient_set_offsets (GimpViewRendererGradient *renderer,
                                          gdouble                   left,
-                                         gdouble                   right,
-                                         gboolean                  instant_update)
+                                         gdouble                   right)
 {
   g_return_if_fail (GIMP_IS_VIEW_RENDERER_GRADIENT (renderer));
 
@@ -220,9 +219,6 @@ gimp_view_renderer_gradient_set_offsets (GimpViewRendererGradient *renderer,
       renderer->right = right;
 
       gimp_view_renderer_invalidate (GIMP_VIEW_RENDERER (renderer));
-
-      if (instant_update)
-        gimp_view_renderer_update (GIMP_VIEW_RENDERER (renderer));
     }
 }
 
diff --git a/app/widgets/gimpviewrenderergradient.h b/app/widgets/gimpviewrenderergradient.h
index 6ec2a76..c1edbc3 100644
--- a/app/widgets/gimpviewrenderergradient.h
+++ b/app/widgets/gimpviewrenderergradient.h
@@ -53,8 +53,7 @@ GType   gimp_view_renderer_gradient_get_type    (void) G_GNUC_CONST;
 
 void    gimp_view_renderer_gradient_set_offsets (GimpViewRendererGradient *renderer,
                                                  gdouble                   left,
-                                                 gdouble                   right,
-                                                 gboolean                  instant_update);
+                                                 gdouble                   right);
 void    gimp_view_renderer_gradient_set_reverse (GimpViewRendererGradient *renderer,
                                                  gboolean                  reverse);
 



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