[gimp/gtk3-port: 225/228] app: port wilber drawing to GtkStyleContext



commit 8d3f9f328f62da567e9d6c137a604727455a42b2
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 |   57 +++++++++++++++++++--------------------
 1 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpcairo-wilber.c b/app/widgets/gimpcairo-wilber.c
index 883ccc6..7c7db41 100644
--- a/app/widgets/gimpcairo-wilber.c
+++ b/app/widgets/gimpcairo-wilber.c
@@ -38,18 +38,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);
 
@@ -66,11 +65,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);
 }
 
@@ -78,21 +77,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);
 
@@ -120,11 +118,12 @@ 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]