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



commit 81616d5e0b4f8d2828c1edbfcfa37d4dcc5f896b
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]