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



commit 6142bd4148e34d04dc3b4a946ebf7e9b0940cfe8
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 2e1f486..10108fa 100644
--- a/libgimpwidgets/gimpcolorselect.c
+++ b/libgimpwidgets/gimpcolorselect.c
@@ -176,8 +176,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,
@@ -185,8 +185,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          *widget,
                                                  GdkEvent           *event,
@@ -281,8 +281,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),
@@ -311,8 +311,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),
@@ -638,20 +638,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];
   y = (allocation.height - 1) - (allocation.height - 1) * select->pos[1];
 
@@ -669,8 +664,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;
 }
 
@@ -760,20 +753,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];
 
   cairo_move_to (cr, 0,                y + 0.5);
@@ -787,8 +775,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]