[gimp/gtk3-port: 29/237] app: port to GtkWidget::draw()



commit 42d03d7a6bad7f5118248d7a15194e4d63a28b4d
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 14:15:07 2010 +0200

    app: port to GtkWidget::draw()

 app/widgets/gimpfgbgeditor.c |   27 ++++++------------
 app/widgets/gimpfgbgview.c   |   60 ++++++++++++++++--------------------------
 2 files changed, 32 insertions(+), 55 deletions(-)
---
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index bf49aed..94c1053 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -69,8 +69,8 @@ static void     gimp_fg_bg_editor_get_property    (GObject        *object,
                                                    GValue         *value,
                                                    GParamSpec     *pspec);
 
-static gboolean gimp_fg_bg_editor_expose          (GtkWidget      *widget,
-                                                   GdkEventExpose *eevent);
+static gboolean gimp_fg_bg_editor_draw            (GtkWidget      *widget,
+                                                   cairo_t        *cr);
 static gboolean gimp_fg_bg_editor_button_press    (GtkWidget      *widget,
                                                    GdkEventButton *bevent);
 static gboolean gimp_fg_bg_editor_button_release  (GtkWidget      *widget,
@@ -118,7 +118,7 @@ gimp_fg_bg_editor_class_init (GimpFgBgEditorClass *klass)
   object_class->set_property         = gimp_fg_bg_editor_set_property;
   object_class->get_property         = gimp_fg_bg_editor_get_property;
 
-  widget_class->expose_event         = gimp_fg_bg_editor_expose;
+  widget_class->draw                 = gimp_fg_bg_editor_draw;
   widget_class->button_press_event   = gimp_fg_bg_editor_button_press;
   widget_class->button_release_event = gimp_fg_bg_editor_button_release;
   widget_class->drag_motion          = gimp_fg_bg_editor_drag_motion;
@@ -221,13 +221,11 @@ gimp_fg_bg_editor_get_property (GObject    *object,
 }
 
 static gboolean
-gimp_fg_bg_editor_expose (GtkWidget      *widget,
-                          GdkEventExpose *eevent)
+gimp_fg_bg_editor_draw (GtkWidget *widget,
+                        cairo_t   *cr)
 {
   GimpFgBgEditor *editor = GIMP_FG_BG_EDITOR (widget);
   GtkStyle       *style  = gtk_widget_get_style (widget);
-  GdkWindow      *window = gtk_widget_get_window (widget);
-  cairo_t        *cr;
   GtkAllocation   allocation;
   gint            width, height;
   gint            default_w, default_h;
@@ -238,11 +236,6 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
   if (! gtk_widget_is_drawable (widget))
     return FALSE;
 
-  cr = gdk_cairo_create (eevent->window);
-
-  gdk_cairo_region (cr, eevent->region);
-  cairo_clip (cr);
-
   gtk_widget_get_allocation (widget, &allocation);
 
   width  = allocation.width;
@@ -314,10 +307,10 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, window, GTK_STATE_NORMAL,
+  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
                     editor->active_color == GIMP_ACTIVE_COLOR_FOREGROUND ?
                     GTK_SHADOW_OUT : GTK_SHADOW_IN,
-                    NULL, widget, NULL,
+                    widget, NULL,
                     (width - rect_w),
                     (height - rect_h),
                     rect_w, rect_h);
@@ -336,15 +329,13 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, window, GTK_STATE_NORMAL,
+  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
                     editor->active_color == GIMP_ACTIVE_COLOR_BACKGROUND ?
                     GTK_SHADOW_OUT : GTK_SHADOW_IN,
-                    NULL, widget, NULL,
+                    widget, NULL,
                     0, 0,
                     rect_w, rect_h);
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 
diff --git a/app/widgets/gimpfgbgview.c b/app/widgets/gimpfgbgview.c
index e8f688d..512621a 100644
--- a/app/widgets/gimpfgbgview.c
+++ b/app/widgets/gimpfgbgview.c
@@ -43,18 +43,18 @@ enum
 };
 
 
-static void     gimp_fg_bg_view_dispose      (GObject        *object);
-static void     gimp_fg_bg_view_set_property (GObject        *object,
-                                              guint           property_id,
-                                              const GValue   *value,
-                                              GParamSpec     *pspec);
-static void     gimp_fg_bg_view_get_property (GObject        *object,
-                                              guint           property_id,
-                                              GValue         *value,
-                                              GParamSpec     *pspec);
+static void     gimp_fg_bg_view_dispose      (GObject      *object);
+static void     gimp_fg_bg_view_set_property (GObject      *object,
+                                              guint         property_id,
+                                              const GValue *value,
+                                              GParamSpec   *pspec);
+static void     gimp_fg_bg_view_get_property (GObject      *object,
+                                              guint         property_id,
+                                              GValue       *value,
+                                              GParamSpec   *pspec);
 
-static gboolean gimp_fg_bg_view_expose       (GtkWidget      *widget,
-                                              GdkEventExpose *eevent);
+static gboolean gimp_fg_bg_view_draw         (GtkWidget    *widget,
+                                              cairo_t      *cr);
 
 
 G_DEFINE_TYPE (GimpFgBgView, gimp_fg_bg_view, GTK_TYPE_WIDGET)
@@ -72,7 +72,7 @@ gimp_fg_bg_view_class_init (GimpFgBgViewClass *klass)
   object_class->set_property = gimp_fg_bg_view_set_property;
   object_class->get_property = gimp_fg_bg_view_get_property;
 
-  widget_class->expose_event = gimp_fg_bg_view_expose;
+  widget_class->draw         = gimp_fg_bg_view_draw;
 
   g_object_class_install_property (object_class, PROP_CONTEXT,
                                    g_param_spec_object ("context",
@@ -141,29 +141,17 @@ gimp_fg_bg_view_get_property (GObject    *object,
 }
 
 static gboolean
-gimp_fg_bg_view_expose (GtkWidget      *widget,
-                        GdkEventExpose *eevent)
+gimp_fg_bg_view_draw (GtkWidget *widget,
+                      cairo_t   *cr)
 {
-  GimpFgBgView *view   = GIMP_FG_BG_VIEW (widget);
-  GtkStyle     *style  = gtk_widget_get_style (widget);
-  GdkWindow    *window = gtk_widget_get_window (widget);
-  cairo_t      *cr;
+  GimpFgBgView *view  = GIMP_FG_BG_VIEW (widget);
+  GtkStyle     *style = gtk_widget_get_style (widget);
   GtkAllocation allocation;
   gint          rect_w, rect_h;
   GimpRGB       color;
 
-  if (! gtk_widget_is_drawable (widget))
-    return FALSE;
-
-  cr = gdk_cairo_create (eevent->window);
-
-  gdk_cairo_region (cr, eevent->region);
-  cairo_clip (cr);
-
   gtk_widget_get_allocation (widget, &allocation);
 
-  cairo_translate (cr, allocation.x, allocation.y);
-
   rect_w = allocation.width  * 3 / 4;
   rect_h = allocation.height * 3 / 4;
 
@@ -182,11 +170,11 @@ gimp_fg_bg_view_expose (GtkWidget      *widget,
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, window, GTK_STATE_NORMAL,
+  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
                     GTK_SHADOW_IN,
-                    NULL, widget, NULL,
-                    allocation.x + allocation.width  - rect_w,
-                    allocation.y + allocation.height - rect_h,
+                    widget, NULL,
+                    allocation.width  - rect_w,
+                    allocation.height - rect_h,
                     rect_w, rect_h);
 
   /*  draw the foreground area  */
@@ -200,12 +188,10 @@ gimp_fg_bg_view_expose (GtkWidget      *widget,
       cairo_fill (cr);
     }
 
-  gtk_paint_shadow (style, window, GTK_STATE_NORMAL,
+  gtk_paint_shadow (style, cr, GTK_STATE_NORMAL,
                     GTK_SHADOW_OUT,
-                    NULL, widget, NULL,
-                    allocation.x, allocation.y, rect_w, rect_h);
-
-  cairo_destroy (cr);
+                    widget, NULL,
+                    0, 0, rect_w, rect_h);
 
   return TRUE;
 }



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