[hamster-applet] avoiding multiple instances of same window
- From: Toms Baugis <tbaugis src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hamster-applet] avoiding multiple instances of same window
- Date: Thu, 15 Jul 2010 15:40:59 +0000 (UTC)
commit 4dcc1374266cdd9ebdac9a8181eb3b9492789d68
Author: Toms Bauģis <toms baugis gmail com>
Date: Thu Jul 15 16:38:45 2010 +0100
avoiding multiple instances of same window
src/hamster-standalone | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/hamster-standalone b/src/hamster-standalone
index ec31ebc..ad754bf 100755
--- a/src/hamster-standalone
+++ b/src/hamster-standalone
@@ -49,8 +49,22 @@ except:
logging.warning("Could not import pynotify - notifications will be disabled")
pynotify = None
-class ProjectHamster(object):
+import dbus, dbus.service, sys
+
+class ProjectHamster(dbus.service.Object):
+ __dbus_object_path__ = "/org/gnome/Hamster/Standalone"
+
def __init__(self):
+ # maintain just one instance. this code feels hackish
+ self.bus = dbus.SessionBus()
+ if "org.gnome.Hamster.Standalone" not in dbus.SessionBus().list_names():
+ bus_name = dbus.service.BusName("org.gnome.Hamster.Standalone", bus=self.bus)
+ dbus.service.Object.__init__(self, bus_name, self.__dbus_object_path__)
+ else:
+ overview = self.bus.get_object("org.gnome.Hamster.Standalone", self.__dbus_object_path__)
+ overview.show()
+ sys.exit(0)
+
# load window of activity switcher and todays view
self._gui = stuff.load_ui_file("hamster.ui")
self.window = self._gui.get_object('hamster-window')
@@ -442,8 +456,10 @@ class ProjectHamster(object):
def on_window_configure_event(self, window, event):
self.treeview.fix_row_heights()
+ @dbus.service.method("org.gnome.Hamster.Standalone")
def show(self):
self.window.show_all()
+ self.window.present()
def get_widget(self, name):
return self._gui.get_object(name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]