[gimp/gtk3-port: 30/237] app: port to GtkWidget::draw() and s/GtkObject/GtkAdjustment/



commit e179be1759bfe0e064b7c5a808fb20f95d19a42c
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 14:19:42 2010 +0200

    app: port to GtkWidget::draw() and s/GtkObject/GtkAdjustment/

 app/widgets/gimpgradienteditor.c |   66 ++++++++++++++++++--------------------
 app/widgets/gimpgradienteditor.h |    2 +-
 2 files changed, 32 insertions(+), 36 deletions(-)
---
diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c
index 1f7f0a3..ab1a182 100644
--- a/app/widgets/gimpgradienteditor.c
+++ b/app/widgets/gimpgradienteditor.c
@@ -159,8 +159,8 @@ static void      view_pick_color                  (GimpGradientEditor *editor,
 static gboolean  control_events                   (GtkWidget          *widget,
                                                    GdkEvent           *event,
                                                    GimpGradientEditor *editor);
-static gboolean  control_expose                   (GtkWidget          *widget,
-                                                   GdkEventExpose     *event,
+static gboolean  control_draw                     (GtkWidget          *widget,
+                                                   cairo_t            *cr,
                                                    GimpGradientEditor *editor);
 static void      control_do_hint                  (GimpGradientEditor *editor,
                                                    gint                x,
@@ -201,7 +201,7 @@ static double    control_move                     (GimpGradientEditor  *editor,
 static void      control_update                   (GimpGradientEditor *editor,
                                                    GimpGradient       *gradient,
                                                    gboolean            recalculate);
-static void      control_draw                     (GimpGradientEditor *editor,
+static void      control_draw_all                 (GimpGradientEditor *editor,
                                                    GimpGradient       *gradient,
                                                    cairo_t            *cr,
                                                    gint                width,
@@ -352,8 +352,8 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
                     G_CALLBACK (control_events),
                     editor);
 
-  g_signal_connect (editor->control, "expose-event",
-                    G_CALLBACK (control_expose),
+  g_signal_connect (editor->control, "draw",
+                    G_CALLBACK (control_draw),
                     editor);
 
   gimp_dnd_color_dest_add (GTK_WIDGET (editor->control),
@@ -375,7 +375,7 @@ gimp_gradient_editor_init (GimpGradientEditor *editor)
                     G_CALLBACK (gradient_editor_scrollbar_update),
                     editor);
 
-  editor->scrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (editor->scroll_data));
+  editor->scrollbar = gtk_hscrollbar_new (editor->scroll_data);
   gtk_box_pack_start (GTK_BOX (editor), editor->scrollbar, FALSE, FALSE, 0);
   gtk_widget_show (editor->scrollbar);
 
@@ -560,7 +560,7 @@ gimp_gradient_editor_zoom (GimpGradientEditor *editor,
 
   g_return_if_fail (GIMP_IS_GRADIENT_EDITOR (editor));
 
-  adjustment = GTK_ADJUSTMENT (editor->scroll_data);
+  adjustment = editor->scroll_data;
 
   old_value     = gtk_adjustment_get_value (adjustment);
   old_page_size = gtk_adjustment_get_page_size (adjustment);
@@ -880,7 +880,7 @@ view_events (GtkWidget          *widget,
           }
         else
           {
-            GtkAdjustment *adj   = GTK_ADJUSTMENT (editor->scroll_data);
+            GtkAdjustment *adj   = editor->scroll_data;
             gfloat         value = gtk_adjustment_get_value (adj);
 
             switch (sevent->direction)
@@ -1076,9 +1076,8 @@ control_events (GtkWidget          *widget,
           }
         else
           {
-            GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data);
-
-            gfloat new_value;
+            GtkAdjustment *adj = editor->scroll_data;
+            gfloat         new_value;
 
             new_value = (gtk_adjustment_get_value (adj) +
                          ((sevent->direction == GDK_SCROLL_UP) ?
@@ -1179,26 +1178,23 @@ control_events (GtkWidget          *widget,
 }
 
 static gboolean
-control_expose (GtkWidget          *widget,
-                GdkEventExpose     *event,
-                GimpGradientEditor *editor)
+control_draw (GtkWidget          *widget,
+              cairo_t            *cr,
+              GimpGradientEditor *editor)
 {
-  GtkAdjustment *adj = GTK_ADJUSTMENT (editor->scroll_data);
-  cairo_t       *cr  = gdk_cairo_create (gtk_widget_get_window (widget));
+  GtkAdjustment *adj = editor->scroll_data;
   GtkAllocation  allocation;
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  control_draw (editor,
-                GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data),
-                cr,
-                allocation.width,
-                allocation.height,
-                gtk_adjustment_get_value (adj),
-                gtk_adjustment_get_value (adj) +
-                gtk_adjustment_get_page_size (adj));
-
-  cairo_destroy (cr);
+  control_draw_all (editor,
+                    GIMP_GRADIENT (GIMP_DATA_EDITOR (editor)->data),
+                    cr,
+                    allocation.width,
+                    allocation.height,
+                    gtk_adjustment_get_value (adj),
+                    gtk_adjustment_get_value (adj) +
+                    gtk_adjustment_get_page_size (adj));
 
   return TRUE;
 }
@@ -1695,13 +1691,13 @@ control_update (GimpGradientEditor *editor,
 }
 
 static void
-control_draw (GimpGradientEditor *editor,
-              GimpGradient       *gradient,
-              cairo_t            *cr,
-              gint                width,
-              gint                height,
-              gdouble             left,
-              gdouble             right)
+control_draw_all (GimpGradientEditor *editor,
+                  GimpGradient       *gradient,
+                  cairo_t            *cr,
+                  gint                width,
+                  gint                height,
+                  gdouble             left,
+                  gdouble             right)
 {
   GtkStyle               *control_style;
   GimpGradientSegment    *seg;
@@ -1846,7 +1842,7 @@ static gint
 control_calc_p_pos (GimpGradientEditor *editor,
                     gdouble             pos)
 {
-  GtkAdjustment *adjustment = GTK_ADJUSTMENT (editor->scroll_data);
+  GtkAdjustment *adjustment = editor->scroll_data;
   GtkAllocation  allocation;
   gint           pwidth;
 
@@ -1868,7 +1864,7 @@ static gdouble
 control_calc_g_pos (GimpGradientEditor *editor,
                     gint                pos)
 {
-  GtkAdjustment *adjustment = GTK_ADJUSTMENT (editor->scroll_data);
+  GtkAdjustment *adjustment = editor->scroll_data;
   GtkAllocation  allocation;
   gint           pwidth;
 
diff --git a/app/widgets/gimpgradienteditor.h b/app/widgets/gimpgradienteditor.h
index e9b7272..6387c33 100644
--- a/app/widgets/gimpgradienteditor.h
+++ b/app/widgets/gimpgradienteditor.h
@@ -61,7 +61,7 @@ struct _GimpGradientEditor
 
   /*  Zoom and scrollbar  */
   guint           zoom_factor;
-  GtkObject      *scroll_data;
+  GtkAdjustment  *scroll_data;
 
   /*  Color dialog  */
   GtkWidget      *color_dialog;



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