[gimp/gtk3-port: 132/236] app: port Wilber drawing to GtkStyleContext



commit aedb96df2d9c091e29b719da4040541e1f026362
Author: Michael Natterer <mitch gimp org>
Date:   Fri Dec 17 11:14:19 2010 +0100

    app: port Wilber drawing to GtkStyleContext

 app/widgets/gimpcairo.c |   57 +++++++++++++++++++++++------------------------
 1 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpcairo.c b/app/widgets/gimpcairo.c
index 7e4e67c..34a2e81 100644
--- a/app/widgets/gimpcairo.c
+++ b/app/widgets/gimpcairo.c
@@ -140,18 +140,17 @@ void
 gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
                                 cairo_t   *cr)
 {
-  GtkStyle     *style;
-  GtkStateType  state;
-  GtkAllocation allocation;
-  gdouble       wilber_width;
-  gdouble       wilber_height;
-  gdouble       factor;
+  GtkStyleContext *context;
+  GtkAllocation    allocation;
+  GdkRGBA          color;
+  gdouble          wilber_width;
+  gdouble          wilber_height;
+  gdouble          factor;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (cr != NULL);
 
-  style = gtk_widget_get_style (widget);
-  state = gtk_widget_get_state (widget);
+  context = gtk_widget_get_style_context (widget);
 
   gtk_widget_get_allocation (widget, &allocation);
 
@@ -168,11 +167,11 @@ gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
                      (allocation.width  / factor - wilber_width)  / 2.0,
                      (allocation.height / factor - wilber_height) / 2.0);
 
-  cairo_set_source_rgba (cr,
-                         style->fg[state].red   / 65535.0,
-                         style->fg[state].green / 65535.0,
-                         style->fg[state].blue  / 65535.0,
-                         0.10);
+  gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
+                               &color);
+  color.alpha = 0.1;
+  gdk_cairo_set_source_rgba (cr, &color);
+
   cairo_fill (cr);
 }
 
@@ -180,21 +179,20 @@ void
 gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                              cairo_t   *cr)
 {
-  GtkStyle     *style;
-  GtkStateType  state;
-  GtkAllocation allocation;
-  gdouble       wilber_width;
-  gdouble       wilber_height;
-  gdouble       width;
-  gdouble       height;
-  gdouble       side;
-  gdouble       factor;
+  GtkStyleContext *context;
+  GtkAllocation    allocation;
+  GdkRGBA          color;
+  gdouble          wilber_width;
+  gdouble          wilber_height;
+  gdouble          width;
+  gdouble          height;
+  gdouble          side;
+  gdouble          factor;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
   g_return_if_fail (cr != NULL);
 
-  style  = gtk_widget_get_style (widget);
-  state  = gtk_widget_get_state (widget);
+  context = gtk_widget_get_style_context (widget);
 
   gtk_widget_get_allocation (widget, &allocation);
 
@@ -222,10 +220,11 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                      - wilber_width * 0.6,
                      allocation.height / factor - wilber_height * 1.1);
 
-  cairo_set_source_rgba (cr,
-                         style->fg[state].red   / 65535.0,
-                         style->fg[state].green / 65535.0,
-                         style->fg[state].blue  / 65535.0,
-                         0.15);
+  gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget),
+                               &color);
+  color.alpha = 0.15;
+
+  gdk_cairo_set_source_rgba (cr, &color);
+
   cairo_fill (cr);
 }



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