[gimp/gtk3-port: 22/231] app: port to GtkWidget::draw()



commit 0091e82b91c193002ed496d49e06004cedce602c
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 a1d68bf..b93ab72 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -71,8 +71,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,
@@ -120,7 +120,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;
@@ -223,13 +223,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;
@@ -240,11 +238,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 dcfa61d..9f2cb5e 100644
--- a/app/widgets/gimpfgbgview.c
+++ b/app/widgets/gimpfgbgview.c
@@ -44,18 +44,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)
@@ -73,7 +73,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",
@@ -142,29 +142,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;
 
@@ -183,11 +171,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  */
@@ -201,12 +189,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]