[gimp/gtk3-port: 217/234] app: port wilber drawing to GtkStyleContext



commit bd4fb57b1746de325a5805b36f2307beb1e8598d
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 4519640..7d0c0f7 100644
--- a/app/widgets/gimpcairo-wilber.c
+++ b/app/widgets/gimpcairo-wilber.c
@@ -43,18 +43,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);
 
@@ -71,11 +70,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);
 }
 
@@ -84,21 +83,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);
 
@@ -126,11 +124,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);
 
   if (blink)
@@ -140,7 +139,7 @@ gimp_cairo_draw_drop_wilber (GtkWidget *widget,
                        allocation.height / factor - wilber_height * 1.1);
 
       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]