summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorHuang Peng <shawn.p.huang@gmail.com>2008-08-21 13:49:34 +0800
committerHuang Peng <shawn.p.huang@gmail.com>2008-08-21 13:49:34 +0800
commitc77adbb5dea1bfd4fe275c9789623a0360677c9e (patch)
tree6bffad692c996f569151d3c8777e2e87d257dbd5 /daemon
parent766f22120dfeaa883ef0c3346898d9a7a690dd11 (diff)
downloadibus-c77adbb5dea1bfd4fe275c9789623a0360677c9e.tar.gz
ibus-c77adbb5dea1bfd4fe275c9789623a0360677c9e.tar.xz
ibus-c77adbb5dea1bfd4fe275c9789623a0360677c9e.zip
Add configure items for keyboard shortcuts.
Diffstat (limited to 'daemon')
-rw-r--r--daemon/bus.py49
1 files changed, 43 insertions, 6 deletions
diff --git a/daemon/bus.py b/daemon/bus.py
index 6e68f1e..068da15 100644
--- a/daemon/bus.py
+++ b/daemon/bus.py
@@ -60,9 +60,29 @@ class IBus(ibus.Object):
self.__connections = list()
self.__prev_key = None
- self.__shortcut_trigger = [(keysyms.space, modifier.CONTROL_MASK)]
- m = modifier.CONTROL_MASK | modifier.SHIFT_MASK | modifier.RELEASE_MASK
- self.__shortcut_next_engine = [(keysyms.Shift_L, m), (keysyms.Shift_R, m)]
+
+ self.__shortcut_trigger = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_TRIGGER, ["Ctrl+space"])
+ self.__shortcut_next_engine = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE,
+ ["Ctrl+Shift+Release+Shift_L", "Ctrl+Shift+Release+Shift_R"])
+ self.__shortcut_prev_engine = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE, [])
+
+ def __load_config_shortcut(self, config_key, default_value):
+
+ # load trigger
+ shortcut_strings = default_value
+ try:
+ shortcut_strings = self.__config.get_value(config_key)
+ except:
+ pass
+ shortcuts = []
+ for s in shortcut_strings:
+ keyval, keymask = self.__parse_shortcut_string(s)
+ if keyval != 0:
+ shortcuts.append((keyval, keymask))
+ return shortcuts
def new_connection(self, dbusconn):
conn = Connection(dbusconn)
@@ -436,6 +456,19 @@ class IBus(ibus.Object):
if key in self.__config_watch:
self.__config_watch[key].remove(conn)
+ def __parse_shortcut_string(self, string):
+ keys = string.split("+")
+ keymask = 0
+ for name, mask in modifier.MODIFIER_NAME_TABLE:
+ if name in keys[:-1]:
+ keymask |= mask
+ keyname = keys[-1]
+ if keyname[0] in "1234567890":
+ keyname = "_" + keyname
+ keyval = keysyms.__dict__.get(keyname, 0)
+
+ return keyval, keymask
+
def __config_value_changed_cb(self, config, key, value):
for _dir in self.__config_watch.keys():
if key.startswith(_dir):
@@ -444,11 +477,15 @@ class IBus(ibus.Object):
# check daemon configure
if key == CONFIG_GENERAL_SHORTCUT_TRIGGER:
- print value
+ self.__shortcut_trigger = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_TRIGGER, ["Ctrl+space"])
elif key == CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE:
- print value
+ self.__shortcut_next_engine = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE,
+ ["Ctrl+Shift+Release+Shift_L", "Ctrl+Shift+Release+Shift_R"])
elif key == CONFIG_GENERAL_SHORTCUT_PREV_ENGINE:
- print value
+ self.__shortcut_prev_engine = self.__load_config_shortcut(
+ CONFIG_GENERAL_SHORTCUT_NEXT_ENGINE, [])
def __config_destroy_cb(self, config):
if config == self.__config: