[pygobject] Override Pango.Layout constructor.
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Override Pango.Layout constructor.
- Date: Sat, 11 Dec 2010 14:03:03 +0000 (UTC)
commit bca603de0f217fb290189a0ea330f82961c46d5d
Author: Paolo Borelli <pborelli gnome org>
Date: Sat Dec 11 15:03:21 2010 +0100
Override Pango.Layout constructor.
I must take a Pango.Context argument. Unfortumately the context is not a
gobject property so we need to jump through some oops.
gi/overrides/Pango.py | 13 +++++++++++++
tests/test_overrides.py | 6 ++++++
2 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Pango.py b/gi/overrides/Pango.py
index 1bbfcad..700d26d 100644
--- a/gi/overrides/Pango.py
+++ b/gi/overrides/Pango.py
@@ -38,3 +38,16 @@ class FontDescription(Pango.FontDescription):
FontDescription = override(FontDescription)
__all__.append('FontDescription')
+class Layout(Pango.Layout):
+
+ def __new__(cls, context):
+ return Pango.Layout.new(context)
+
+ def __init__(self, context, **kwds):
+ # simply discard 'context', since it was set by
+ # __new__ and it is not a PangoLayout property
+ super(Layout, self).__init__(**kwds)
+
+Layout = override(Layout)
+__all__.append('Layout')
+
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 8220c95..a53fd3e 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -44,6 +44,12 @@ class TestPango(unittest.TestCase):
desc = Pango.FontDescription('monospace')
self.assertEquals(desc.get_family(), 'monospace')
+ def test_layout(self):
+ self.assertRaises(TypeError, Pango.Layout)
+ context = Pango.Context()
+ layout = Pango.Layout(context)
+ self.assertEquals(layout.get_context(), context)
+
class TestGdk(unittest.TestCase):
def test_color(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]