From 7ba6b518fe414e2dc988acd9f7688ceca56d69f8 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Thu, 6 Sep 2012 13:05:56 +0900 Subject: [PATCH] Disabled to show non-used GUI. --- setup/main.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++------ setup/setup.ui | 38 ++++++++++++++++++---------------- 2 files changed, 77 insertions(+), 24 deletions(-) diff --git a/setup/main.py b/setup/main.py index cf63643..d14796c 100644 --- a/setup/main.py +++ b/setup/main.py @@ -77,22 +77,31 @@ class Setup(object): self.__init_ui() def __init_hotkey(self): + ''' default_values = { "trigger" : (N_("trigger"), ["Control+space"]), "enable_unconditional" : (N_("enable"), []), "disable_unconditional" : (N_("disable"), []) } + ''' + default_values = { + 'trigger_accel' : ('next_engine', ['space']), + 'trigger_accel_backward' : ('prev_engine', ['space']), + } values = dict(self.__config.get_values("general/hotkey")) - for name, (label, shortcuts) in default_values.items(): + for name, (id, shortcuts) in default_values.items(): shortcuts = values.get(name, shortcuts) - button = self.__builder.get_object("button_%s" % name) - entry = self.__builder.get_object("entry_%s" % name) + button = self.__builder.get_object("button_%s" % id) + entry = self.__builder.get_object("entry_%s" % id) entry.set_text("; ".join(shortcuts)) - entry.set_tooltip_text("\n".join(shortcuts)) - button.connect("clicked", self.__shortcut_button_clicked_cb, - label, "general/hotkey", name, entry) + text = '\n'.join(shortcuts) + text = "Use ';' separated values\n" + text + entry.set_tooltip_text(text) + button.connect("clicked", self.__shortcut_button_clicked_cb2, + name, "general/hotkey", id, entry) + button.set_tooltip_text("Save the left entry string") def __init_panel(self): values = dict(self.__config.get_values("panel")) @@ -445,6 +454,48 @@ class Setup(object): entry.set_text(text) entry.set_tooltip_text(text) + def __shortcut_button_clicked_cb2(self, button, name, section, id, entry): + text = entry.get_text() + if text: + text = text.replace(' ', '') + shortcuts = text.split(';') + else: + shortcuts = [] + orig_list =['space'] + if name == 'trigger_accel_backward': + orig_list =['space'] + variant = self.__config.get_value(section, name) + if variant != None: + orig_list = variant.dup_strv() + orig_text = ';'.join(orig_list) + if text == orig_text: + return + invalid_shortcut = None + for shortcut in shortcuts: + (key, mods) = Gtk.accelerator_parse(shortcut) + if shortcut.find('<') >= 0: + if mods <= 0: + invalid_shortcut = shortcut + break + if not Gtk.accelerator_valid(key, mods): + invalid_shortcut = shortcut + break + # Alt_R could be supported as the trigger key. + else: + if key <= 0: + invalid_shortcut = shortcut + break + if invalid_shortcut != None: + dlg = Gtk.MessageDialog(type = Gtk.MessageType.ERROR, + buttons = Gtk.ButtonsType.CLOSE, + message_format = "Invalid key %s" % invalid_shortcut) + dlg.run() + dlg.destroy() + return + self.__config.set_value(section, name, GLib.Variant.new_strv(shortcuts)) + text = '\n'.join(shortcuts) + text = "Use ';' separated values\n" + text + entry.set_tooltip_text(text) def __item_started_column_toggled_cb(self, cell, path_str, model): diff --git a/setup/setup.ui b/setup/setup.ui index 2026172..af99cae 100644 --- a/setup/setup.ui +++ b/setup/setup.ui @@ -122,7 +122,6 @@ True - False False The shortcut keys for switching to previous input method in the list 0 @@ -137,7 +136,7 @@ - True + True False 6 @@ -172,6 +171,7 @@ 1 2 + GTK_FILL @@ -183,7 +183,7 @@ True True - False + True @@ -193,7 +193,9 @@ - ... + + gtk-apply + True False True True @@ -223,9 +225,8 @@ True - False True - False + True @@ -235,10 +236,11 @@ - ... + + gtk-apply + True False True - False True False False @@ -260,7 +262,7 @@ - True + True False The shortcut keys for turning input method on or off 0 @@ -273,7 +275,7 @@ - True + True False 0 Enable: @@ -287,7 +289,7 @@ - True + True False 6 @@ -328,7 +330,7 @@ - True + True False 0 Disable: @@ -342,7 +344,7 @@ - True + True False 6 @@ -452,7 +454,7 @@ - True + True False Set the behavior of ibus how to show or hide language bar 0 @@ -481,7 +483,7 @@ - True + True False model_panel_show_mode @@ -521,7 +523,7 @@ Show icon on system tray False - True + True True False Show icon on system tray @@ -540,7 +542,7 @@ Show input method name on language bar False - True + True True False Show input method's name on language bar when check the checkbox @@ -1001,7 +1003,7 @@ You may use up/down buttons to change it.</i></small> - True + True False 0 none -- 1.7.10.4