doc/tutorial.txt: Don't claim we have a tutorial for p2p connections yet
[dbus-python-phuang.git] / dbus / gobject_service.py
blob9b94f93d09d8eeaf4474aea0578ca8570c5fe9e6
1 """Support code for implementing D-Bus services via GObjects."""
3 # Copyright (C) 2007 Collabora Ltd. <http://www.collabora.co.uk/>
5 # Licensed under the Academic Free License version 2.1
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Library General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library General Public License for more details.
17 # You should have received a copy of the GNU Library General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 import gobject
22 import dbus.service
24 class ExportedGObjectType(gobject.GObjectMeta, dbus.service.InterfaceType):
25 """A metaclass which inherits from both GObjectMeta and
26 `dbus.service.InterfaceType`. Used as the metaclass for `ExportedGObject`.
27 """
28 def __init__(cls, name, bases, dct):
29 gobject.GObjectMeta.__init__(cls, name, bases, dct)
30 dbus.service.InterfaceType.__init__(cls, name, bases, dct)
32 class ExportedGObject(gobject.GObject, dbus.service.Object):
33 """A GObject which is exported on the D-Bus.
35 Because GObject and `dbus.service.Object` both have custom metaclasses,
36 the naive approach using simple multiple inheritance won't work. This
37 class has `ExportedGObjectType` as its metaclass, which is sufficient
38 to make it work correctly.
39 """
40 __metaclass__ = ExportedGObjectType
42 def __init__(self, conn=None, object_path=None, bus_name=None):
43 gobject.GObject.__init__(self)
44 dbus.service.Object.__init__(self, conn=conn,
45 object_path=object_path,
46 bus_name=bus_name)