[pygobject] pygtkcompat: Fix color conversion



commit 5948b62ba3e08ea943e6965ee38c94c363186226
Author: Martin Pitt <martinpitt gnome org>
Date:   Sun May 6 17:59:57 2012 -0700

    pygtkcompat: Fix color conversion
    
    gtk_style_context_get_background_color() returns a GdkRGBA value, which has
    float values between 0 and 1. However, we construct a GdkColor object from
    that, so we need to scale to 0..65535 and round to int.

 gi/pygtkcompat.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/gi/pygtkcompat.py b/gi/pygtkcompat.py
index 3e07c50..21f017c 100644
--- a/gi/pygtkcompat.py
+++ b/gi/pygtkcompat.py
@@ -385,9 +385,9 @@ def enable_gtk(version='2.0'):
 
         def __getitem__(self, state):
             color = self.context.get_background_color(state)
-            return Gdk.Color(red=color.red,
-                             green=color.green,
-                             blue=color.blue)
+            return Gdk.Color(red=int(color.red * 65535),
+                             green=int(color.green * 65535),
+                             blue=int(color.blue *65535))
 
     class Styles(object):
         def __init__(self, widget):



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