[hamster-applet] cleaned up keybinder code. fixes bug 609863
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] cleaned up keybinder code. fixes bug 609863
- Date: Mon, 15 Feb 2010 12:47:56 +0000 (UTC)
commit 377e6b3030afbba7bcfe5b45289d11897f051f6c
Author: Toms Bauģis <toms baugis gmail com>
Date: Mon Feb 15 12:46:01 2010 +0000
cleaned up keybinder code. fixes bug 609863
src/hamster/KeyBinder.py | 76 -------------------------------------
src/hamster/Makefile.am | 1 -
src/hamster/applet.py | 25 +++++++++++-
src/hamster/keybinder/__init__.py | 6 ++-
4 files changed, 26 insertions(+), 82 deletions(-)
---
diff --git a/src/hamster/Makefile.am b/src/hamster/Makefile.am
index 4127575..0a3b9c1 100644
--- a/src/hamster/Makefile.am
+++ b/src/hamster/Makefile.am
@@ -19,7 +19,6 @@ hamster_PYTHON = \
charting.py \
graphics.py \
configuration.py \
- KeyBinder.py \
preferences.py \
stuff.py \
edit_activity.py \
diff --git a/src/hamster/applet.py b/src/hamster/applet.py
index 1270640..e73bc1a 100755
--- a/src/hamster/applet.py
+++ b/src/hamster/applet.py
@@ -34,7 +34,7 @@ import eds
from configuration import conf, runtime, dialogs
import stuff
-from KeyBinder import *
+import keybinder
from hamsterdbus import HAMSTER_URI, HamsterDbusController
# controllers for other windows
@@ -241,6 +241,9 @@ class HamsterApplet(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
@@ -257,7 +260,6 @@ class HamsterApplet(object):
runtime.dispatcher.add_handler('panel_visible', self.__show_toggle)
runtime.dispatcher.add_handler('activity_updated', self.after_activity_update)
runtime.dispatcher.add_handler('day_updated', self.after_fact_update)
- runtime.dispatcher.add_handler('keybinding_activated', self.on_keybinding_activated)
self.screen = None
if self.workspace_tracking:
@@ -274,6 +276,14 @@ class HamsterApplet(object):
self.prev_size = None
+ 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 init_workspace_tracking(self):
if not wnck: # can't track if we don't have the trackable
return
@@ -664,7 +674,7 @@ class HamsterApplet(object):
self.notification.show()
"""global shortcuts"""
- def on_keybinding_activated(self, event, data):
+ def on_keybinding_activated(self):
self.__show_toggle(None, not self.button.get_active())
@@ -688,6 +698,15 @@ class HamsterApplet(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):
diff --git a/src/hamster/keybinder/__init__.py b/src/hamster/keybinder/__init__.py
index e603441..5963702 100644
--- a/src/hamster/keybinder/__init__.py
+++ b/src/hamster/keybinder/__init__.py
@@ -1,11 +1,13 @@
try:
- from ._keybinder import *
+ from _keybinder import tomboy_keybinder_bind as bind
+ from _keybinder import tomboy_keybinder_unbind as unbind
except ImportError:
# running uninstalled?
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '.libs'))
try:
- from _keybinder import *
+ from _keybinder import tomboy_keybinder_bind as bind
+ from _keybinder import tomboy_keybinder_unbind as unbind
finally:
sys.path.pop()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]