def __init__(self, bus, path, name): dbus.service.Object.__init__(self, bus, path, name) self.running = False self.window = MainDialog() self._connect_signals()
class Application(dbus.service.Object): def __init__(self, bus, path, name): dbus.service.Object.__init__(self, bus, path, name) self.running = False self.window = MainDialog() self._connect_signals() @dbus.service.method(BUS_NAME, in_signature='', out_signature='b') def IsRunning(self): return self.running @dbus.service.method(BUS_NAME, in_signature='a{sv}i', out_signature='') def Start(self, options, timestamp): if self.IsRunning(): self.window.present_with_time(timestamp) else: self.running = True self._start() self.running = False @dbus.service.method(BUS_NAME, in_signature='', out_signature='') def Activate(self): self.window.present() gtk.gdk.notify_startup_complete() @dbus.service.method(BUS_NAME, in_signature='s', out_signature='s') def SetWorkingDirectory(self, cwd): self.window.set_cwd(cwd) return self.window.strfmt_dialog.cwd @dbus.service.signal(BUS_NAME, signature='s') def InsertSnippet(self, snippet): return snippet def _start(self): try: self.window.run() gtk.main() except Exception as err: ErrorDialog().run(err) sys.exit(127) def _connect_signals(self): self.window.connect('close', gtk.main_quit) self.window.connect('insert-snippet', self._on_insert_snippet) def _on_insert_snippet(self, window, snippet): self.InsertSnippet(snippet)