[gimp/gtk3-port: 6/233] libgimpwidgets: port virtual functions to GTK+ 3.0



commit 63b01ac78cc40ce833c4bd5a1810115912054044
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 10:26:34 2010 +0200

    libgimpwidgets: port virtual functions to GTK+ 3.0

 libgimpwidgets/gimpcellrenderertoggle.c |  140 ++++++++++++++-----------------
 1 files changed, 63 insertions(+), 77 deletions(-)
---
diff --git a/libgimpwidgets/gimpcellrenderertoggle.c b/libgimpwidgets/gimpcellrenderertoggle.c
index 9862752..95b2c0d 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.c
+++ b/libgimpwidgets/gimpcellrenderertoggle.c
@@ -72,35 +72,34 @@ struct _GimpCellRendererTogglePrivate
                                      GimpCellRendererTogglePrivate)
 
 
-static void gimp_cell_renderer_toggle_finalize     (GObject         *object);
-static void gimp_cell_renderer_toggle_get_property (GObject         *object,
-                                                    guint            param_id,
-                                                    GValue          *value,
-                                                    GParamSpec      *pspec);
-static void gimp_cell_renderer_toggle_set_property (GObject         *object,
-                                                    guint            param_id,
-                                                    const GValue    *value,
-                                                    GParamSpec      *pspec);
-static void gimp_cell_renderer_toggle_get_size     (GtkCellRenderer *cell,
-                                                    GtkWidget       *widget,
-                                                    GdkRectangle    *rectangle,
-                                                    gint            *x_offset,
-                                                    gint            *y_offset,
-                                                    gint            *width,
-                                                    gint            *height);
-static void gimp_cell_renderer_toggle_render       (GtkCellRenderer *cell,
-                                                    GdkWindow       *window,
-                                                    GtkWidget       *widget,
-                                                    GdkRectangle    *background_area,
-                                                    GdkRectangle    *cell_area,
-                                                    GdkRectangle    *expose_area,
-                                                    GtkCellRendererState flags);
-static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
-                                                    GdkEvent        *event,
-                                                    GtkWidget       *widget,
-                                                    const gchar     *path,
-                                                    GdkRectangle    *background_area,
-                                                    GdkRectangle    *cell_area,
+static void gimp_cell_renderer_toggle_finalize     (GObject              *object);
+static void gimp_cell_renderer_toggle_get_property (GObject              *object,
+                                                    guint                 param_id,
+                                                    GValue               *value,
+                                                    GParamSpec           *pspec);
+static void gimp_cell_renderer_toggle_set_property (GObject              *object,
+                                                    guint                 param_id,
+                                                    const GValue         *value,
+                                                    GParamSpec           *pspec);
+static void gimp_cell_renderer_toggle_get_size     (GtkCellRenderer      *cell,
+                                                    GtkWidget            *widget,
+                                                    const GdkRectangle   *rectangle,
+                                                    gint                 *x_offset,
+                                                    gint                 *y_offset,
+                                                    gint                 *width,
+                                                    gint                 *height);
+static void gimp_cell_renderer_toggle_render       (GtkCellRenderer      *cell,
+                                                    cairo_t              *cr,
+                                                    GtkWidget            *widget,
+                                                    const GdkRectangle   *background_area,
+                                                    const GdkRectangle   *cell_area,
+                                                    GtkCellRendererState  flags);
+static gboolean gimp_cell_renderer_toggle_activate (GtkCellRenderer      *cell,
+                                                    GdkEvent             *event,
+                                                    GtkWidget            *widget,
+                                                    const gchar          *path,
+                                                    const GdkRectangle   *background_area,
+                                                    const GdkRectangle   *cell_area,
                                                     GtkCellRendererState  flags);
 static void gimp_cell_renderer_toggle_create_pixbuf (GimpCellRendererToggle *toggle,
                                                      GtkWidget              *widget);
@@ -267,13 +266,13 @@ gimp_cell_renderer_toggle_set_property (GObject      *object,
 }
 
 static void
-gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
-                                    GtkWidget       *widget,
-                                    GdkRectangle    *cell_area,
-                                    gint            *x_offset,
-                                    gint            *y_offset,
-                                    gint            *width,
-                                    gint            *height)
+gimp_cell_renderer_toggle_get_size (GtkCellRenderer    *cell,
+                                    GtkWidget          *widget,
+                                    const GdkRectangle *cell_area,
+                                    gint               *x_offset,
+                                    gint               *y_offset,
+                                    gint               *width,
+                                    gint               *height)
 {
   GimpCellRendererToggle        *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
   GimpCellRendererTogglePrivate *priv   = GET_PRIVATE (cell);
@@ -337,18 +336,16 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
 
 static void
 gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
-                                  GdkWindow            *window,
+                                  cairo_t              *cr,
                                   GtkWidget            *widget,
-                                  GdkRectangle         *background_area,
-                                  GdkRectangle         *cell_area,
-                                  GdkRectangle         *expose_area,
+                                  const GdkRectangle   *background_area,
+                                  const GdkRectangle   *cell_area,
                                   GtkCellRendererState  flags)
 {
   GimpCellRendererToggle        *toggle = GIMP_CELL_RENDERER_TOGGLE (cell);
   GimpCellRendererTogglePrivate *priv   = GET_PRIVATE (cell);
   GtkStyle                      *style  = gtk_widget_get_style (widget);
   GdkRectangle                   toggle_rect;
-  GdkRectangle                   draw_rect;
   GtkStateType                   state;
   gboolean                       active;
   gint                           xpad;
@@ -356,9 +353,9 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
 
   if (! priv->icon_name && ! toggle->stock_id)
     {
-      GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, window, widget,
+      GTK_CELL_RENDERER_CLASS (parent_class)->render (cell, cr, widget,
                                                       background_area,
-                                                      cell_area, expose_area,
+                                                      cell_area,
                                                       flags);
       return;
     }
@@ -424,54 +421,43 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
         state = GTK_STATE_INSENSITIVE;
     }
 
-  if (gdk_rectangle_intersect (expose_area, cell_area, &draw_rect) &&
-      (flags & GTK_CELL_RENDERER_PRELIT))
+  if (flags & GTK_CELL_RENDERER_PRELIT)
     gtk_paint_shadow (style,
-                      window,
+                      cr,
                       state,
                       active ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
-                      &draw_rect,
                       widget, NULL,
                       toggle_rect.x,     toggle_rect.y,
                       toggle_rect.width, toggle_rect.height);
 
   if (active)
     {
+      gboolean inconsistent;
+
       toggle_rect.x      += style->xthickness;
       toggle_rect.y      += style->ythickness;
       toggle_rect.width  -= style->xthickness * 2;
       toggle_rect.height -= style->ythickness * 2;
 
-      if (gdk_rectangle_intersect (&draw_rect, &toggle_rect, &draw_rect))
-        {
-          cairo_t  *cr = gdk_cairo_create (window);
-          gboolean  inconsistent;
-
-          gdk_cairo_rectangle (cr, &draw_rect);
-          cairo_clip (cr);
-
-          gdk_cairo_set_source_pixbuf (cr, toggle->pixbuf,
-                                       toggle_rect.x, toggle_rect.y);
-          cairo_paint (cr);
+      gdk_cairo_set_source_pixbuf (cr, toggle->pixbuf,
+                                   toggle_rect.x, toggle_rect.y);
+      cairo_paint (cr);
 
-          g_object_get (toggle,
-                        "inconsistent", &inconsistent,
-                        NULL);
-
-          if (inconsistent)
-            {
-              gdk_cairo_set_source_color (cr, &style->fg[state]);
-              cairo_set_line_width (cr, 1.5);
-              cairo_move_to (cr,
-                             toggle_rect.x + toggle_rect.width - 1,
-                             toggle_rect.y + 1);
-              cairo_line_to (cr,
-                             toggle_rect.x + 1,
-                             toggle_rect.y + toggle_rect.height - 1);
-              cairo_stroke (cr);
-            }
+      g_object_get (toggle,
+                    "inconsistent", &inconsistent,
+                    NULL);
 
-          cairo_destroy (cr);
+      if (inconsistent)
+        {
+          gdk_cairo_set_source_color (cr, &style->fg[state]);
+          cairo_set_line_width (cr, 1.5);
+          cairo_move_to (cr,
+                         toggle_rect.x + toggle_rect.width - 1,
+                         toggle_rect.y + 1);
+          cairo_line_to (cr,
+                         toggle_rect.x + 1,
+                         toggle_rect.y + toggle_rect.height - 1);
+          cairo_stroke (cr);
         }
     }
 }
@@ -481,8 +467,8 @@ gimp_cell_renderer_toggle_activate (GtkCellRenderer      *cell,
                                     GdkEvent             *event,
                                     GtkWidget            *widget,
                                     const gchar          *path,
-                                    GdkRectangle         *background_area,
-                                    GdkRectangle         *cell_area,
+                                    const GdkRectangle   *background_area,
+                                    const GdkRectangle   *cell_area,
                                     GtkCellRendererState  flags)
 {
   GtkCellRendererToggle *toggle = GTK_CELL_RENDERER_TOGGLE (cell);


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