import pygtk
pygtk.require('2.0')
import gobject
    
class MyObject(gobject.GObject):
    
    __gproperties__ = {
        'foo' : (gobject.TYPE_STRING, 'short_description',
                       'long_description', 'bar',
                       gobject.PARAM_READWRITE | gobject.PARAM_CONSTRUCT)
        }

    def __init__(self):
        gobject.GObject.__init__(self)

    def do_get_property(self, pspec):
        print 'calling do_get_property for %s' % pspec.name, self
        if pspec.name == 'foo':
            return self.foo
        else:
            raise AttributeError, 'unknown property %s' % pspec.name

    def do_set_property(self, pspec, value):
        print 'calling do_set_property for %s=%s' % (pspec.name, value), self
        if pspec.name == 'foo':
            self.foo = value
        else:
            raise AttributeError, 'unknown property %s' % pspec.name
        
gobject.type_register(MyObject)

def test():
    o1 = MyObject()
    a = o1.get_property('foo')
    print 'foo is', a

test()
