Moving more modules
[apertium.git] / trunk / apertium-tools / apertium-dbus / src / service.py
blob0960151d39282eb6de64b4df658303f9c8cbbf41
1 import gobject
3 import dbus
4 import dbus.service
5 import dbus.mainloop.glib
7 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
8 method = dbus.service.method
11 class Service(dbus.service.Object):
12 def __init__(self, name):
13 dbus.service.Object.__init__(self, dbus.SessionBus(), name)
16 def make_proxy(path, interface):
17 slash_index = path.index('/')
18 dbus_name = path[:slash_index]
19 obj_name = path[slash_index:]
21 return dbus.Interface(dbus.SessionBus().get_object(dbus_name, obj_name), interface)
24 def add_signal_receiver(*args, **kwargs):
25 dbus.SessionBus().add_signal_receiver(*args, **kwargs)
28 mainloop = None
30 def quit():
31 mainloop.quit()
33 def run_as(name):
34 global mainloop
36 name = dbus.service.BusName(name, dbus.SessionBus())
37 mainloop = gobject.MainLoop()
38 mainloop.run()