Skip to content
Browse files

[gi-overrides] add an override for Gdk.RGBA

  • Loading branch information...
1 parent ee2b63f commit b70f4daf071cf77a4561b57f5521eb928f66d1ce John (J5) Palmieri committed Mar 3, 2011
Showing with 28 additions and 0 deletions.
  1. +18 −0 gi/overrides/Gdk.py
  2. +10 −0 tests/test_overrides.py
View
18 gi/overrides/Gdk.py
@@ -45,6 +45,24 @@ def __repr__(self):
Color = override(Color)
__all__.append('Color')
+if Gdk._version == '3.0':
+ class RGBA(Gdk.RGBA):
+ def __init__(self, red=1.0, green=1.0, blue=1.0, alpha=1.0):
+ Gdk.RGBA.__init__(self)
+ self.red = red
+ self.green = green
+ self.blue = blue
+ self.alpha = alpha
+
+ def __new__(cls, *args, **kwargs):
+ return Gdk.RGBA.__new__(cls)
+
+ def __repr__(self):
+ return '<Gdk.Color(red=%f, green=%f, blue=%f, alpha=%f)>' % (self.red, self.green, self.blue, self.alpha)
+
+ RGBA = override(RGBA)
+ __all__.append('RGBA')
+
if Gdk._version == '2.0':
class Rectangle(Gdk.Rectangle):
View
10 tests/test_overrides.py
@@ -345,6 +345,16 @@ def test_color(self):
self.assertEquals(color.green, 200)
self.assertEquals(color.blue, 300)
+ def test_rgba(self):
+ self.assertEquals(Gdk.RGBA, overrides.Gdk.RGBA)
+ rgba = Gdk.RGBA(0.1, 0.2, 0.3, 0.4)
+ self.assertEquals(rgba.red, 0.1)
+ self.assertEquals(rgba.green, 0.2)
+ self.assertEquals(rgba.blue, 0.3)
+ self.assertEquals(rgba.alpha, 0.4)
+ rgba.green = 0.9
+ self.assertEquals(rgba.green, 0.9)
+
def test_event(self):
event = Gdk.Event.new(Gdk.EventType.CONFIGURE)
self.assertEquals(event.type, Gdk.EventType.CONFIGURE)

0 comments on commit b70f4da

Please sign in to comment.
Something went wrong with that request. Please try again.