[gimp/gtk3-port: 214/240] app: port wilber drawing to GtkStyleContext



commit dce0f73e007d37aa4b06f34a20f17b21ebf80327
Author: Michael Natterer <mitch gimp org>
Date:   Fri May 4 17:18:51 2012 +0200

    app: port wilber drawing to GtkStyleContext

 app/widgets/gimpcairo-wilber.c |   59 +++++++++++++++++++--------------------
 1 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/app/widgets/gimpcairo-wilber.c b/app/widgets/gimpcairo-wilber.c
index 74d8b09..3e67685 100644
--- a/app/widgets/gimpcairo-wilber.c
+++ b/app/widgets/gimpcairo-wilber.c
@@ -72,18 +72,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);
 
@@ -101,11 +100,11 @@ gimp_cairo_draw_toolbox_wilber (GtkWidget *widget,
                               (allocation.height / factor - wilber_height) / 2.0,
                               factor, 30.0 * G_PI / 180.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);
 }
 
@@ -114,21 +113,20 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                              cairo_t   *cr,
                              gboolean   blink)
 {
-  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);
 
@@ -157,11 +155,12 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                               allocation.height / factor - wilber_height * 1.1,
                               factor, 50.0 * G_PI / 180.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.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);
 
   if (blink)
@@ -172,7 +171,7 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                        factor, 50.0 * G_PI / 180.0);
 
       cairo_set_source_rgba (cr,
-                             style->fg[state].red   / 65535.0,
+                             color.red,
                              0,
                              0,
                              1.0);


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