[pitivi] ruler: Clarify what params setCairoColor handles



commit 58fc8b9c02cac97652e3effeacc41bfc07d0265d
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Thu Jan 2 15:08:06 2014 +0100

    ruler: Clarify what params setCairoColor handles
    
    There are colors and colors, it seems.
    Passing Gdk.Color objects is not handled yet.

 pitivi/timeline/ruler.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index da8b2bc..fcf2704 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -43,12 +43,14 @@ RULER_BACKGROUND_COLOR = (57, 63, 63)
 
 
 def setCairoColor(context, color):
-    if type(color) is tuple:
+    if type(color) is Gdk.RGBA:
+        cairo_color = (float(color.red), float(color.green), float(color.blue))
+    elif type(color) is tuple:
         # Cairo's set_source_rgb function expects values from 0.0 to 1.0
         cairo_color = map(lambda x: max(0, min(1, x / 255.0)), color)
-        context.set_source_rgb(*cairo_color)
     else:
-        context.set_source_rgb(float(color.red), float(color.green), float(color.blue))
+        raise Exception("Unexpected color parameter: %s, %s" % (type(color), color))
+    context.set_source_rgb(*cairo_color)
 
 
 class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):


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