diff options
author | Hideaki ABE <abe.sendai@gmail.com> | 2009-06-06 11:56:30 +0900 |
---|---|---|
committer | Hideaki ABE <abe.sendai@gmail.com> | 2009-06-06 11:56:30 +0900 |
commit | e9c356983cf3e06ad3c67392ca558b221f119257 (patch) | |
tree | 774a8a7360e2fadfa2d17deffa6d225d959652d8 /setup | |
parent | eede04867dacd2afb657b603cdd42187658b501d (diff) | |
download | ibus-anthy-e9c356983cf3e06ad3c67392ca558b221f119257.tar.gz |
Implimented multi shortcut key setsetup_ui_new
Diffstat (limited to 'setup')
-rw-r--r-- | setup/anthyprefs.py | 116 | ||||
-rw-r--r-- | setup/main.py | 31 | ||||
-rw-r--r-- | setup/setup.glade | 218 |
3 files changed, 262 insertions, 103 deletions
diff --git a/setup/anthyprefs.py b/setup/anthyprefs.py index 5f2d6a2..24d031f 100644 --- a/setup/anthyprefs.py +++ b/setup/anthyprefs.py @@ -30,7 +30,7 @@ _cmd_keys = [ "wide_latin_mode", "hiragana_mode", "katakana_mode", - "half_katakana", + "half_katakana_mode", "cancel_pseudo_ascii_mode_key", "circle_typing_method", @@ -105,7 +105,9 @@ _config = { 'page_size': 10, 'half_width_symbol': False, - 'half_width_number': False + 'half_width_number': False, + + 'shortcut_type': 'default' }, 'shortcut/default': { #mode_keys @@ -116,7 +118,7 @@ _config = { 'wide_latin_mode': [], 'hiragana_mode': [], 'katakana_mode': [], - 'half_katakana': [], + 'half_katakana_mode': [], 'cancel_pseudo_ascii_mode_key': ['Escape'], 'circle_typing_method': ['Alt+Romaji', 'Ctrl+slash'], @@ -186,3 +188,111 @@ _config = { 'add_word': ['F12'], }, } + +_shortcut_atok = { + 'on_off': ['Henkan', 'Eisu_toggle', 'Zenkaku_Hankaku'], + 'circle_input_mode': ['F10'], + 'hiragana_mode': ['Hiragana_Katakana'], + 'katakana_mode': ['Shift+Hiragana_Katakana'], + 'circle_typing_method': ['Romaji', 'Alt+Romaji'], + 'convert': ['space', 'Henkan', 'Shift+space', 'Shift+Henkan'], + 'predict': ['Tab'], + 'cancel': ['Escape', 'BackSpace', 'Ctrl+H', 'Ctrl+bracketleft'], + 'commit': ['Return', 'Ctrl+M'], + 'reconvert': ['Shift+Henkan'], + + 'insert_space': ['space'], + 'insert_alternate_space': ['Shift+space'], + 'backspace': ['BackSpace', 'Ctrl+H'], + 'delete': ['Delete', 'Ctrl+G'], + + 'move_caret_backward': ['Left', 'Ctrl+K'], + 'move_caret_forward': ['Right', 'Ctrl+L'], + 'move_caret_first': ['Ctrl+Left'], + 'move_caret_last': ['Ctrl+Right'], + + 'select_prev_segment': ['Shift+Left'], + 'select_next_segment': ['Shift+Right'], + 'select_first_segment': ['Ctrl+Left'], + 'select_last_segment': ['Ctrl+Right'], + 'expand_segment': ['Right', 'Ctrl+L'], + 'shrink_segment': ['Left', 'Ctrl+K'], + 'commit_selected_segment': ['Down'], + + 'candidates_page_up': ['Shift+Henkan', 'Page_Up'], + 'candidates_page_down': ['Henkan', 'Page_Down'], + 'select_next_candidate': ['space', 'Tab', 'Henkan', 'Shift+space', 'Shift+Henkan'], + 'select_prev_candidate': ['Up'], + + 'select_candidates_1': ['1'], + 'select_candidates_2': ['2'], + 'select_candidates_3': ['3'], + 'select_candidates_4': ['4'], + 'select_candidates_5': ['5'], + 'select_candidates_6': ['6'], + 'select_candidates_7': ['7'], + 'select_candidates_8': ['8'], + 'select_candidates_9': ['9'], + 'select_candidates_0': ['0'], + + 'convert_to_hiragana': ['F6', 'Ctrl+U'], + 'convert_to_katakana': ['F7', 'Ctrl+I'], + 'convert_to_half': ['F8', 'Ctrl+O'], + 'convert_to_half_katakana': ['Shift+F8'], + 'convert_to_wide_latin': ['F9', 'Ctrl+P'], + 'convert_to_latin': ['F10', 'Ctrl+at'], + + 'add_word': ['Ctrl+F7'], +} + +_config['shortcut/atok'] = dict.fromkeys(_cmd_keys, []) +_config['shortcut/atok'].update(_shortcut_atok) + +_shortcut_wnn = { + 'on_off': ['Shift+space'], + 'convert': ['space'], + 'predict': ['Ctrl+Q'], + 'cancel': ['Escape', 'Ctrl+G', 'Alt+Down', 'Muhenkan'], + 'commit': ['Ctrl+L', 'Ctrl+M', 'Ctrl+J', 'Return'], + 'insert_space': ['space'], + 'backspace': ['Ctrl+H', 'BackSpace'], + 'delete': ['Ctrl+D', 'Delete'], + + 'move_caret_backward': ['Ctrl+B', 'Left'], + 'move_caret_forward': ['Ctrl+F', 'Right'], + 'move_caret_first': ['Ctrl+A', 'Alt+Left'], + 'move_caret_last': ['Ctrl+E', 'Alt+Right'], + + 'select_prev_segment': ['Ctrl+B', 'Left'], + 'select_next_segment': ['Ctrl+F', 'Right'], + 'select_first_segment': ['Ctrl+A', 'Alt+Left'], + 'select_last_segment': ['Ctrl+E', 'Alt+Right'], + 'expand_segment': ['Ctrl+O', 'F14'], + 'shrink_segment': ['Ctrl+I', 'F13'], + + 'candidates_page_up': ['Tab'], + 'candidates_page_down': ['Shift+Tab'], + 'select_next_candidate': ['space', 'Ctrl+Q', 'Ctrl+P', 'Down'], + 'select_prev_candidate': ['Ctrl+N', 'Up'], + + 'select_candidates_1': ['1'], + 'select_candidates_2': ['2'], + 'select_candidates_3': ['3'], + 'select_candidates_4': ['4'], + 'select_candidates_5': ['5'], + 'select_candidates_6': ['6'], + 'select_candidates_7': ['7'], + 'select_candidates_8': ['8'], + 'select_candidates_9': ['9'], + 'select_candidates_0': ['0'], + + 'convert_to_hiragana': ['F6'], + 'convert_to_katakana': ['F7'], + 'convert_to_half': ['F8'], + 'convert_to_wide_latin': ['F9'], + 'convert_to_latin': ['F10'], +} + +_config['shortcut/wnn'] = dict.fromkeys(_cmd_keys, []) +_config['shortcut/wnn'].update(_shortcut_wnn) + diff --git a/setup/main.py b/setup/main.py index 47752bd..c412ddb 100644 --- a/setup/main.py +++ b/setup/main.py @@ -31,6 +31,11 @@ class AnthySetup(object): 'half_width_symbol', 'half_width_number']: xml.get_widget(name).set_active(prefs.get_value('common', name)) + l = ['default', 'atok', 'wnn'] + s_type = prefs.get_value('common', 'shortcut_type') + s_type = s_type if s_type in l else 'default' + xml.get_widget('shortcut_type').set_active(l.index(s_type)) + xml.get_widget('page_size').set_value(prefs.get_value('common', 'page_size')) @@ -44,7 +49,7 @@ class AnthySetup(object): tv.get_selection().connect_after('changed', self.on_selection_changed, 0) ls = gtk.ListStore(str, str) - sec = 'shortcut/default' + sec = 'shortcut/' + s_type for k in self.prefs.keys(sec): ls.append([k, l_to_s(self.prefs.get_value(sec, k))]) tv.set_model(ls) @@ -125,19 +130,39 @@ class AnthySetup(object): if id == gtk.RESPONSE_OK: new = l_to_s([m[i][0] for i in range(len(m))]) if new != ls.get(it, 1)[0]: - self.prefs.set_value('shortcut/default', ls.get(it, 0)[0], s_to_l(new)) + sec = self._get_shortcut_sec() + self.prefs.set_value(sec, ls.get(it, 0)[0], s_to_l(new)) ls.set(it, 1, new) self.xml.get_widget('btn_apply').set_sensitive(True) def on_btn_default_clicked(self, widget): ls, it = self.xml.get_widget('shortcut').get_selection().get_selected() - sec = 'shortcut/default' + sec = self._get_shortcut_sec() new = l_to_s(self.prefs.default[sec][ls.get(it, 0)[0]]) if new != ls.get(it, 1)[0]: self.prefs.set_value(sec, ls.get(it, 0)[0], s_to_l(new)) ls.set(it, 1, new) self.xml.get_widget('btn_apply').set_sensitive(True) + def _get_shortcut_sec(self): + l = ['default', 'atok', 'wnn'] + s_type = self.xml.get_widget('shortcut_type').get_active_text().lower() + return 'shortcut/' + s_type if s_type in l else 'default' + + def on_shortcut_type_changed(self, widget): + ls = self.xml.get_widget('shortcut').get_model() + ls.clear() + + for a in widget.get_model(): + print a[0] + + sec = self._get_shortcut_sec() + for k in self.prefs.keys(sec): + ls.append([k, l_to_s(self.prefs.get_value(sec, k))]) + + self.prefs.set_value('common', widget.name, sec[len('shortcut/'):]) + self.xml.get_widget('btn_apply').set_sensitive(True) + def on_shortcut_key_release_event(self, widget, event): if event.hardware_keycode in [36, 65]: self.on_btn_edit_clicked(None) diff --git a/setup/setup.glade b/setup/setup.glade index faa88ea..0beb3b6 100644 --- a/setup/setup.glade +++ b/setup/setup.glade @@ -38,17 +38,30 @@ <property name="column_spacing">8</property> <property name="row_spacing">4</property> <child> - <widget class="GtkComboBox" id="typing_method"> + <widget class="GtkLabel" id="label9"> <property name="visible">True</property> - <property name="items" translatable="yes">Romaji -Kana</property> - <signal name="changed" handler="on_cb_changed"/> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Input Mode:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">input_mode</property> + </widget> + <packing> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkLabel" id="label21"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Typing Method:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">typing_method</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> @@ -69,30 +82,17 @@ Wide Latin</property> </packing> </child> <child> - <widget class="GtkLabel" id="label21"> + <widget class="GtkComboBox" id="typing_method"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Typing Method:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">typing_method</property> + <property name="items" translatable="yes">Romaji +Kana</property> + <signal name="changed" handler="on_cb_changed"/> </widget> <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label9"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Input Mode:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">input_mode</property> - </widget> - <packing> - <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> @@ -135,49 +135,60 @@ Wide Latin</property> <property name="column_spacing">8</property> <property name="row_spacing">4</property> <child> - <widget class="GtkComboBox" id="behivior_on_focus_out"> + <widget class="GtkLabel" id="label12"> <property name="visible">True</property> - <property name="items" translatable="yes">Clear -Commit -Hold -</property> - <signal name="changed" handler="on_cb_changed"/> + <property name="xalign">0</property> + <property name="label" translatable="yes">_Period Style:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">period_style</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkComboBox" id="behivior_on_period"> + <widget class="GtkLabel" id="label26"> <property name="visible">True</property> - <property name="items" translatable="yes">Do Nothing -Auto Convert</property> + <property name="xalign">0</property> + <property name="label" translatable="yes">Ten _Key Type:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">ten_key_mode</property> + </widget> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="x_options">GTK_FILL</property> + <property name="y_options"></property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="ten_key_mode"> + <property name="visible">True</property> + <property name="items" translatable="yes">Ten Key Mode +Usual Mode +</property> <signal name="changed" handler="on_cb_changed"/> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="label23"> + <widget class="GtkComboBox" id="period_style"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Behaivior on _Focus Out:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">behivior_on_focus_out</property> + <property name="items" translatable="yes">、。 +,. +</property> + <signal name="changed" handler="on_cb_changed"/> </widget> <packing> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">GTK_FILL</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> <property name="y_options"></property> </packing> </child> @@ -197,60 +208,49 @@ Auto Convert</property> </packing> </child> <child> - <widget class="GtkComboBox" id="period_style"> + <widget class="GtkLabel" id="label23"> <property name="visible">True</property> - <property name="items" translatable="yes">、。 -,. -</property> - <signal name="changed" handler="on_cb_changed"/> + <property name="xalign">0</property> + <property name="label" translatable="yes">Behaivior on _Focus Out:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">behivior_on_focus_out</property> </widget> <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + <property name="x_options">GTK_FILL</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkComboBox" id="ten_key_mode"> + <widget class="GtkComboBox" id="behivior_on_period"> <property name="visible">True</property> - <property name="items" translatable="yes">Ten Key Mode -Usual Mode -</property> + <property name="items" translatable="yes">Do Nothing +Auto Convert</property> <signal name="changed" handler="on_cb_changed"/> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - <child> - <widget class="GtkLabel" id="label26"> - <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">Ten _Key Type:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">ten_key_mode</property> - </widget> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">GTK_FILL</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="y_options"></property> </packing> </child> <child> - <widget class="GtkLabel" id="label12"> + <widget class="GtkComboBox" id="behivior_on_focus_out"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Period Style:</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">period_style</property> + <property name="items" translatable="yes">Clear +Commit +Hold +</property> + <signal name="changed" handler="on_cb_changed"/> </widget> <packing> - <property name="x_options">GTK_FILL</property> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> <property name="y_options"></property> </packing> </child> @@ -293,18 +293,18 @@ Usual Mode <property name="column_spacing">8</property> <property name="row_spacing">4</property> <child> - <widget class="GtkCheckButton" id="half_width_symbol"> + <widget class="GtkCheckButton" id="half_width_number"> <property name="visible">True</property> - <property name="label" translatable="yes">Half Width _Symbol</property> + <property name="label" translatable="yes">Half Width _Number</property> <property name="use_underline">True</property> <property name="response_id">0</property> <property name="draw_indicator">True</property> <signal name="toggled" handler="on_ck_toggled"/> - <accelerator key="S" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> + <accelerator key="N" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </widget> <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> <property name="y_options"></property> </packing> </child> @@ -345,18 +345,18 @@ Usual Mode </packing> </child> <child> - <widget class="GtkCheckButton" id="half_width_number"> + <widget class="GtkCheckButton" id="half_width_symbol"> <property name="visible">True</property> - <property name="label" translatable="yes">Half Width _Number</property> + <property name="label" translatable="yes">Half Width _Symbol</property> <property name="use_underline">True</property> <property name="response_id">0</property> <property name="draw_indicator">True</property> <signal name="toggled" handler="on_ck_toggled"/> - <accelerator key="N" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> + <accelerator key="S" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </widget> <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> @@ -401,12 +401,36 @@ Usual Mode <property name="border_width">4</property> <property name="spacing">4</property> <child> - <widget class="GtkLabel" id="label28"> + <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> - <property name="xalign">0</property> - <property name="label" translatable="yes">_Key Customize</property> - <property name="use_underline">True</property> - <property name="mnemonic_widget">shortcut</property> + <property name="spacing">8</property> + <child> + <widget class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Shortcut Type:</property> + <property name="use_underline">True</property> + <property name="wrap_mode">PANGO_WRAP_WORD_CHAR</property> + <property name="mnemonic_widget">shortcut_type</property> + </widget> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="padding">1</property> + </packing> + </child> + <child> + <widget class="GtkComboBox" id="shortcut_type"> + <property name="visible">True</property> + <property name="items" translatable="yes">Default +ATOK +Wnn +</property> + <signal name="changed" handler="on_shortcut_type_changed"/> + </widget> + <packing> + <property name="position">1</property> + </packing> + </child> </widget> <packing> <property name="expand">False</property> |