[gimp/gtk3-port: 102/240] libgimpwidgets: port to GtkStyleContext and gtk_render_foo()



commit 67cf13d9e19e57719be6bccfffc16c87b583224e
Author: Michael Natterer <mitch gimp org>
Date:   Thu Dec 9 23:10:01 2010 +0100

    libgimpwidgets: port to GtkStyleContext and gtk_render_foo()

 libgimpwidgets/gimpcellrenderercolor.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/libgimpwidgets/gimpcellrenderercolor.c b/libgimpwidgets/gimpcellrenderercolor.c
index 16322ca..4b27b88 100644
--- a/libgimpwidgets/gimpcellrenderercolor.c
+++ b/libgimpwidgets/gimpcellrenderercolor.c
@@ -238,7 +238,7 @@ gimp_cell_renderer_color_render (GtkCellRenderer      *cell,
                                  const GdkRectangle   *cell_area,
                                  GtkCellRendererState  flags)
 {
-  GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
+  GimpCellRendererColor *renderer_color = GIMP_CELL_RENDERER_COLOR (cell);
   GdkRectangle           rect;
   gint                   xpad;
   gint                   ypad;
@@ -258,17 +258,18 @@ gimp_cell_renderer_color_render (GtkCellRenderer      *cell,
 
   if (rect.width > 2 && rect.height > 2)
     {
-      GtkStyle     *style = gtk_widget_get_style (widget);
-      GtkStateType  state;
+      GtkStyleContext *context = gtk_widget_get_style_context (widget);
+      GtkStateFlags    state   = 0;
+      GdkRGBA          color;
 
       cairo_rectangle (cr,
                        rect.x + 1, rect.y + 1,
                        rect.width - 2, rect.height - 2);
 
-      gimp_cairo_set_source_rgb (cr, &color->color);
+      gimp_cairo_set_source_rgb (cr, &renderer_color->color);
       cairo_fill (cr);
 
-      if (! color->opaque && color->color.a < 1.0)
+      if (! renderer_color->opaque && renderer_color->color.a < 1.0)
         {
           cairo_pattern_t *pattern;
 
@@ -285,7 +286,7 @@ gimp_cell_renderer_color_render (GtkCellRenderer      *cell,
 
           cairo_fill_preserve (cr);
 
-          gimp_cairo_set_source_rgba (cr, &color->color);
+          gimp_cairo_set_source_rgba (cr, &renderer_color->color);
           cairo_fill (cr);
         }
 
@@ -297,17 +298,18 @@ gimp_cell_renderer_color_render (GtkCellRenderer      *cell,
       if (! gtk_cell_renderer_get_sensitive (cell) ||
           ! gtk_widget_is_sensitive (widget))
         {
-          state = GTK_STATE_INSENSITIVE;
+          state |= GTK_STATE_FLAG_INSENSITIVE;
         }
-      else
+
+      if (flags & GTK_CELL_RENDERER_SELECTED)
         {
-          state = (flags & GTK_CELL_RENDERER_SELECTED ?
-                   GTK_STATE_SELECTED : GTK_STATE_NORMAL);
+          state |= GTK_STATE_FLAG_SELECTED;
         }
 
       cairo_set_line_width (cr, 1);
-      gdk_cairo_set_source_color (cr, &style->fg[state]);
-      cairo_stroke_preserve (cr);
+      gtk_style_context_get_color (context, state, &color);
+      gdk_cairo_set_source_rgba (cr, &color);
+      cairo_stroke (cr);
     }
 }
 


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