[giggle] giggle-graph-renderer: Port set_source_color to GtkStyleContext



commit 42b0ee39367f6b68796b0089146f8addd4195247
Author: João Pedro Forjaz de Lacerda <jpl codethink co uk>
Date:   Wed Apr 20 11:53:42 2011 +0100

    giggle-graph-renderer: Port set_source_color to GtkStyleContext
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=648284

 src/giggle-graph-renderer.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/giggle-graph-renderer.c b/src/giggle-graph-renderer.c
index 505e806..62033a7 100644
--- a/src/giggle-graph-renderer.c
+++ b/src/giggle-graph-renderer.c
@@ -251,21 +251,23 @@ set_source_color (cairo_t         *cr,
 		  GtkWidget       *widget,
 		  unsigned	   color_index)
 {
+	GtkStyleContext *context;
+	GdkRGBA rgba;
 	GdkColor  color;
-	GtkStyle *style;
-
 
 	if (gtk_widget_is_sensitive (widget)) {
 		gdk_cairo_set_source_color (cr, &colors[color_index]);
 	} else {
-		style = gtk_widget_get_style (widget);
+		context = gtk_widget_get_style_context (widget);
+		gtk_style_context_get_color (context, GTK_STATE_FLAG_INSENSITIVE, &rgba);
 		color = colors[color_index];
 
-		color.red   = (color.red   + 7 * style->text[GTK_STATE_INSENSITIVE].red)   / 8;
-		color.green = (color.green + 7 * style->text[GTK_STATE_INSENSITIVE].green) / 8;
-		color.blue  = (color.blue  + 7 * style->text[GTK_STATE_INSENSITIVE].blue)  / 8;
+		/* convert color values to rgba values, lying in the [0,1] range */
+		rgba.red   = (color.red / 65535.0   + 7 * rgba.red)   / 8;
+		rgba.green = (color.green / 65535.0 + 7 * rgba.green) / 8;
+		rgba.blue  = (color.blue / 65535.0  + 7 * rgba.blue)  / 8;
 
-		gdk_cairo_set_source_color (cr, &color);
+		gdk_cairo_set_source_rgba (cr, &rgba);
 	}
 }
 



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