[gimp/gtk3-port: 5/235] libgimpwidgets: port virtual functions to GTK+ 3.0



commit 90c9fcf2c4d5d8c3aeedb2127b02c70dbf3160a7
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 |  142 ++++++++++++++-----------------
 1 files changed, 64 insertions(+), 78 deletions(-)
---
diff --git a/libgimpwidgets/gimpcellrenderertoggle.c b/libgimpwidgets/gimpcellrenderertoggle.c
index c18e922..2569c4e 100644
--- a/libgimpwidgets/gimpcellrenderertoggle.c
+++ b/libgimpwidgets/gimpcellrenderertoggle.c
@@ -56,35 +56,34 @@ enum
 };
 
 
-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);
@@ -220,13 +219,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);
   GtkStyle               *style  = gtk_widget_get_style (widget);
@@ -289,17 +288,15 @@ 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);
   GtkStyle               *style  = gtk_widget_get_style (widget);
   GdkRectangle            toggle_rect;
-  GdkRectangle            draw_rect;
   GtkStateType            state;
   gboolean                active;
   gint                    xpad;
@@ -307,9 +304,9 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer      *cell,
 
   if (! 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;
     }
@@ -348,54 +345,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))
+      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)
         {
-          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);
-
-          g_object_get (toggle,
-                        "inconsistent", &inconsistent,
-                        NULL);
-
-          if (inconsistent)
-            {
-              gdk_cairo_set_source_color (cr, &style->fg[state]);
-              cairo_set_line_width (cr, 2.0);
-              cairo_move_to (cr,
-                             toggle_rect.x + toggle_rect.width,
-                             toggle_rect.y);
-              cairo_line_to (cr,
-                             toggle_rect.x,
-                             toggle_rect.y + toggle_rect.height);
-              cairo_stroke (cr);
-            }
-
-          cairo_destroy (cr);
+          gdk_cairo_set_source_color (cr, &style->fg[state]);
+          cairo_set_line_width (cr, 2.0);
+          cairo_move_to (cr,
+                         toggle_rect.x + toggle_rect.width,
+                         toggle_rect.y);
+          cairo_line_to (cr,
+                         toggle_rect.x,
+                         toggle_rect.y + toggle_rect.height);
+          cairo_stroke (cr);
         }
     }
 }
@@ -405,8 +391,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]