[kupfer] preferences: Use check callback for testing accelerators
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] preferences: Use check callback for testing accelerators
- Date: Wed, 31 Mar 2010 12:12:25 +0000 (UTC)
commit 6fe9c4defd22cdeefee0ed83affaf523fc4812d0
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Wed Mar 31 13:47:02 2010 +0200
preferences: Use check callback for testing accelerators
kupfer/ui/preferences.py | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/kupfer/ui/preferences.py b/kupfer/ui/preferences.py
index 4549798..439c911 100644
--- a/kupfer/ui/preferences.py
+++ b/kupfer/ui/preferences.py
@@ -662,17 +662,19 @@ class PreferencesWindowController (pretty.OutputMixin):
def _is_good_keystr(self, keystr):
# Reject single letters so you can't bind 'A' etc
if keystr is None:
- return False
- ukeystr = kupferstring.tounicode(keystr)
- return not (len(ukeystr) == 1 and ukeystr.isalnum())
+ return
+ label = gtk.accelerator_get_label(*gtk.accelerator_parse(keystr))
+ ulabel = kupferstring.tounicode(label)
+ return not (len(ulabel) == 1 and ulabel.isalnum())
def on_gkeybindings_row_activate(self, treeview, path, view_column):
it = self.gkeybind_store.get_iter(path)
keybind_id = self.gkeybind_store.get_value(it, 2)
setctl = settings.GetSettingsController()
curr_key = setctl.get_accelerator(keybind_id)
- keystr = getkey_dialog.ask_for_key(previous_key=curr_key)
- if self._is_good_keystr(keystr):
+ keystr = getkey_dialog.ask_for_key(self._is_good_keystr,
+ previous_key=curr_key)
+ if keystr is not None:
setctl.set_accelerator(keybind_id, keystr)
label = gtk.accelerator_get_label(*gtk.accelerator_parse(keystr))
self.gkeybind_store.set_value(it, 1, label)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]