[hamster-applet] if possible, grab global hotkey and on press present the window



commit 7ee22787742a5dbbff1be44066c75cfca1398af3
Author: Toms Bauģis <toms baugis gmail com>
Date:   Tue Feb 23 14:04:50 2010 +0000

    if possible, grab global hotkey and on press present the window

 src/hamster-standalone |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/src/hamster-standalone b/src/hamster-standalone
index 9013746..0e96469 100755
--- a/src/hamster-standalone
+++ b/src/hamster-standalone
@@ -30,7 +30,7 @@ import dbus, dbus.service, dbus.mainloop.glib
 from hamster import eds
 from hamster.configuration import conf, runtime, dialogs
 
-from hamster import stuff
+from hamster import stuff, keybinder
 from hamster.hamsterdbus import HAMSTER_URI, HamsterDbusController
 
 # controllers for other windows
@@ -99,6 +99,9 @@ class ProjectHamster(object):
         self.notify_interval = conf.get("notify_interval")
         self.workspace_tracking = conf.get("workspace_tracking")
 
+        self.hotkey = conf.get("keybinding")
+        self.bind_hotkey()
+
         runtime.dispatcher.add_handler('conf_changed', self.on_conf_changed)
 
         # Load today's data, activities and set label
@@ -271,6 +274,18 @@ class ProjectHamster(object):
         fact = self.treeview.get_selected_fact()
         runtime.storage.remove_fact(fact["id"])
 
+    def bind_hotkey(self):
+        try:
+            print 'Binding shortcut %s to popup hamster' % self.hotkey
+            keybinder.bind(self.hotkey, self.on_keybinding_activated)
+        except KeyError:
+            pass # don't care
+
+    def on_keybinding_activated(self):
+        print "boink"
+        self.window.present()
+
+
     def __update_fact(self):
         """dbus controller current fact updating"""
         last_activity_id = 0
@@ -449,6 +464,14 @@ class ProjectHamster(object):
                 if self.screen:
                     self.screen.disconnect(self.screen.workspace_handler)
                     self.screen = None
+        elif key == "keybinding":
+            try:
+                keybinder.unbind(self.hotkey)
+            except KeyError:
+                pass # don't care
+
+            self.hotkey = value
+            self.bind_hotkey()
 
 
     def on_activity_text_changed(self, widget):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]