diff options
author | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2007-06-16 11:54:03 +0000 |
---|---|---|
committer | Gustavo J. A. M. Carneiro <gjc@src.gnome.org> | 2007-06-16 11:54:03 +0000 |
commit | 599dbc210b59f58018c89ebb2d34b2255ea61d05 (patch) | |
tree | 661752e56a594707662f8c262f374bcaadea6df9 | |
parent | 00b12c72912c53aa541add7914a2c25784fb07e1 (diff) | |
download | pygobject-599dbc210b59f58018c89ebb2d34b2255ea61d05.tar.gz |
Support type=GObject or type=TYPE_OBJECT in the new properties API.
svn path=/trunk/; revision=675
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | gobject/propertyhelper.py | 4 | ||||
-rw-r--r-- | tests/test_properties.py | 14 |
3 files changed, 24 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2007-06-16 Gustavo J. A. M. Carneiro <gjc@gnome.org> + + * gobject/propertyhelper.py, + * tests/test_properties.py: Support type=GObject or + type=TYPE_OBJECT in the new properties API. + 2007-06-06 Yevgen Muntyan <muntyan@tamu.edu> OK'd by Johan diff --git a/gobject/propertyhelper.py b/gobject/propertyhelper.py index 7f9197ad..c382c83c 100644 --- a/gobject/propertyhelper.py +++ b/gobject/propertyhelper.py @@ -173,6 +173,8 @@ class property(object): return TYPE_STRING elif type == object: return TYPE_PYOBJECT + elif type == _gobject.GObject: + return TYPE_OBJECT elif type in [TYPE_NONE, TYPE_INTERFACE, TYPE_CHAR, TYPE_UCHAR, TYPE_INT, TYPE_UINT, TYPE_BOOLEAN, TYPE_LONG, TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_ENUM, @@ -279,6 +281,8 @@ class property(object): args = (self.default,) elif ptype == TYPE_PYOBJECT: args = () + elif ptype == TYPE_OBJECT: + args = () else: raise NotImplementedError(ptype) diff --git a/tests/test_properties.py b/tests/test_properties.py index 3996b8d6..a82c1fbe 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -290,3 +290,17 @@ class TestProperty(unittest.TestCase): o1.prop = 'value' self.assertEqual(o1.prop, 'value') self.assertEqual(o2.prop, 'default') + + def testObjectProperty(self): + class PropertyObject(GObject): + obj = gobject.property(type=GObject) + + pobj1 = PropertyObject() + obj1_hash = hash(pobj1) + pobj2 = PropertyObject() + + pobj2.obj = pobj1 + del pobj1 + pobj1 = pobj2.obj + self.assertEqual(hash(pobj1), obj1_hash) + |