[gimp/gtk3-port: 16/223] app: port to GtkWidget::draw()



commit 15582afd486a2219c17d88f87cca22d1cd63cd56
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 12:58:53 2010 +0200

    app: port to GtkWidget::draw()

 app/widgets/gimpcolorbar.c |   36 ++++++++++++++----------------------
 1 files changed, 14 insertions(+), 22 deletions(-)
---
diff --git a/app/widgets/gimpcolorbar.c b/app/widgets/gimpcolorbar.c
index 0e9b2ac..a9a9728 100644
--- a/app/widgets/gimpcolorbar.c
+++ b/app/widgets/gimpcolorbar.c
@@ -43,17 +43,17 @@ enum
 
 /*  local function prototypes  */
 
-static void      gimp_color_bar_set_property (GObject        *object,
-                                              guint           property_id,
-                                              const GValue   *value,
-                                              GParamSpec     *pspec);
-static void      gimp_color_bar_get_property (GObject        *object,
-                                              guint           property_id,
-                                              GValue         *value,
-                                              GParamSpec     *pspec);
+static void      gimp_color_bar_set_property (GObject      *object,
+                                              guint         property_id,
+                                              const GValue *value,
+                                              GParamSpec   *pspec);
+static void      gimp_color_bar_get_property (GObject      *object,
+                                              guint         property_id,
+                                              GValue       *value,
+                                              GParamSpec   *pspec);
 
-static gboolean  gimp_color_bar_expose       (GtkWidget      *widget,
-                                              GdkEventExpose *event);
+static gboolean  gimp_color_bar_draw         (GtkWidget    *widget,
+                                              cairo_t      *cr);
 
 
 G_DEFINE_TYPE (GimpColorBar, gimp_color_bar, GTK_TYPE_EVENT_BOX)
@@ -71,7 +71,7 @@ gimp_color_bar_class_init (GimpColorBarClass *klass)
   object_class->set_property = gimp_color_bar_set_property;
   object_class->get_property = gimp_color_bar_get_property;
 
-  widget_class->expose_event = gimp_color_bar_expose;
+  widget_class->draw         = gimp_color_bar_draw;
 
   g_object_class_install_property (object_class, PROP_ORIENTATION,
                                    g_param_spec_enum ("orientation",
@@ -152,11 +152,10 @@ gimp_color_bar_get_property (GObject    *object,
 }
 
 static gboolean
-gimp_color_bar_expose (GtkWidget      *widget,
-                       GdkEventExpose *event)
+gimp_color_bar_draw (GtkWidget *widget,
+                     cairo_t   *cr)
 {
   GimpColorBar    *bar = GIMP_COLOR_BAR (widget);
-  cairo_t         *cr;
   GtkAllocation    allocation;
   cairo_surface_t *surface;
   cairo_pattern_t *pattern;
@@ -166,11 +165,6 @@ gimp_color_bar_expose (GtkWidget      *widget,
   gint             width, height;
   gint             i;
 
-  cr = gdk_cairo_create (event->window);
-
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   gtk_widget_get_allocation (widget, &allocation);
 
   x = y = gtk_container_get_border_width (GTK_CONTAINER (bar));
@@ -181,7 +175,7 @@ gimp_color_bar_expose (GtkWidget      *widget,
   if (width < 1 || height < 1)
     return TRUE;
 
-  cairo_translate (cr, allocation.x + x, allocation.y + y);
+  cairo_translate (cr, x, y);
   cairo_rectangle (cr, 0, 0, width, height);
   cairo_clip (cr);
 
@@ -216,8 +210,6 @@ gimp_color_bar_expose (GtkWidget      *widget,
 
   cairo_paint (cr);
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 



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