[pygobject] Gdk.Window: Map the standard constructor to the *new* constructor
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Gdk.Window: Map the standard constructor to the *new* constructor
- Date: Tue, 1 Feb 2011 16:13:42 +0000 (UTC)
commit afeaaa126f7cd6556fb855ecd0facc174c0f946c
Author: Simon Schampijer <simon laptop org>
Date: Wed Jan 19 16:19:46 2011 +0100
Gdk.Window: Map the standard constructor to the *new* constructor
Gdk.Window had to be made abstract
(see c4a36d875235e0bf1e52dbf2fa14d08bfc8bd4ec in gtk),
this override allows using the standard constructor
This commit adds as well a testcase.
https://bugzilla.gnome.org/show_bug.cgi?id=639936
gi/overrides/Gdk.py | 6 ++++++
tests/test_overrides.py | 8 ++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 9d01105..4ed71a6 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -71,6 +71,12 @@ if Gdk._version == '2.0':
__all__.append('Drawable')
else:
class Window(Gdk.Window):
+ def __new__(cls, parent, attributes, attributes_mask):
+ # Gdk.Window had to be made abstract,
+ # this override allows using the standard constructor
+ return Gdk.Window.new(parent, attributes, attributes_mask)
+ def __init__(self, parent, attributes, attributes_mask):
+ pass
def cairo_create(self):
return Gdk.cairo_create(self)
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index aaf9f1d..aeb9e80 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -330,6 +330,14 @@ class TestPango(unittest.TestCase):
class TestGdk(unittest.TestCase):
+ def test_constructor(self):
+ attribute = Gdk.WindowAttr()
+ attribute.window_type = Gdk.WindowType.CHILD
+ attributes_mask = Gdk.WindowAttributesType.X | \
+ Gdk.WindowAttributesType.Y
+ window = Gdk.Window(None, attribute, attributes_mask)
+ self.assertEquals(window.get_window_type(), Gdk.WindowType.CHILD)
+
def test_color(self):
color = Gdk.Color(100, 200, 300)
self.assertEquals(color.red, 100)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]