[gimp/gtk3-port: 8/223] libgimpwidgets: port to GtkWidget::draw()



commit ce8d3cbe3e25834dcdc2c7ee2402c70222bc9442
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 4bebdbd..7ba0086 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -69,8 +69,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);
@@ -96,7 +96,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;
 
   /**
    * GimpColorScale:channel:
@@ -317,15 +317,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;
@@ -335,18 +333,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);
@@ -382,13 +372,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,
@@ -415,10 +403,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);
 
@@ -493,8 +481,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]