[gimp/gtk3-port: 9/237] libgimpwidgets: port to GtkWidget::draw()



commit 5f0f2e6a3bd1546baf62e640381d59b6c2ad1370
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 11:13:47 2010 +0200

    libgimpwidgets: port to GtkWidget::draw()

 libgimpwidgets/gimpcolorscale.c |   38 ++++++++++++--------------------------
 1 files changed, 12 insertions(+), 26 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 8c91d6b..7ee97e3 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -54,8 +54,8 @@ static gboolean gimp_color_scale_button_press   (GtkWidget       *widget,
                                                  GdkEventButton  *event);
 static gboolean gimp_color_scale_button_release (GtkWidget       *widget,
                                                  GdkEventButton  *event);
-static gboolean gimp_color_scale_expose         (GtkWidget       *widget,
-                                                 GdkEventExpose  *event);
+static gboolean gimp_color_scale_draw           (GtkWidget       *widget,
+                                                 cairo_t         *cr);
 
 static void     gimp_color_scale_render         (GimpColorScale  *scale);
 static void     gimp_color_scale_render_alpha   (GimpColorScale  *scale);
@@ -79,7 +79,7 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
   widget_class->state_changed        = gimp_color_scale_state_changed;
   widget_class->button_press_event   = gimp_color_scale_button_press;
   widget_class->button_release_event = gimp_color_scale_button_release;
-  widget_class->expose_event         = gimp_color_scale_expose;
+  widget_class->draw                 = gimp_color_scale_draw;
 }
 
 static void
@@ -246,15 +246,13 @@ gimp_color_scale_button_release (GtkWidget      *widget,
 }
 
 static gboolean
-gimp_color_scale_expose (GtkWidget      *widget,
-                         GdkEventExpose *event)
+gimp_color_scale_draw (GtkWidget *widget,
+                       cairo_t   *cr)
 {
   GimpColorScale  *scale     = GIMP_COLOR_SCALE (widget);
   GtkRange        *range     = GTK_RANGE (widget);
   GtkStyle        *style     = gtk_widget_get_style (widget);
-  GdkWindow       *window    = gtk_widget_get_window (widget);
   gboolean         sensitive = gtk_widget_is_sensitive (widget);
-  GtkAllocation    allocation;
   GdkRectangle     range_rect;
   GdkRectangle     area      = { 0, };
   cairo_surface_t *buffer;
@@ -264,18 +262,10 @@ gimp_color_scale_expose (GtkWidget      *widget,
   gint             slider_size;
   gint             x, y;
   gint             w, h;
-  cairo_t         *cr;
 
   if (! scale->buf || ! gtk_widget_is_drawable (widget))
     return FALSE;
 
-  gtk_widget_get_allocation (widget, &allocation);
-
-  cr = gdk_cairo_create (window);
-  gdk_cairo_region (cr, event->region);
-  cairo_translate (cr, allocation.x, allocation.y);
-  cairo_clip (cr);
-
   gtk_widget_style_get (widget,
                         "trough-border", &trough_border,
                         NULL);
@@ -311,13 +301,11 @@ gimp_color_scale_expose (GtkWidget      *widget,
       scale->needs_render = FALSE;
     }
 
-  gtk_paint_box (style, window,
+  gtk_paint_box (style, cr,
                  sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
                  GTK_SHADOW_IN,
-                 &event->area, widget, "trough",
-                 x + allocation.x,
-                 y + allocation.y,
-                 w, h);
+                 widget, "trough",
+                 x, y, w, h);
 
   buffer = cairo_image_surface_create_for_data (scale->buf,
                                                 CAIRO_FORMAT_RGB24,
@@ -344,10 +332,10 @@ gimp_color_scale_expose (GtkWidget      *widget,
   cairo_paint (cr);
 
   if (gtk_widget_has_focus (widget))
-    gtk_paint_focus (style, window, gtk_widget_get_state (widget),
-                     &event->area, widget, "trough",
-                     range_rect.x + allocation.x,
-                     range_rect.y + allocation.y,
+    gtk_paint_focus (style, cr, gtk_widget_get_state (widget),
+                     widget, "trough",
+                     range_rect.x,
+                     range_rect.y,
                      range_rect.width,
                      range_rect.height);
 
@@ -422,8 +410,6 @@ gimp_color_scale_expose (GtkWidget      *widget,
   cairo_close_path (cr);
   cairo_fill (cr);
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 



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