[gimp/gtk3-port: 58/226] libgimpwidgets: port to GtkWidget::draw()



commit 66f2f0eb724f156a6eb708f77776eb977f5fbbae
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 19 21:10:48 2010 +0200

    libgimpwidgets: port to GtkWidget::draw()

 libgimpwidgets/gimpcolorselect.c |   42 ++++++++++++-------------------------
 1 files changed, 14 insertions(+), 28 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c
index 922186d..2a327c6 100644
--- a/libgimpwidgets/gimpcolorselect.c
+++ b/libgimpwidgets/gimpcolorselect.c
@@ -174,8 +174,8 @@ static void   gimp_color_select_drop_color      (GtkWidget          *widget,
 static void  gimp_color_select_xy_size_allocate (GtkWidget          *widget,
                                                  GtkAllocation      *allocation,
                                                  GimpColorSelect    *select);
-static gboolean   gimp_color_select_xy_expose   (GtkWidget          *widget,
-                                                 GdkEventExpose     *eevent,
+static gboolean   gimp_color_select_xy_draw     (GtkWidget          *widget,
+                                                 cairo_t            *cr,
                                                  GimpColorSelect    *select);
 static gboolean   gimp_color_select_xy_events   (GtkWidget          *widget,
                                                  GdkEvent           *event,
@@ -183,8 +183,8 @@ static gboolean   gimp_color_select_xy_events   (GtkWidget          *widget,
 static void   gimp_color_select_z_size_allocate (GtkWidget          *widget,
                                                  GtkAllocation      *allocation,
                                                  GimpColorSelect    *select);
-static gboolean   gimp_color_select_z_expose    (GtkWidget          *widget,
-                                                 GdkEventExpose     *eevent,
+static gboolean   gimp_color_select_z_draw      (GtkWidget          *widget,
+                                                 cairo_t            *cr,
                                                  GimpColorSelect    *select);
 static gboolean   gimp_color_select_z_events    (GtkWidget          *widet,
                                                  GdkEvent           *event,
@@ -276,8 +276,8 @@ gimp_color_select_init (GimpColorSelect *select)
   g_signal_connect (select->xy_color, "size-allocate",
                     G_CALLBACK (gimp_color_select_xy_size_allocate),
                     select);
-  g_signal_connect_after (select->xy_color, "expose-event",
-                          G_CALLBACK (gimp_color_select_xy_expose),
+  g_signal_connect_after (select->xy_color, "draw",
+                          G_CALLBACK (gimp_color_select_xy_draw),
                           select);
   g_signal_connect (select->xy_color, "event",
                     G_CALLBACK (gimp_color_select_xy_events),
@@ -304,8 +304,8 @@ gimp_color_select_init (GimpColorSelect *select)
   g_signal_connect (select->z_color, "size-allocate",
                     G_CALLBACK (gimp_color_select_z_size_allocate),
                     select);
-  g_signal_connect_after (select->z_color, "expose-event",
-                          G_CALLBACK (gimp_color_select_z_expose),
+  g_signal_connect_after (select->z_color, "draw",
+                          G_CALLBACK (gimp_color_select_z_draw),
                           select);
   g_signal_connect (select->z_color, "event",
                     G_CALLBACK (gimp_color_select_z_events),
@@ -616,20 +616,15 @@ gimp_color_select_xy_size_allocate (GtkWidget       *widget,
 }
 
 static gboolean
-gimp_color_select_xy_expose (GtkWidget       *widget,
-                             GdkEventExpose  *event,
-                             GimpColorSelect *select)
+gimp_color_select_xy_draw (GtkWidget       *widget,
+                           cairo_t         *cr,
+                           GimpColorSelect *select)
 {
   GtkAllocation  allocation;
-  cairo_t       *cr;
   gint           x, y;
 
   gtk_widget_get_allocation (select->xy_color, &allocation);
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   x = ((allocation.width - 1) * select->pos[0]) / 255;
   y = (allocation.height - 1) - ((allocation.height - 1) * select->pos[1]) / 255;
 
@@ -647,8 +642,6 @@ gimp_color_select_xy_expose (GtkWidget       *widget,
   cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
   cairo_stroke (cr);
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 
@@ -738,20 +731,15 @@ gimp_color_select_z_size_allocate (GtkWidget       *widget,
 }
 
 static gboolean
-gimp_color_select_z_expose (GtkWidget       *widget,
-                            GdkEventExpose  *event,
-                            GimpColorSelect *select)
+gimp_color_select_z_draw (GtkWidget       *widget,
+                          cairo_t         *cr,
+                          GimpColorSelect *select)
 {
   GtkAllocation  allocation;
-  cairo_t       *cr;
   gint           y;
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   y = (allocation.height - 1) - ((allocation.height - 1) * select->pos[2]) / 255;
 
   cairo_move_to (cr, 0,                y + 0.5);
@@ -765,8 +753,6 @@ gimp_color_select_z_expose (GtkWidget       *widget,
   cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
   cairo_stroke (cr);
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 


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