Skip to content

Commit

Permalink
Support type=GObject or type=TYPE_OBJECT in the new properties API.
Browse files Browse the repository at this point in the history
svn path=/trunk/; revision=675
  • Loading branch information
Gustavo J. A. M. Carneiro committed Jun 16, 2007
1 parent 00b12c7 commit 599dbc2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions gobject/propertyhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def _type_from_python(self, type):
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,
Expand Down Expand Up @@ -279,6 +281,8 @@ def get_pspec_args(self):
args = (self.default,)
elif ptype == TYPE_PYOBJECT:
args = ()
elif ptype == TYPE_OBJECT:
args = ()
else:
raise NotImplementedError(ptype)

Expand Down
14 changes: 14 additions & 0 deletions tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,17 @@ class C(gobject.GObject):
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)

0 comments on commit 599dbc2

Please sign in to comment.