[gimp/gtk3-port: 151/155] app: port Wilber drawing to GtkStyleContext



commit 5d6c5f77c0d0e92ce3529cbee3cc021399b72c46
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 |   55 ++++++++++++++++++++++------------------------
 1 files changed, 26 insertions(+), 29 deletions(-)
---
diff --git a/app/widgets/gimpcairo.c b/app/widgets/gimpcairo.c
index 17a8e9f..5dc448d 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);
 
@@ -165,11 +164,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);
 }
 
@@ -177,21 +176,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);
 
@@ -216,10 +214,9 @@ 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;
+
   cairo_fill (cr);
 }



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