xpra icon
Bug tracker and wiki

Ticket #907: gobject_subclassing.py

File gobject_subclassing.py, 1.7 KB (added by Antoine Martin, 4 years ago)

example triggering the centos 7 warning

Line 
1# This file is part of Xpra.
2# Copyright (C) 2015 Antoine Martin <antoine@devloop.org.uk>
3# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
4# later version. See the file COPYING for details.
5
6import gobject
7
8
9class BaseClass(gobject.GObject):
10    __common_properties__ = {
11        "foo": (gobject.TYPE_PYOBJECT,
12                "Foo thing", "",
13                gobject.PARAM_READABLE),
14           }
15    __common_signals__ = {
16        "bar"             : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (), ),
17        }
18
19    def __init__(self):
20        gobject.GObject.__init__(self)
21gobject.type_register(BaseClass)
22
23
24class ActualClass(BaseClass):
25
26    __gproperties__ = dict(BaseClass.__common_properties__)
27    __gproperties__.update({
28        "foo2": (gobject.TYPE_PYOBJECT,
29                  "Foo2 thing", "",
30                  gobject.PARAM_READABLE),
31                            })
32    __gsignals__ = dict(BaseClass.__common_signals__)
33    __gsignals__.update({
34        "bar2"           : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (), ),
35        })
36gobject.type_register(ActualClass)
37
38
39class OtherClass(BaseClass):
40    __gproperties__ = dict(BaseClass.__common_properties__)
41    __gproperties__.update({
42        "foo3": (gobject.TYPE_PYOBJECT,
43                  "Foo3 thing", "",
44                  gobject.PARAM_READABLE),
45                            })
46    __gsignals__ = dict(BaseClass.__common_signals__)
47    __gsignals__.update({
48        "bar3"           : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (), ),
49        })
50gobject.type_register(OtherClass)
51
52
53def main():
54    a = ActualClass()
55    b = OtherClass()
56    assert b!=a
57
58
59if __name__ == "__main__":
60    main()