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



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

    libgimpwidgets: port to GtkWidget::draw()

 libgimpwidgets/gimpcolorselect.c |   46 +++++++++++--------------------------
 1 files changed, 14 insertions(+), 32 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c
index e45b76c..05de903 100644
--- a/libgimpwidgets/gimpcolorselect.c
+++ b/libgimpwidgets/gimpcolorselect.c
@@ -218,8 +218,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,
@@ -227,8 +227,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,
@@ -380,8 +380,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),
@@ -411,8 +411,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),
@@ -890,12 +890,11 @@ 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;
   GdkPixbuf     *pixbuf;
   gint           x, y;
 
@@ -964,12 +963,6 @@ gimp_color_select_xy_expose (GtkWidget       *widget,
 
   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);
-
-  cairo_translate (cr, allocation.x, allocation.y);
-
   gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
   g_object_unref (pixbuf);
   cairo_paint (cr);
@@ -991,8 +984,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;
 }
 
@@ -1096,12 +1087,11 @@ 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;
   GdkPixbuf     *pixbuf;
   gint           y;
 
@@ -1126,10 +1116,6 @@ gimp_color_select_z_expose (GtkWidget       *widget,
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   if (! select->transform)
     gimp_color_select_create_transform (select);
 
@@ -1174,8 +1160,6 @@ gimp_color_select_z_expose (GtkWidget       *widget,
                                          NULL, NULL);
     }
 
-  cairo_translate (cr, allocation.x, allocation.y);
-
   gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
   g_object_unref (pixbuf);
   cairo_paint (cr);
@@ -1193,8 +1177,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]