diff options
Diffstat (limited to 'setup/python2')
-rw-r--r-- | setup/python2/Makefile.am | 15 | ||||
-rw-r--r-- | setup/python2/anthyprefs.py | 342 | ||||
-rw-r--r-- | setup/python2/anthyprefs.py.in | 1368 | ||||
-rw-r--r-- | setup/python2/main.py | 633 | ||||
-rw-r--r-- | setup/python2/prefs.py | 425 | ||||
-rw-r--r-- | setup/python2/setup.ui | 134 |
6 files changed, 870 insertions, 2047 deletions
diff --git a/setup/python2/Makefile.am b/setup/python2/Makefile.am index 948f0a8..4e072e9 100644 --- a/setup/python2/Makefile.am +++ b/setup/python2/Makefile.am @@ -4,8 +4,8 @@ # # Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> # Copyright (c) 2009 Hideaki ABE <abe.sendai@gmail.com> -# Copyright (c) 2010-2016 Takao Fujiwara <takao.fujiwara1@gmail.com> -# Copyright (c) 2007-2016 Red Hat, Inc. +# Copyright (c) 2010-2017 Takao Fujiwara <takao.fujiwara1@gmail.com> +# Copyright (c) 2007-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -37,7 +37,6 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) BUILT_SOURCES = \ _config.py \ - anthyprefs.py \ $(NULL) libexec_SCRIPTS = ibus-setup-anthy @@ -82,15 +81,6 @@ ibus-setup-anthy: ibus-setup-anthy.in -e "s|\@PYTHON\@|$(PYTHON)|g" \ $< > $@ -anthyprefs.py: anthyprefs.py.in - sed -e "s|\@ANTHY_ZIPCODE_FILE\@|$(ANTHY_ZIPCODE_FILE)|g" \ - -e "s|\@KASUMI_EXEC_FILE\@|$(KASUMI_EXEC_FILE)|g" \ - -e "s|\@KASUMI_ICON_FILE\@|$(KASUMI_ICON_FILE)|g" \ - -e "s|\@ON_OFF_KEYS\@|$(ON_OFF_KEYS)|g" \ - -e "s|\@VERSION\@|$(VERSION)|g" \ - -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ - $< > $@ - _config.py: _config.py.in sed -e "s|\@pkgdatadir\@|$(pkgdatadir)|g" \ -e "s|\@libexecdir\@|$(libexecdir)|g" \ @@ -98,6 +88,7 @@ _config.py: _config.py.in -e "s|\@LAYOUT\@|$(LAYOUT)|g" \ -e "s|\@SYMBOL_CHAR_INT\@|$(SYMBOL_CHAR_INT)|g" \ -e "s|\@ICON_PREFERENCE\@|$(ICON_PREFERENCE)|g" \ + -e "s|\@VERSION\@|$(VERSION)|g" \ $< > $@ # Need a time lag between .py and .py.in files to build .py files diff --git a/setup/python2/anthyprefs.py b/setup/python2/anthyprefs.py new file mode 100644 index 0000000..5e3bade --- /dev/null +++ b/setup/python2/anthyprefs.py @@ -0,0 +1,342 @@ +# -*- coding: utf-8 -*- +# vim:set noet ts=4: +# +# ibus-anthy - The Anthy engine for IBus +# +# Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> +# Copyright (c) 2009 Hideaki ABE <abe.sendai@gmail.com> +# Copyright (c) 2010-2017 Takao Fujiwara <takao.fujiwara1@gmail.com> +# Copyright (c) 2007-2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import sys + +import _config as config +from prefs import Prefs + +N_ = lambda a : a + +__all__ = ['AnthyPrefs'] + + +class AnthyPrefs(Prefs): + _char_to_config_key = None + + def __init__(self): + super(AnthyPrefs, self).__init__() + + def get_japanese_ordered_list(self): + return _japanese_ordered_list + + def get_version(self): + return config.VERSION + + # Convert gsettings key to typing sequences + # E.g. 'largea-bracketleft' to 'A[' + def typing_from_config_key(self, gkeys): + retval = '' + for key in gkeys.split('-'): + if key in _supported_gsettings_key_chars: + retval += key + continue + try: + ch = _config_key_to_char[key] + except KeyError: + print >> sys.stderr, 'Not supported key in gsettings', gkeys + retval = '' + break + retval += ch + return retval + + # Convert typing sequences to gsettings key. + # E.g. 'A[' to 'largea-bracketleft' + def typing_to_config_key(self, typing): + retval = '' + if self._char_to_config_key == None: + self._char_to_config_key = {} + for _key, _ch in _config_key_to_char.items(): + self._char_to_config_key[_ch] = _key + for ch in typing: + try: + # U+A5 needs to be UTF-8 since gconf values are + # disk saved values. + ch = ch.encode('utf-8') + except: + print >> sys.stderr, \ + 'Failed to encode UTF-8:', ch + if ch in _supported_gsettings_key_chars: + if retval != '': + retval += '-' + retval += ch + continue + try: + key = self._char_to_config_key[ch] + except KeyError: + print >> sys.stderr, 'Not supported key in gsettings', typing + retval = '' + break + if retval != '': + retval += '-' + retval += key + return retval + + def get_value(self, section, key): + not_sorted = super(AnthyPrefs, self).get_value(section, key) + if section == 'shortcut' and type(not_sorted) == dict: + retval = dict.fromkeys(_cmd_keys, []) + retval.update(not_sorted) + return retval + return not_sorted + + +# Sad! dict.keys() doesn't return the saved order. +# locale.strcoll() also just returns the Unicode code point. +# Unicode order is wrong in Japanese large 'a' and small 'a'. +# The workaround is to save the order here... +_japanese_ordered_list = [ + 'あ', 'い', 'う', 'え', 'お', + 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', + 'いぇ', + 'うぁ', 'うぃ', 'うぅ', 'うぇ', 'うぉ', + 'うゃ', 'うゅ', 'うょ', + 'か', 'き', 'く', 'け', 'こ', + 'ゕ', 'ゖ', 'ヵ', 'ヶ', + 'が', 'ぎ', 'ぐ', 'げ', 'ご', + 'きゃ', 'きぃ', 'きゅ', 'きぇ', 'きょ', + 'くぁ', 'くぃ', 'くぅ', 'くぇ', 'くぉ', + 'ぎゃ', 'ぎぃ', 'ぎゅ', 'ぎぇ', 'ぎょ', + 'ぐぁ', 'ぐぃ', 'ぐぅ', 'ぐぇ', 'ぐぉ', + 'さ', 'し', 'す', 'せ', 'そ', + 'ざ', 'じ', 'ず', 'ぜ', 'ぞ', + 'しゃ', 'しぃ', 'しゅ', 'しぇ', 'しょ', + 'じゃ', 'じぃ', 'じゅ', 'じぇ', 'じょ', + 'すぅぃ', 'すぇ', + 'ずぇ', + 'た', 'ち', 'つ', 'て', 'と', + 'だ', 'ぢ', 'づ', 'で', 'ど', + 'っ', + 'ちゃ', 'ちぃ', 'ちゅ', 'ちぇ', 'ちょ', + 'ぢぃ', 'ぢぇ', + 'ぢゃ', 'ぢゅ', 'ぢょ', + 'つぁ', 'つぃ', 'つぇ', 'つぉ', + 'つゃ', 'つぃぇ', 'つゅ', 'つょ', + 'づぁ', 'づぃ', 'づぇ', 'づぉ', + 'づゃ', 'づぃぇ', 'づゅ', 'づょ', + 'てぃ', 'てぇ', + 'てゃ', 'てゅ', 'てょ', + 'とぅ', + 'でぃ', 'でぇ', + 'でゃ', 'でゅ', 'でょ', + 'どぅ', + 'な', 'に', 'ぬ', 'ね', 'の', + 'にぃ', 'にぇ', + 'にゃ', 'にゅ', 'にょ', + 'は', 'ひ', 'ふ', 'へ', 'ほ', + 'ば', 'び', 'ぶ', 'べ', 'ぼ', + 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ', + 'ひぃ', 'ひぇ', + 'ひゃ', 'ひゅ', 'ひょ', + 'びぃ', 'びぇ', + 'びゃ', 'びゅ', 'びょ', + 'ぴぃ', 'ぴぇ', + 'ぴゃ', 'ぴゅ', 'ぴょ', + 'ふぁ', 'ふぃ', 'ふぇ', 'ふぉ', + 'ふゃ', 'ふゅ', 'ふょ', + 'ぶぁ', 'ぶぇ', 'ぶぉ', + 'ぷぁ', 'ぷぇ', 'ぷぉ', + 'ま', 'み', 'む', 'め', 'も', + 'みぃ', 'みぇ', + 'みゃ', 'みゅ', 'みょ', + 'や', 'ゆ', 'よ', + 'ゃ', 'ゅ', 'ょ', + 'ら', 'り', 'る', 'れ', 'ろ', + 'りぃ', 'りぇ', + 'りゃ', 'りゅ', 'りょ', + 'わ', 'を', 'ん', + 'ゎ', + 'ゐ', 'ゑ', + 'ー', + 'ヴぁ', 'ヴぃ', 'ヴ', 'ヴぇ', 'ヴぉ', + 'ヴゃ', 'ヴぃぇ', 'ヴゅ', 'ヴょ', +] + +# http://git.gnome.org/browse/glib/tree/gio/glib-compile-schemas.c#n765 +# gsettings supports keys named by "abcdefghijklmnopqrstuvwxyz0123456789-" +# and ibus-anthy uses '-' as the delimiter. +_supported_gsettings_key_chars = "abcdefghijklmnopqrstuvwxyz0123456789" + +_config_key_to_char = { + # no modifiers keys + 'minus' : '-', + 'asciicircum' : '^', + 'at' : '@', + 'bracketleft' : '[', + 'semicolon' : ';', + 'colon' : ':', + 'bracketright' : ']', + 'comma' : ',', + 'period' : '.', + 'slash' : '/', + 'backslash' : '\\', + + # shift modifiered keys + 'exclam' : '!', + 'quotedbl' : '"', + 'numbersign' : '#', + 'dollar' : '$', + 'percent' : '%', + 'ampersand' : '&', + 'apostrophe' : '\'', + 'parenleft' : '(', + 'parenright' : ')', + 'asciitilde' : '~', + 'equal' : '=', + 'bar' : '|', + + 'largeq' : 'Q', + 'largew' : 'W', + 'largee' : 'E', + 'larger' : 'R', + 'larget' : 'T', + 'largey' : 'Y', + 'largeu' : 'U', + 'largei' : 'I', + 'largeo' : 'O', + 'largep' : 'P', + 'grave' : '`', + + 'braceleft' : '{', + + 'largea' : 'A', + 'larges' : 'S', + 'larged' : 'D', + 'largef' : 'F', + 'largeg' : 'G', + 'largeh' : 'H', + 'largej' : 'J', + 'largek' : 'K', + 'largel' : 'L', + 'plus' : '+', + 'asterisk' : '*', + + 'braceright' : '}', + + 'largez' : 'Z', + 'largex' : 'X', + 'largec' : 'C', + 'largev' : 'V', + 'largeb' : 'B', + 'largen' : 'N', + 'largem' : 'M', + 'less' : '<', + 'greater' : '>', + + 'question' : '?', + 'underscore' : '_', + + 'yen' : '¥', +} + +_cmd_keys = [ + 'on_off', + 'circle_input_mode', + 'circle_kana_mode', + 'circle_typing_method', + 'circle_dict_method', + 'latin_mode', + 'wide_latin_mode', + 'hiragana_mode', + 'katakana_mode', + 'half_katakana_mode', +# 'cancel_pseudo_ascii_mode_key', + + 'hiragana_for_latin_with_shift', + + 'insert_space', + 'insert_alternate_space', + 'insert_half_space', + 'insert_wide_space', + 'backspace', + 'delete', + 'commit', + 'convert', + 'predict', + 'cancel', + 'cancel_all', + 'reconvert', +# 'do_nothing', + + 'select_first_candidate', + 'select_last_candidate', + 'select_next_candidate', + 'select_prev_candidate', + 'candidates_page_up', + 'candidates_page_down', + + 'move_caret_first', + 'move_caret_last', + 'move_caret_forward', + 'move_caret_backward', + + 'select_first_segment', + 'select_last_segment', + 'select_next_segment', + 'select_prev_segment', + 'shrink_segment', + 'expand_segment', + 'commit_first_segment', + 'commit_selected_segment', + + 'select_candidates_1', + 'select_candidates_2', + 'select_candidates_3', + 'select_candidates_4', + 'select_candidates_5', + 'select_candidates_6', + 'select_candidates_7', + 'select_candidates_8', + 'select_candidates_9', + 'select_candidates_0', + + 'convert_to_char_type_forward', + 'convert_to_char_type_backward', + 'convert_to_hiragana', + 'convert_to_katakana', + 'convert_to_half', + 'convert_to_half_katakana', + 'convert_to_wide_latin', + 'convert_to_latin', + 'convert_to_hiragana_all', + 'convert_to_katakana_all', + 'convert_to_half_all', + 'convert_to_half_katakana_all', + 'convert_to_wide_latin_all', + 'convert_to_latin_all', + + 'dict_admin', + 'add_word', + + 'start_setup', +] + +_dummy_translatable_strings = [ + N_('General'), + N_('Zip Code Conversion'), + N_('Symbol'), + N_('Old Character Style'), + N_('Era'), + N_('Emoji'), +] diff --git a/setup/python2/anthyprefs.py.in b/setup/python2/anthyprefs.py.in deleted file mode 100644 index f232879..0000000 --- a/setup/python2/anthyprefs.py.in +++ /dev/null @@ -1,1368 +0,0 @@ -# -*- coding: utf-8 -*- -# vim:set noet ts=4: -# -# ibus-anthy - The Anthy engine for IBus -# -# Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> -# Copyright (c) 2009 Hideaki ABE <abe.sendai@gmail.com> -# Copyright (c) 2010-2015 Takao Fujiwara <takao.fujiwara1@gmail.com> -# Copyright (c) 2007-2015 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -import sys - -from prefs import Prefs - -N_ = lambda a : a - -__all__ = ['AnthyPrefs'] - - -class AnthyPrefs(Prefs): - _prefix = 'engine/anthy' - _char_to_config_key = None - - def __init__(self, bus=None, config=None): - super(AnthyPrefs, self).__init__(bus, config) - if _config != None: - self.default = _config - self.set_no_key_warning(True) - self.fetch_all() - self.set_no_key_warning(False) - - def __update_key (self, section, old_key, new_key): - file = __file__ - if __file__.find('/') >= 0: - file = __file__[__file__.rindex('/') + 1:] - warning_message = \ - '(' + file + ') ibus-anthy-WARNING **: ' \ - 'The key (' + old_key + ') will be removed in the future. ' \ - 'Currently the key (' + new_key + ') is used instead. ' \ - 'The ibus keys are defined in ' + \ - '/'.join(['/desktop/ibus', self._prefix, section]) + ' .' - - if not self.fetch_item(section, old_key, True): - return - print >> sys.stderr, warning_message - if self.fetch_item(section, new_key, True): - return - - self.fetch_item(section, old_key) - value = self.get_value(section, old_key) - self.set_value(section, new_key, value) - self.commit_item(section, new_key) - self.undo_item(section, new_key) - - def keys(self, section): - if section.startswith('shortcut/'): - return _cmd_keys - return self.default[section].keys() - - def get_japanese_ordered_list(self): - return _japanese_ordered_list - - def get_version(self): - return '@VERSION@' - - # Convert typing sequences to gsettings key. - # E.g. 'largea-bracketleft' to 'A[' - def typing_from_config_key(self, gkeys): - retval = '' - for key in gkeys.split('-'): - if key in _supported_gsettings_key_chars: - retval += key - continue - try: - ch = _config_key_to_char[key] - except KeyError: - print >> sys.stderr, 'Not supported key in gsettings', gkeys - retval = '' - break - retval += ch - return retval - - # Convert typing sequences to gsettings key. - # E.g. 'A[' to 'largea-bracketleft' - def typing_to_config_key(self, typing): - retval = '' - if self._char_to_config_key == None: - self._char_to_config_key = {} - for _key, _ch in _config_key_to_char.items(): - self._char_to_config_key[_ch] = _key - for ch in typing: - try: - # U+A5 needs to be UTF-8 since gconf values are - # disk saved values. - ch = ch.encode('utf-8') - except: - print >> sys.stderr, \ - 'Failed to encode UTF-8:', ch - if ch in _supported_gsettings_key_chars: - if retval != '': - retval += '-' - retval += ch - continue - try: - key = self._char_to_config_key[ch] - except KeyError: - print >> sys.stderr, 'Not supported key in gsettings', typing - retval = '' - break - if retval != '': - retval += '-' - retval += key - return retval - -# Sad! dict.keys() doesn't return the saved order. -# locale.strcoll() also just returns the Unicode code point. -# Unicode order is wrong in Japanese large 'a' and small 'a'. -# The workaround is to save the order here... -_japanese_ordered_list = [ - 'あ', 'い', 'う', 'え', 'お', - 'ぁ', 'ぃ', 'ぅ', 'ぇ', 'ぉ', - 'いぇ', - 'うぁ', 'うぃ', 'うぅ', 'うぇ', 'うぉ', - 'うゃ', 'うゅ', 'うょ', - 'か', 'き', 'く', 'け', 'こ', - 'ゕ', 'ゖ', 'ヵ', 'ヶ', - 'が', 'ぎ', 'ぐ', 'げ', 'ご', - 'きゃ', 'きぃ', 'きゅ', 'きぇ', 'きょ', - 'くぁ', 'くぃ', 'くぅ', 'くぇ', 'くぉ', - 'ぎゃ', 'ぎぃ', 'ぎゅ', 'ぎぇ', 'ぎょ', - 'ぐぁ', 'ぐぃ', 'ぐぅ', 'ぐぇ', 'ぐぉ', - 'さ', 'し', 'す', 'せ', 'そ', - 'ざ', 'じ', 'ず', 'ぜ', 'ぞ', - 'しゃ', 'しぃ', 'しゅ', 'しぇ', 'しょ', - 'じゃ', 'じぃ', 'じゅ', 'じぇ', 'じょ', - 'すぅぃ', 'すぇ', - 'ずぇ', - 'た', 'ち', 'つ', 'て', 'と', - 'だ', 'ぢ', 'づ', 'で', 'ど', - 'っ', - 'ちゃ', 'ちぃ', 'ちゅ', 'ちぇ', 'ちょ', - 'ぢぃ', 'ぢぇ', - 'ぢゃ', 'ぢゅ', 'ぢょ', - 'つぁ', 'つぃ', 'つぇ', 'つぉ', - 'つゃ', 'つぃぇ', 'つゅ', 'つょ', - 'づぁ', 'づぃ', 'づぇ', 'づぉ', - 'づゃ', 'づぃぇ', 'づゅ', 'づょ', - 'てぃ', 'てぇ', - 'てゃ', 'てゅ', 'てょ', - 'とぅ', - 'でぃ', 'でぇ', - 'でゃ', 'でゅ', 'でょ', - 'どぅ', - 'な', 'に', 'ぬ', 'ね', 'の', - 'にぃ', 'にぇ', - 'にゃ', 'にゅ', 'にょ', - 'は', 'ひ', 'ふ', 'へ', 'ほ', - 'ば', 'び', 'ぶ', 'べ', 'ぼ', - 'ぱ', 'ぴ', 'ぷ', 'ぺ', 'ぽ', - 'ひぃ', 'ひぇ', - 'ひゃ', 'ひゅ', 'ひょ', - 'びぃ', 'びぇ', - 'びゃ', 'びゅ', 'びょ', - 'ぴぃ', 'ぴぇ', - 'ぴゃ', 'ぴゅ', 'ぴょ', - 'ふぁ', 'ふぃ', 'ふぇ', 'ふぉ', - 'ふゃ', 'ふゅ', 'ふょ', - 'ぶぁ', 'ぶぇ', 'ぶぉ', - 'ぷぁ', 'ぷぇ', 'ぷぉ', - 'ま', 'み', 'む', 'め', 'も', - 'みぃ', 'みぇ', - 'みゃ', 'みゅ', 'みょ', - 'や', 'ゆ', 'よ', - 'ゃ', 'ゅ', 'ょ', - 'ら', 'り', 'る', 'れ', 'ろ', - 'りぃ', 'りぇ', - 'りゃ', 'りゅ', 'りょ', - 'わ', 'を', 'ん', - 'ゎ', - 'ゐ', 'ゑ', - 'ー', - 'ヴぁ', 'ヴぃ', 'ヴ', 'ヴぇ', 'ヴぉ', - 'ヴゃ', 'ヴぃぇ', 'ヴゅ', 'ヴょ', -] - -# http://git.gnome.org/browse/glib/tree/gio/glib-compile-schemas.c#n765 -# gsettings supports keys named by "abcdefghijklmnopqrstuvwxyz0123456789-" -# and ibus-anthy uses '-' as the delimiter. -_supported_gsettings_key_chars = "abcdefghijklmnopqrstuvwxyz0123456789" - -_config_key_to_char = { - # no modifiers keys - 'minus' : '-', - 'asciicircum' : '^', - 'at' : '@', - 'bracketleft' : '[', - 'semicolon' : ';', - 'colon' : ':', - 'bracketright' : ']', - 'comma' : ',', - 'period' : '.', - 'slash' : '/', - 'backslash' : '\\', - - # shift modifiered keys - 'exclam' : '!', - 'quotedbl' : '"', - 'numbersign' : '#', - 'dollar' : '$', - 'percent' : '%', - 'ampersand' : '&', - 'apostrophe' : '\'', - 'parenleft' : '(', - 'parenright' : ')', - 'asciitilde' : '~', - 'equal' : '=', - 'bar' : '|', - - 'largeq' : 'Q', - 'largew' : 'W', - 'largee' : 'E', - 'larger' : 'R', - 'larget' : 'T', - 'largey' : 'Y', - 'largeu' : 'U', - 'largei' : 'I', - 'largeo' : 'O', - 'largep' : 'P', - 'grave' : '`', - - 'braceleft' : '{', - - 'largea' : 'A', - 'larges' : 'S', - 'larged' : 'D', - 'largef' : 'F', - 'largeg' : 'G', - 'largeh' : 'H', - 'largej' : 'J', - 'largek' : 'K', - 'largel' : 'L', - 'plus' : '+', - 'asterisk' : '*', - - 'braceright' : '}', - - 'largez' : 'Z', - 'largex' : 'X', - 'largec' : 'C', - 'largev' : 'V', - 'largeb' : 'B', - 'largen' : 'N', - 'largem' : 'M', - 'less' : '<', - 'greater' : '>', - - 'question' : '?', - 'underscore' : '_', - - 'yen' : '¥', -} - -_cmd_keys = [ - 'on_off', - 'circle_input_mode', - 'circle_kana_mode', - 'circle_typing_method', - 'circle_dict_method', - 'latin_mode', - 'wide_latin_mode', - 'hiragana_mode', - 'katakana_mode', - 'half_katakana_mode', -# 'cancel_pseudo_ascii_mode_key', - - 'hiragana_for_latin_with_shift', - - 'insert_space', - 'insert_alternate_space', - 'insert_half_space', - 'insert_wide_space', - 'backspace', - 'delete', - 'commit', - 'convert', - 'predict', - 'cancel', - 'cancel_all', - 'reconvert', -# 'do_nothing', - - 'select_first_candidate', - 'select_last_candidate', - 'select_next_candidate', - 'select_prev_candidate', - 'candidates_page_up', - 'candidates_page_down', - - 'move_caret_first', - 'move_caret_last', - 'move_caret_forward', - 'move_caret_backward', - - 'select_first_segment', - 'select_last_segment', - 'select_next_segment', - 'select_prev_segment', - 'shrink_segment', - 'expand_segment', - 'commit_first_segment', - 'commit_selected_segment', - - 'select_candidates_1', - 'select_candidates_2', - 'select_candidates_3', - 'select_candidates_4', - 'select_candidates_5', - 'select_candidates_6', - 'select_candidates_7', - 'select_candidates_8', - 'select_candidates_9', - 'select_candidates_0', - - 'convert_to_char_type_forward', - 'convert_to_char_type_backward', - 'convert_to_hiragana', - 'convert_to_katakana', - 'convert_to_half', - 'convert_to_half_katakana', - 'convert_to_wide_latin', - 'convert_to_latin', - 'convert_to_hiragana_all', - 'convert_to_katakana_all', - 'convert_to_half_all', - 'convert_to_half_katakana_all', - 'convert_to_wide_latin_all', - 'convert_to_latin_all', - - 'dict_admin', - 'add_word', - - 'start_setup', -] - -_config = { - 'common': { - 'input_mode': 0, - 'typing_method': 0, - 'conversion_segment_mode': 0, - - 'show-input-mode': True, - 'show-typing-method': False, - 'show-segment-mode': False, - 'show-dict-mode': True, - 'show-dict-config': False, - 'show-preferences': True, - - 'period_style': 0, - 'symbol_style': 1, - 'ten_key_mode': 1, - 'behavior_on_focus_out': 0, - 'behavior_on_period': 0, - 'trigger_periods': ',.、。,.', - - 'page_size': 10, - 'half_width_symbol': False, - 'half_width_number': False, - 'half_width_space': False, - 'latin_with_shift': True, - - 'shortcut_type': 'default', - - 'dict_admin_command': ['@KASUMI_EXEC_FILE@', 'kasumi'], - 'add_word_command': ['@KASUMI_EXEC_FILE@', 'kasumi', '-a'], - 'dict_config_icon': '@KASUMI_ICON_FILE@', - 'keyboard_layouts': [ - 'default', 'jp', 'us', - # XKB options requires ibus 1.5. - 'jp[ctrl:swapcaps]', 'us[ctrl:swapcaps]', - 'jp[ctrl:swapcaps,compose:rctrl]', - 'us[ctrl:swapcaps,compose:rctrl]', - 'jp[japan:kana_lock]', - 'jp[japan:nicola_f_bs]', - 'jp[japan:nicola_f_bs,ctrl:swapcaps]', - 'jp[japan:hztg_escape]', - 'jp[japan:hztg_escape,ctrl:swapcaps]', - ], - }, - - 'romaji_typing_rule': { - 'method': 'default', - # The newkeys list is saved for every romaji_typing_rule/$method - # so that prefs.get_value_direct() is not used. - # prefs.fetch_section() doesn't get the keys if they exist - # in gconf only. - 'newkeys': [], - }, - - ##0 MS-IME - # http://www.filibeto.org/sun/lib/solaris10-docs/E19253-01/819-7844/appe-1-4/index.html - ##1 ATOK - # http://www.filibeto.org/sun/lib/solaris10-docs/E19253-01/819-7844/appe-1-3/index.html - ##2 Gairaigo http://ja.wikipedia.org/wiki/%E5%A4%96%E6%9D%A5%E8%AA%9E - ##3 ANSI/BSI Suggestions http://en.wikipedia.org/wiki/Katakana - ##4 Historical kana http://en.wikipedia.org/wiki/Romanization_of_Japanese - # Maybe we need a compatibility between MS-IME and ibus-anthy. - 'romaji_typing_rule/default': { - 'minus' : 'ー', - 'a' : 'あ', - 'i' : 'い', - 'u' : 'う', - 'e' : 'え', - 'o' : 'お', - 'x-a' : 'ぁ', - 'x-i' : 'ぃ', - 'x-u' : 'ぅ', - 'x-e' : 'ぇ', - 'x-o' : 'ぉ', - 'l-a' : 'ぁ', - 'l-i' : 'ぃ', - 'l-u' : 'ぅ', - 'l-e' : 'ぇ', - 'l-o' : 'ぉ', - 'w-h-a' : 'うぁ', - 'w-h-i' : 'うぃ', - 'w-h-e' : 'うぇ', - 'w-h-o' : 'うぉ', - 'w-y-a' : 'うゃ', ##2 - 'w-y-u' : 'うゅ', ##2 - 'w-y-o' : 'うょ', ##2 - 'v-a' : 'ヴぁ', - 'v-i' : 'ヴぃ', - 'v-u' : 'ヴ', - 'v-e' : 'ヴぇ', - 'v-o' : 'ヴぉ', - 'v-y-a' : 'ヴゃ', ##2 - 'v-y-u' : 'ヴゅ', ##2 - 'v-y-e' : 'ヴぃぇ', ##2 - 'v-y-o' : 'ヴょ', ##2 - 'k-a' : 'か', - 'k-i' : 'き', - 'k-u' : 'く', - 'k-e' : 'け', - 'k-o' : 'こ', - 'l-k-a' : 'ヵ', - 'l-k-e' : 'ヶ', -# 'x-k-a' : 'ゕ', - 'x-k-a' : 'ヵ', -# 'x-k-e' : 'ゖ', - 'x-k-e' : 'ヶ', - 'g-a' : 'が', - 'g-i' : 'ぎ', - 'g-u' : 'ぐ', - 'g-e' : 'げ', - 'g-o' : 'ご', - 'k-y-a' : 'きゃ', - 'k-y-i' : 'きぃ', - 'k-y-u' : 'きゅ', - 'k-y-e' : 'きぇ', - 'k-y-o' : 'きょ', - 'k-w-a' : 'くぁ', - 'k-w-i' : 'くぃ', ##2 - 'k-w-u' : 'くぅ', ##2 - 'k-w-e' : 'くぇ', ##2 - 'k-w-o' : 'くぉ', ##2 - 'g-y-a' : 'ぎゃ', - 'g-y-i' : 'ぎぃ', - 'g-y-u' : 'ぎゅ', - 'g-y-e' : 'ぎぇ', - 'g-y-o' : 'ぎょ', - 'g-w-a' : 'ぐぁ', - 'g-w-i' : 'ぐぃ', ##2 - 'g-w-u' : 'ぐぅ', ##2 - 'g-w-e' : 'ぐぇ', ##2 - 'g-w-o' : 'ぐぉ', ##2 - 's-a' : 'さ', - 's-i' : 'し', - 's-u' : 'す', - 's-e' : 'せ', - 's-o' : 'そ', - 'z-a' : 'ざ', - 'z-i' : 'じ', - 'z-u' : 'ず', - 'z-e' : 'ぜ', - 'z-o' : 'ぞ', - 's-y-a' : 'しゃ', - 's-y-i' : 'しぃ', - 's-y-u' : 'しゅ', - 's-y-e' : 'しぇ', - 's-y-o' : 'しょ', - 's-h-a' : 'しゃ', - 's-h-i' : 'し', - 's-h-u' : 'しゅ', - 's-h-e' : 'しぇ', - 's-h-o' : 'しょ', - 'z-y-a' : 'じゃ', - 'z-y-i' : 'じぃ', - 'z-y-u' : 'じゅ', - 'z-y-e' : 'じぇ', - 'z-y-o' : 'じょ', - 'j-a' : 'じゃ', - 'j-y-a' : 'じゃ', - 'j-i' : 'じ', - 'j-y-i' : 'じぃ', - 'j-u' : 'じゅ', - 'j-y-u' : 'じゅ', - 'j-e' : 'じぇ', - 'j-y-e' : 'じぇ', - 'j-o' : 'じょ', - 'j-y-o' : 'じょ', - 's-w-i' : 'すぅぃ', ##2 - 's-w-e' : 'すぇ', ##2 - 'z-w-e' : 'ずぇ', ##2 - 't-a' : 'た', - 't-i' : 'ち', - 't-u' : 'つ', - 't-s-u' : 'つ', - 't-e' : 'て', - 't-o' : 'と', - 'd-a' : 'だ', - 'd-i' : 'ぢ', - 'd-u' : 'づ', - 'd-e' : 'で', - 'd-o' : 'ど', - 'x-t-u' : 'っ', - 'x-t-s-u' : 'っ', - 'l-t-u' : 'っ', - 'l-t-s-u' : 'っ', - 't-y-a' : 'ちゃ', - 't-y-i' : 'ちぃ', - 't-y-u' : 'ちゅ', - 't-y-e' : 'ちぇ', - 't-y-o' : 'ちょ', - 'c-y-a' : 'ちゃ', - 'c-y-i' : 'ちぃ', - 'c-y-u' : 'ちゅ', - 'c-y-e' : 'ちぇ', - 'c-y-o' : 'ちょ', - 'c-h-a' : 'ちゃ', - 'c-h-i' : 'ち', - 'c-h-u' : 'ちゅ', - 'c-h-e' : 'ちぇ', - 'c-h-o' : 'ちょ', - 'd-y-a' : 'ぢゃ', - 'd-y-i' : 'ぢぃ', - 'd-y-u' : 'ぢゅ', - 'd-y-e' : 'ぢぇ', - 'd-y-o' : 'ぢょ', - 't-s-a' : 'つぁ', - 't-s-i' : 'つぃ', - 't-s-e' : 'つぇ', - 't-s-o' : 'つぉ', - 't-s-y-a' : 'つゃ', ##3 - 't-s-y-u' : 'つゅ', ##3 - 't-s-y-e' : 'つぃぇ', ##3 - 't-s-y-o' : 'つょ', ##3 - 'd-z-a' : 'づぁ', ##3 - 'd-z-i' : 'づぃ', ##3 - 'd-z-u' : 'づ', ##4 - 'd-z-e' : 'づぇ', ##3 - 'd-z-o' : 'づぉ', ##3 - 'd-z-y-a' : 'づゃ', ##3 - 'd-z-y-u' : 'づゅ', ##3 - 'd-z-y-e' : 'づぃぇ', ##3 - 'd-z-y-o' : 'づょ', ##3 - 't-h-a' : 'てゃ', - 't-h-i' : 'てぃ', - 't-h-u' : 'てゅ', - 't-h-e' : 'てぇ', - 't-h-o' : 'てょ', - 't-w-u' : 'とぅ', - 'd-h-a' : 'でゃ', - 'd-h-i' : 'でぃ', - 'd-h-u' : 'でゅ', - 'd-h-e' : 'でぇ', - 'd-h-o' : 'でょ', - 'd-w-u' : 'どぅ', - 'n-a' : 'な', - 'n-i' : 'に', - 'n-u' : 'ぬ', - 'n-e' : 'ね', - 'n-o' : 'の', - 'n-y-a' : 'にゃ', - 'n-y-i' : 'にぃ', - 'n-y-u' : 'にゅ', - 'n-y-e' : 'にぇ', - 'n-y-o' : 'にょ', - 'h-a' : 'は', - 'h-i' : 'ひ', - 'h-u' : 'ふ', - 'h-e' : 'へ', - 'h-o' : 'ほ', - 'b-a' : 'ば', - 'b-i' : 'び', - 'b-u' : 'ぶ', - 'b-e' : 'べ', - 'b-o' : 'ぼ', - 'p-a' : 'ぱ', - 'p-i' : 'ぴ', - 'p-u' : 'ぷ', - 'p-e' : 'ぺ', - 'p-o' : 'ぽ', - 'h-y-a' : 'ひゃ', - 'h-y-i' : 'ひぃ', - 'h-y-u' : 'ひゅ', - 'h-y-e' : 'ひぇ', - 'h-y-o' : 'ひょ', - 'b-y-a' : 'びゃ', - 'b-y-i' : 'びぃ', - 'b-y-u' : 'びゅ', - 'b-y-e' : 'びぇ', - 'b-y-o' : 'びょ', - 'p-y-a' : 'ぴゃ', - 'p-y-i' : 'ぴぃ', - 'p-y-u' : 'ぴゅ', - 'p-y-e' : 'ぴぇ', - 'p-y-o' : 'ぴょ', - 'f-a' : 'ふぁ', - 'f-i' : 'ふぃ', - 'f-u' : 'ふ', - 'f-e' : 'ふぇ', - 'f-o' : 'ふぉ', - 'f-y-a' : 'ふゃ', - 'f-y-i' : 'ふぃ', - 'f-y-u' : 'ふゅ', - 'f-y-e' : 'ふぇ', - 'f-y-o' : 'ふょ', - 'b-w-a' : 'ぶぁ', ##2 - 'b-w-e' : 'ぶぇ', ##2 - 'b-w-o' : 'ぶぉ', ##2 - 'p-w-a' : 'ぷぁ', ##2 - 'p-w-e' : 'ぷぇ', ##2 - 'p-w-o' : 'ぷぉ', ##2 - 'm-a' : 'ま', - 'm-i' : 'み', - 'm-u' : 'む', - 'm-e' : 'め', - 'm-o' : 'も', - 'm-y-a' : 'みゃ', - 'm-y-i' : 'みぃ', - 'm-y-u' : 'みゅ', - 'm-y-e' : 'みぇ', - 'm-y-o' : 'みょ', - 'y-a' : 'や', - 'y-i' : 'い', - 'y-u' : 'ゆ', - 'y-e' : 'いぇ', - 'y-o' : 'よ', - 'l-y-a' : 'ゃ', - 'l-y-i' : 'ぃ', - 'l-y-u' : 'ゅ', - 'l-y-e' : 'ぇ', - 'l-y-o' : 'ょ', - 'x-y-a' : 'ゃ', - 'x-y-i' : 'ぃ', - 'x-y-u' : 'ゅ', - 'x-y-e' : 'ぇ', - 'x-y-o' : 'ょ', - 'r-a' : 'ら', - 'r-i' : 'り', - 'r-u' : 'る', - 'r-e' : 'れ', - 'r-o' : 'ろ', - 'r-y-a' : 'りゃ', - 'r-y-i' : 'りぃ', - 'r-y-u' : 'りゅ', - 'r-y-e' : 'りぇ', - 'r-y-o' : 'りょ', - 'w-a' : 'わ', - 'w-i' : 'うぃ', - 'w-u' : 'う', - 'w-e' : 'うぇ', - 'w-o' : 'を', - 'l-w-a' : 'ゎ', - 'x-w-a' : 'ゎ', - 'n-apostrophe' : 'ん', - 'n-n' : 'ん', - 'w-y-i' : 'ゐ', - 'w-y-e' : 'ゑ', - }, - - 'kana_typing_rule': { - 'method': 'jp', - 'newkeys': [], - }, - - 'kana_typing_rule/jp': { - # no modifiers keys - '1' : 'ぬ', - '2' : 'ふ', - '3' : 'あ', - '4' : 'う', - '5' : 'え', - '6' : 'お', - '7' : 'や', - '8' : 'ゆ', - '9' : 'よ', - '0' : 'わ', - 'minus' : 'ほ', - 'asciicircum' : 'へ', - - 'q' : 'た', - 'w' : 'て', - 'e' : 'い', - 'r' : 'す', - 't' : 'か', - 'y' : 'ん', - 'u' : 'な', - 'i' : 'に', - 'o' : 'ら', - 'p' : 'せ', - 'at' : '゛', - 'bracketleft' : '゜', - - 'a' : 'ち', - 's' : 'と', - 'd' : 'し', - 'f' : 'は', - 'g' : 'き', - 'h' : 'く', - 'j' : 'ま', - 'k' : 'の', - 'l' : 'り', - 'semicolon' : 'れ', - 'colon' : 'け', - 'bracketright' : 'む', - - 'z' : 'つ', - 'x' : 'さ', - 'c' : 'そ', - 'v' : 'ひ', - 'b' : 'こ', - 'n' : 'み', - 'm' : 'も', - 'comma' : 'ね', - 'period' : 'る', - 'slash' : 'め', - # 'backslash' : 'ー', - 'backslash' : 'ろ', - - # shift modifiered keys - 'exclam' : 'ぬ', - 'quotedbl' : 'ふ', - 'numbersign' : 'ぁ', - 'dollar' : 'ぅ', - 'percent' : 'ぇ', - 'ampersand' : 'ぉ', - 'apostrophe' : 'ゃ', - 'parenleft' : 'ゅ', - 'parenright' : 'ょ', - 'asciitilde' : 'を', - 'equal' : 'ゑ', - 'bar' : 'ー', - - 'largeq' : 'た', - 'largew' : 'て', - 'largee' : 'ぃ', - 'larger' : 'す', - 'larget' : 'ヵ', - 'largey' : 'ん', - 'largeu' : 'な', - 'largei' : 'に', - 'largeo' : 'ら', - 'largep' : 'せ', - 'grave' : '゛', - - 'braceleft' : '「', - - 'largea' : 'ち', - 'larges' : 'と', - 'larged' : 'し', - 'largef' : 'ゎ', - 'largeg' : 'き', - 'largeh' : 'く', - 'largej' : 'ま', - 'largek' : 'の', - 'largel' : 'り', - 'plus' : 'れ', - 'asterisk' : 'ヶ', - - 'braceright' : '」', - - 'largez' : 'っ', - 'largex' : 'さ', - 'largec' : 'そ', - 'largev' : 'ゐ', - 'largeb' : 'こ', - 'largen' : 'み', - 'largem' : 'も', - 'less' : '、', - 'greater' : '。', - - 'question' : '・', - 'underscore' : 'ろ', - - 'yen' : 'ー', - }, - - 'kana_typing_rule/us': { - # no modifiers keys - 'grave' : 'ろ', - '1' : 'ぬ', - '2' : 'ふ', - '3' : 'あ', - '4' : 'う', - '5' : 'え', - '6' : 'お', - '7' : 'や', - '8' : 'ゆ', - '9' : 'よ', - '0' : 'わ', - 'minus' : 'ほ', - 'equal' : 'へ', - - 'q' : 'た', - 'w' : 'て', - 'e' : 'い', - 'r' : 'す', - 't' : 'か', - 'y' : 'ん', - 'u' : 'な', - 'i' : 'に', - 'o' : 'ら', - 'p' : 'せ', - 'bracketleft' : '゛', - 'bracketright' : '゜', - # 'backslash' : 'ー', - 'backslash' : 'む', - - 'a' : 'ち', - 's' : 'と', - 'd' : 'し', - 'f' : 'は', - 'g' : 'き', - 'h' : 'く', - 'j' : 'ま', - 'k' : 'の', - 'l' : 'り', - 'semicolon' : 'れ', - 'apostrophe' : 'け', - - 'z' : 'つ', - 'x' : 'さ', - 'c' : 'そ', - 'v' : 'ひ', - 'b' : 'こ', - 'n' : 'み', - 'm' : 'も', - 'comma' : 'ね', - 'period' : 'る', - 'slash' : 'め', - - # shift modifiered keys - 'asciitilde' : 'ろ', - 'exclam' : 'ぬ', - 'at' : 'ふ', - 'numbersign' : 'ぁ', - 'dollar' : 'ぅ', - 'percent' : 'ぇ', - 'asciicircum' : 'ぉ', - 'ampersand' : 'ゃ', - 'asterisk' : 'ゅ', - 'parenleft' : 'ょ', - 'parenright' : 'を', - 'underscore' : 'ー', - 'plus' : 'ゑ', - - 'largeq' : 'た', - 'largew' : 'て', - 'largee' : 'ぃ', - 'larger' : 'す', - 'larget' : 'ヵ', - 'largey' : 'ん', - 'largeu' : 'な', - 'largei' : 'に', - 'largeo' : 'ら', - 'largep' : 'せ', - 'braceleft' : '「', - - 'braceright' : '」', - - 'bar' : 'む', - - 'largea' : 'ち', - 'larges' : 'と', - 'larged' : 'し', - 'largef' : 'ゎ', - 'largeg' : 'き', - 'largeh' : 'く', - 'largej' : 'ま', - 'largek' : 'の', - 'largel' : 'り', - 'colon' : 'れ', - 'quotedbl' : 'ヶ', - - 'largez' : 'っ', - 'largex' : 'さ', - 'largec' : 'そ', - 'largev' : 'ゐ', - 'largeb' : 'こ', - 'largen' : 'み', - 'largem' : 'も', - 'less' : '、', - 'greater' : '。', - - 'question' : '・', - }, - 'thumb': { - 'keyboard_layout_mode': True, - 'keyboard_layout': 0, - 'fmv_extension': 2, - 'handakuten': False, - 'rs': 'Henkan', - 'ls': 'Muhenkan', - 't1': 100, - 't2': 75, - }, - - 'thumb_typing_rule': { - 'method': 'base', - 'newkeys': [], - 'nicola_j_table_newkeys': [], - 'nicola_a_table_newkeys': [], - 'nicola_f_table_newkeys': [], - 'kb231_j_fmv_table_newkeys': [], - 'kb231_a_fmv_table_newkeys': [], - 'kb231_f_fmv_table_newkeys': [], - 'kb611_j_fmv_table_newkeys': [], - 'kb611_a_fmv_table_newkeys': [], - 'kb611_f_fmv_table_newkeys': [], - }, - - 'thumb_typing_rule/base': { - 'q' : [u'。', u'', u'ぁ'], - 'w' : [u'か', u'が', u'え'], - 'e' : [u'た', u'だ', u'り'], - 'r' : [u'こ', u'ご', u'ゃ'], - 't' : [u'さ', u'ざ', u'れ'], - - 'y' : [u'ら', u'よ', u'ぱ'], - 'u' : [u'ち', u'に', u'ぢ'], - 'i' : [u'く', u'る', u'ぐ'], - 'o' : [u'つ', u'ま', u'づ'], - 'p' : [u',', u'ぇ', u'ぴ'], - 'at' : [u'、', u'', u''], - 'bracketleft' : [u'゛', u'゜', u''], - - 'a' : [u'う', u'', u'を'], - 's' : [u'し', u'じ', u'あ'], - 'd' : [u'て', u'で', u'な'], - 'f' : [u'け', u'げ', u'ゅ'], - 'g' : [u'せ', u'ぜ', u'も'], - - 'h' : [u'は', u'み', u'ば'], - 'j' : [u'と', u'お', u'ど'], - 'k' : [u'き', u'の', u'ぎ'], - 'l' : [u'い', u'ょ', u'ぽ'], - 'semicolon' : [u'ん', u'っ', u''], - - 'z' : [u'.', u'', u'ぅ'], - 'x' : [u'ひ', u'び', u'ー'], - 'c' : [u'す', u'ず', u'ろ'], - 'v' : [u'ふ', u'ぶ', u'や'], - 'b' : [u'へ', u'べ', u'ぃ'], - - 'n' : [u'め', u'ぬ', u'ぷ'], - 'm' : [u'そ', u'ゆ', u'ぞ'], - 'comma' : [u'ね', u'む', u'ぺ'], - 'period' : [u'ほ', u'わ', u'ぼ'], - 'slash' : [u'・', u'ぉ', u''], - - '1' : [u'1', u'', u'?'], - '2' : [u'2', u'', u'/'], - '4' : [u'4', u'', u'「'], - '5' : [u'5', u'', u'」'], - - '6' : [u'6', u'[', u''], - '7' : [u'7', u']', u''], - '8' : [u'8', u'(', u''], - '9' : [u'9', u')', u''], - 'backslash' : [u'¥', u'', u''], - }, - - 'thumb_typing_rule/nicola_j_table': { - 'colon' : [u':', u'', u''], - 'at' : [u'、', u'', u''], - 'bracketleft' : [u'゛', u'゜', u''], - 'bracketright' : [u'」', u'', u''], - '8' : [u'8', u'(', u''], - '9' : [u'9', u')', u''], - '0' : [u'0', u'', u''], - }, - - 'thumb_typing_rule/nicola_a_table': { - 'colon' : [u':', u'', u''], - 'at' : [u'@', u'', u''], - 'bracketleft' : [u'、', u'', u''], - 'bracketright' : [u'゛', u'゜', u''], - '8' : [u'8', u'', u''], - '9' : [u'9', u'(', u''], - '0' : [u'0', u')', u''], - }, - - 'thumb_typing_rule/nicola_f_table': { - 'colon' : [u'、', u'', u''], - 'at' : [u'@', u'', u''], - 'bracketleft' : [u'゛', u'゜', u''], - 'bracketright' : [u'」', u'', u''], - '8' : [u'8', u'(', u''], - '9' : [u'9', u')', u''], - '0' : [u'0', u'', u''], - }, - - 'thumb_typing_rule/kb231_j_fmv_table': { - '3' : [u'3', u'', u'~'], - '0' : [u'0', u'『', u''], - 'minus' : [u'-', u'』', u''], - 'equal' : [u'=', u'', u''], - }, - - 'thumb_typing_rule/kb231_a_fmv_table': { - '3' : [u'3', u'', u'~'], - '0' : [u'0', u')', u''], - 'minus' : [u'-', u'『', u''], - 'equal' : [u'=', u'』', u''], - }, - - 'thumb_typing_rule/kb231_f_fmv_table': { - '3' : [u'3', u'', u'~'], - '0' : [u'0', u'『', u''], - 'minus' : [u'-', u'』', u''], - 'equal' : [u'=', u'', u''], - }, - - 'thumb_typing_rule/kb611_j_fmv_table': { - 'grave' : [u'‘', u'', u''], - 'asciicircum' : [u'々', u'£', u''], - 'colon' : [u':', u'', u''], - 'at' : [u'、', u'¢', u''], - 'bracketleft' : [u'゛', u'゜', u''], - # keysyms are same and keycodes depend on the platforms. - #'¥' : [u'¥', u'¬', u''], - 'backslash' : [u'¥', u'¦', u''], - }, - - 'thumb_typing_rule/kb611_a_fmv_table': { - 'grave' : [u'々', u'', u'£'], - 'colon' : [u':', u'', u''], - 'at' : [u'@', u'', u''], - 'bracketleft' : [u'、', u'¢', u''], - #'¥' : [u'¥', u'¬', u''], - 'backslash' : [u'¥', u'¦', u''], - }, - - 'thumb_typing_rule/kb611_f_fmv_table': { - 'grave' : [u'‘', u'', u''], - 'asciicircum' : [u'々', u'£', u''], - 'colon' : [u'、', u'¢', u''], - 'at' : [u'@', u'', u''], - 'bracketleft' : [u'゛', u'゜', u''], - #'¥' : [u'¥', u'¬', u''], - 'backslash' : [u'¥', u'¦', u''], - }, - - 'dict': { - 'zipcode': ['@pkgdatadir@/dicts/zipcode.t'], - 'symbol': ['@pkgdatadir@/dicts/symbol.t'], - 'oldchar': ['@pkgdatadir@/dicts/oldchar.t'], - 'era': ['@pkgdatadir@/dicts/era.t'], - 'emoji': ['@pkgdatadir@/dicts/emoji.t'], - 'files': [ - '@pkgdatadir@/dicts/zipcode.t', - '@pkgdatadir@/dicts/symbol.t', - '@pkgdatadir@/dicts/oldchar.t', - '@pkgdatadir@/dicts/era.t', - '@pkgdatadir@/dicts/emoji.t', - ], - }, - - 'dict/file/default': { - 'embed': False, - 'single': True, - 'icon': None, - 'short_label': None, - 'long_label': None, - 'preview_lines': 30, - 'reverse': False, - 'is_system': False, - 'encoding': 'utf-8', - }, - - 'dict/file/embedded': { - 'embed': True, - 'single': True, - 'icon': None, - 'short_label': '般', - 'long_label': N_("General"), - 'preview_lines': 0, - 'reverse': False, - 'is_system': True, - }, - - 'dict/file/zipcode': { - 'embed': False, - 'single': True, - 'icon': None, - 'short_label': '〒', - 'long_label': N_("Zip Code Conversion"), - 'preview_lines': -1, - 'reverse': False, - 'is_system': True, - }, - - 'dict/file/symbol': { - 'embed': True, - 'single': False, - 'icon': None, - 'short_label': '記', - 'long_label': N_("Symbol"), - 'preview_lines': -1, - 'reverse': False, - 'is_system': True, - }, - - 'dict/file/oldchar': { - 'embed': False, - 'single': True, - 'icon': None, - 'short_label': '旧', - 'long_label': N_("Old Character Style"), - 'preview_lines': -1, - 'reverse': False, - 'is_system': True, - }, - 'dict/file/era': { - 'embed': False, - 'single': True, - 'icon': None, - 'short_label': '年', - 'long_label': N_("Era"), - 'preview_lines': -1, - 'reverse': False, - 'is_system': True, - }, - 'dict/file/emoji': { - 'embed': False, - 'single': True, - 'icon': None, - 'short_label': '😊', - 'long_label': N_("Emoji"), - 'preview_lines': -1, - 'reverse': False, - 'is_system': True, - }, -} - -_shortcut_default = { - 'on_off': [@ON_OFF_KEYS@], - 'circle_input_mode': ['Ctrl+comma', 'Ctrl+less'], - # Removed Hiragana_Katakana key in circle_kana_mode for latin_with_shift. - 'circle_kana_mode': ['Ctrl+period', 'Ctrl+greater'], -# 'cancel_pseudo_ascii_mode_key': ['Escape'], - 'circle_typing_method': ['Alt+Romaji', 'Ctrl+slash'], - 'circle_dict_method': ['Alt+Henkan'], - - 'insert_space': ['space'], - 'insert_alternate_space': ['Shift+space'], - 'backspace': ['BackSpace', 'Ctrl+H'], - 'delete': ['Delete', 'Ctrl+D'], - 'commit': ['Return', 'KP_Enter', 'Ctrl+J', 'Ctrl+M'], - 'convert': ['space', 'KP_Space', 'Henkan'], - 'predict': ['Tab', 'ISO_Left_Tab'], - 'cancel': ['Escape', 'Ctrl+G'], - 'reconvert': ['Shift+Henkan'], - - 'move_caret_first': ['Ctrl+A', 'Home'], - 'move_caret_last': ['Ctrl+E', 'End'], - 'move_caret_forward': ['Right', 'Ctrl+F'], - 'move_caret_backward': ['Left', 'Ctrl+B'], - - 'select_first_segment': ['Ctrl+A', 'Home'], - 'select_last_segment': ['Ctrl+E', 'End'], - 'select_next_segment': ['Right', 'Ctrl+F'], - 'select_prev_segment': ['Left', 'Ctrl+B'], - 'shrink_segment': ['Shift+Left', 'Ctrl+I'], - 'expand_segment': ['Shift+Right', 'Ctrl+O'], - 'commit_first_segment': ['Shift+Down'], - 'commit_selected_segment': ['Ctrl+Down'], - - 'select_first_candidate': ['Home'], - 'select_last_candidate': ['End'], - 'select_next_candidate': ['space', 'KP_Space', 'Tab', 'ISO_Left_Tab', 'Henkan', 'Down', 'KP_Add', 'Ctrl+N'], - 'select_prev_candidate': ['Shift+Tab', 'Shift+ISO_Left_Tab', 'Up', 'KP_Subtract', 'Ctrl+P'], - 'candidates_page_up': ['Page_Up'], - 'candidates_page_down': ['Page_Down', 'KP_Tab'], - - '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_char_type_forward': ['Muhenkan'], - 'convert_to_hiragana': ['F6'], - 'convert_to_katakana': ['F7'], - 'convert_to_half': ['F8'], - 'convert_to_half_katakana': ['Shift+F8'], - 'convert_to_wide_latin': ['F9'], - 'convert_to_latin': ['F10'], - 'convert_to_hiragana_all': ['Shift+F6'], - 'convert_to_katakana_all': ['Shift+F7'], - 'convert_to_wide_latin_all': ['Shift+F9'], - 'convert_to_latin_all': ['Shift+F10'], - - 'dict_admin': ['F11'], - 'add_word': ['F12'], - - 'hiragana_for_latin_with_shift': ['Hiragana_Katakana'], -} - -_config['shortcut/default'] = dict.fromkeys(_cmd_keys, []) -_config['shortcut/default'].update(_shortcut_default) - -_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'], - 'circle_dict_method': ['Alt+Henkan'], - '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', 'Ctrl+N'], - - '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'], - 'convert_to_hiragana_all': ['Shift+F6'], - 'convert_to_katakana_all': ['Shift+F7'], - 'convert_to_wide_latin_all': ['Shift+F9'], - 'convert_to_latin_all': ['Shift+F10'], - - 'dict_admin': ['F11'], - 'add_word': ['Ctrl+F7'], - - 'hiragana_for_latin_with_shift': ['Ctrl+J'], -} - -_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'], - 'circle_dict_method': ['Alt+Henkan'], - - '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'], - 'convert_to_hiragana_all': ['Shift+F6'], - 'convert_to_katakana_all': ['Shift+F7'], - 'convert_to_half_all': ['Shift+F8'], - 'convert_to_wide_latin_all': ['Shift+F9'], - 'convert_to_latin_all': ['Shift+F10'], - - 'dict_admin': ['F11'], - 'add_word': ['F12'], - - 'hiragana_for_latin_with_shift': ['Hiragana_Katakana'], -} - -_config['shortcut/wnn'] = dict.fromkeys(_cmd_keys, []) -_config['shortcut/wnn'].update(_shortcut_wnn) - diff --git a/setup/python2/main.py b/setup/python2/main.py index c49a9cc..1fb5a67 100644 --- a/setup/python2/main.py +++ b/setup/python2/main.py @@ -4,8 +4,8 @@ # # Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> # Copyright (c) 2009 Hideaki ABE <abe.sendai@gmail.com> -# Copyright (c) 2010-2016 Takao Fujiwara <takao.fujiwara1@gmail.com> -# Copyright (c) 2007-2016 Red Hat, Inc. +# Copyright (c) 2010-2017 Takao Fujiwara <takao.fujiwara1@gmail.com> +# Copyright (c) 2007-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ import gettext from gettext import dgettext from gi import require_version as gi_require_version +gi_require_version('Gio', '2.0') gi_require_version('GLib', '2.0') gi_require_version('Gtk', '3.0') gi_require_version('Gdk', '3.0') @@ -36,6 +37,7 @@ gi_require_version('GdkX11', '3.0') gi_require_version('Pango', '1.0') gi_require_version('IBus', '1.0') +from gi.repository import Gio from gi.repository import GLib # set_prgname before importing other modules to show the name in warning @@ -73,16 +75,7 @@ class AnthySetup(object): gettext.bindtextdomain(DOMAINNAME, config.LOCALEDIR) gettext.bind_textdomain_codeset(DOMAINNAME, 'UTF-8') - # IBus.Bus() calls ibus_bus_new(). - # Gtk.Builder().add_from_file() also calls ibus_bus_new_async() - # via ibus_im_context_new(). - # Then if IBus.Bus() is called after Gtk.Builder().add_from_file(), - # the connection delay would be happened without an async - # finish function. - ibus_address = IBus.get_address() - bus = None - if ibus_address != None: - bus = IBus.Bus(connect_async='True') + self.__prefs = AnthyPrefs() builder_file = path.join(path.dirname(__file__), 'setup.ui') self.__builder = builder = Gtk.Builder() @@ -126,27 +119,15 @@ class AnthySetup(object): toplevel.connect('notify::window', set_transient) toplevel.show() + self.__init_bus_connected() - if ibus_address == None: - builder.connect_signals(self) - # self.__run_message_dialog needs self.__builder. - self.__run_message_dialog(_("ibus is not running."), - Gtk.MessageType.ERROR) - return - - if bus.is_connected(): - self.__init_bus_connected(bus) - else: - bus.connect('connected', self.__init_bus_connected) - - def __init_bus_connected(self, bus): - self.__config = bus.get_config() + def __init_bus_connected(self): builder = self.__builder + prefs = self.__prefs self.__thumb_kb_layout_mode = None self.__thumb_kb_layout = None self.__japanese_ordered_dict = {} - self.prefs = prefs = AnthyPrefs(None, self.__config) # glade 'icon_name' property has a custom scaling and it seems # to be difficult to show the complicated small icon in metacity. @@ -161,17 +142,25 @@ class AnthySetup(object): icon_path = 'ibus-anthy' builder.get_object('main').set_icon_name(icon_path) - for name in ['input_mode', 'typing_method', 'conversion_segment_mode', - 'period_style', 'symbol_style', 'ten_key_mode', - 'behavior_on_focus_out', 'behavior_on_period', - 'half_width_symbol', 'half_width_number', 'half_width_space', - 'latin_with_shift', - 'thumb:keyboard_layout_mode', 'thumb:keyboard_layout', - 'thumb:fmv_extension', 'thumb:handakuten']: + for name in ['input-mode', 'typing-method', 'conversion-segment-mode', + 'period-style', 'symbol-style', 'ten-key-mode', + 'behavior-on-focus-out', 'behavior-on-period', + 'half-width-symbol', 'half-width-number', 'half-width-space', + 'latin-with-shift', + 'thumb:keyboard-layout-mode', 'thumb:keyboard-layout', + 'thumb:fmv-extension', 'thumb:handakuten']: section, key = self.__get_section_key(name) - builder.get_object(name).set_active(prefs.get_value(section, key)) + prefs.bind(section, key, + builder.get_object(name), + 'active', + Gio.SettingsBindFlags.DEFAULT) + + prefs.bind('thumb', 'keyboard-layout-mode', + builder.get_object('thumb:keyboard-layout'), + 'sensitive', + Gio.SettingsBindFlags.INVERT_BOOLEAN) - tv = builder.get_object('menu_visible:treeview') + tv = builder.get_object('menu-visible:treeview') ls = Gtk.ListStore(str, bool, str) tv.set_model(ls) @@ -196,12 +185,14 @@ class AnthySetup(object): self.__append_menus_in_model() l = ['default', 'atok', 'wnn'] - s_type = prefs.get_value('common', 'shortcut_type') + s_type = prefs.get_value('common', 'shortcut-type') s_type = s_type if s_type in l else 'default' - builder.get_object('shortcut_type').set_active(l.index(s_type)) + builder.get_object('shortcut-type').set_active(l.index(s_type)) - builder.get_object('page_size').set_value(prefs.get_value('common', - 'page_size')) + prefs.bind('common', 'page-size', + builder.get_object('page-size').get_adjustment(), + 'value', + Gio.SettingsBindFlags.DEFAULT) tv = builder.get_object('shortcut') tv.append_column(Gtk.TreeViewColumn(_("Command"), @@ -213,17 +204,17 @@ class AnthySetup(object): tv.get_selection().connect_after('changed', self.on_selection_changed, 0) ls = Gtk.ListStore(str, str) - sec = 'shortcut/' + s_type - for k in self.prefs.keys(sec): - ls.append([k, l_to_s(self.prefs.get_value(sec, k))]) + shortcuts = self.__prefs.get_value('shortcut', s_type) + for k in shortcuts.keys(): + ls.append([k, l_to_s(shortcuts[k])]) tv.set_model(ls) self.__keymap = None GLib.idle_add(self.__update_keymap_label, priority = GLib.PRIORITY_LOW) - self.__thumb_kb_layout_mode = builder.get_object('thumb:keyboard_layout_mode') - self.__thumb_kb_layout = builder.get_object('thumb:keyboard_layout') + self.__thumb_kb_layout_mode = builder.get_object('thumb:keyboard-layout-mode') + self.__thumb_kb_layout = builder.get_object('thumb:keyboard-layout') self.__set_thumb_kb_label() for name in ['thumb:ls', 'thumb:rs']: @@ -236,13 +227,13 @@ class AnthySetup(object): self.on_selection_changed, 1) tv.set_model(Gtk.ListStore(str)) - key = 'dict_admin_command' + key = 'dict-admin-command' cli = self.__get_dict_cli_from_list(prefs.get_value('common', key)) - name = 'dict:entry_edit_dict_command' + name = 'dict:entry-edit-dict-command' builder.get_object(name).set_text(cli) - key = 'add_word_command' + key = 'add-word-command' cli = self.__get_dict_cli_from_list(prefs.get_value('common', key)) - name = 'dict:entry_add_word_command' + name = 'dict:entry-add-word-command' builder.get_object(name).set_text(cli) tv = builder.get_object('dict:view') @@ -298,7 +289,7 @@ class AnthySetup(object): def __init_japanese_sort(self): japanese_ordered_dict = {} - japanese_ordered_list = self.prefs.get_japanese_ordered_list() + japanese_ordered_list = self.__prefs.get_japanese_ordered_list() for index, c in enumerate(japanese_ordered_list): japanese_ordered_dict[c] = index self.__japanese_ordered_dict = japanese_ordered_dict; @@ -306,7 +297,7 @@ class AnthySetup(object): def __init_about_vbox(self, icon_path): about_dialog = self.__builder.get_object('about_dialog') about_vbox = self.__builder.get_object('about_vbox') - about_dialog.set_version(self.prefs.get_version()) + about_dialog.set_version(self.__prefs.get_version()) if icon_path != None: if icon_path[0] == '/': image = Gtk.Image.new_from_file(icon_path) @@ -356,6 +347,20 @@ class AnthySetup(object): dlg.run() dlg.destroy() + def _get_shortcut_sec(self): + l = ['default', 'atok', 'wnn'] + iter = self.__builder.get_object('shortcut-type').get_active_iter() + model = self.__builder.get_object('shortcut-type').get_model() + s_type = model[iter][0].lower() + return 'shortcut/' + (s_type if s_type in l else 'default') + + def __get_shortcut_group(self): + l = ['default', 'atok', 'wnn'] + iter = self.__builder.get_object('shortcut-type').get_active_iter() + model = self.__builder.get_object('shortcut-type').get_model() + s_type = model[iter][0].lower() + return s_type if s_type in l else 'default' + def __japanese_tuple_sort(self, a, b): if a[1] == b[1]: return cmp(a[0], b[0]) @@ -376,26 +381,25 @@ class AnthySetup(object): return cmp(a[0], b[0]) def __renderer_toggled_cb(self, renderer, path, model): - prefs = self.prefs + prefs = self.__prefs enabled = not model[path][1] model[path][1] = enabled key = model[path][0] prefs.set_value('common', key, enabled) - self.__builder.get_object('btn_apply').set_sensitive(True) def __toggle_menu_visible_cell_cb(self, column, renderer, model, iter, id): - l = self.__builder.get_object('menu_visible:treeview').get_model() + l = self.__builder.get_object('menu-visible:treeview').get_model() active = l.get_value(iter, id) renderer.set_property('active', active) def __text_menu_visible_cell_cb(self, column, renderer, model, iter, id): - l = self.__builder.get_object('menu_visible:treeview').get_model() + l = self.__builder.get_object('menu-visible:treeview').get_model() text = l.get_value(iter, id) renderer.set_property('text', text) def __append_menus_in_model(self): - prefs = self.prefs - l = self.__builder.get_object('menu_visible:treeview').get_model() + prefs = self.__prefs + l = self.__builder.get_object('menu-visible:treeview').get_model() l.append(['show-input-mode', prefs.get_value('common', 'show-input-mode'), _("Input mode")]) @@ -416,30 +420,20 @@ class AnthySetup(object): _("Preferences - Anthy")]) def __get_romaji_treeview_custom_key_table(self, method): - prefs = self.prefs + prefs = self.__prefs rule = {} ls = Gtk.ListStore(str, str, str) tv = self.__builder.get_object('treeview_custom_key_table') - section_base = 'romaji_typing_rule' - section = section_base + '/' + prefs.str(method) - for key in prefs.keys(section): - key = prefs.str(key) - value = prefs.get_value(section, key) + section = 'romaji-typing-rule' + keymap = prefs.get_value(section, 'list')[method] + for key in keymap.keys(): + value = keymap[key] ch = prefs.typing_from_config_key(key) if ch == '': continue # config.set_value(key, None) is not supported. if value != None and value != '': - rule[ch] = prefs.str(value) - for key in prefs.get_value(section_base, 'newkeys'): - key = prefs.str(key) - value = self.prefs.get_value_direct(section, key) - ch = prefs.typing_from_config_key(key) - if ch == '': - continue - # config.set_value(key, None) is not supported. - if value != None and value != '': - rule[ch] = prefs.str(value) + rule[ch] = value for key, value in sorted(rule.items(), \ cmp = self.__japanese_tuple_sort): ls.append(['romaji', key, value]) @@ -452,30 +446,20 @@ class AnthySetup(object): return tv def __get_kana_treeview_custom_key_table(self, method): - prefs = self.prefs + prefs = self.__prefs rule = {} ls = Gtk.ListStore(str, str, str) tv = self.__builder.get_object('treeview_custom_key_table') - section_base = 'kana_typing_rule' - section = section_base + '/' + prefs.str(method) - for key in prefs.keys(section): - key = prefs.str(key) - value = prefs.get_value(section, key) + section = 'kana-typing-rule' + keymap = prefs.get_value(section, 'list')[method] + for key in keymap.keys(): + value = keymap[key] ch = prefs.typing_from_config_key(key) if ch == '': continue # config.set_value(key, None) is not supported. if value != None and value != '': - rule[ch] = prefs.str(value) - for key in prefs.get_value(section_base, 'newkeys'): - key = prefs.str(key) - value = self.prefs.get_value_direct(section, key) - ch = prefs.typing_from_config_key(key) - if ch == '': - continue - # config.set_value(key, None) is not supported. - if value != None and value != '': - rule[ch] = prefs.str(value) + rule[ch] = value for key, value in sorted(rule.items(), \ cmp = self.__japanese_tuple_sort): ls.append(['kana', key, value]) @@ -488,30 +472,14 @@ class AnthySetup(object): return tv def __get_thumb_treeview_custom_key_table(self, method): - prefs = self.prefs + prefs = self.__prefs rule = {} ls = Gtk.ListStore(str, str, str, str, str) tv = self.__builder.get_object('treeview_custom_key_table') - section_base = 'thumb_typing_rule' - section = section_base + '/' + prefs.str(method) - for key in prefs.keys(section): - key = prefs.str(key) - value = prefs.get_value(section, key) - ch = prefs.typing_from_config_key(key) - if ch == '': - continue - # config.set_value(key, None) is not supported. - if value != None and len(value) == 3 and \ - ((value[0] != None and value[0] != '') or \ - (value[1] != None and value[1] != '') or \ - (value[2] != None and value[2] != '')): - rule[ch] = {} - rule[ch][0] = prefs.str(value[0]) - rule[ch][1] = prefs.str(value[1]) - rule[ch][2] = prefs.str(value[2]) - for key in prefs.get_value(section_base, 'newkeys'): - key = prefs.str(key) - value = self.prefs.get_value_direct(section, key) + section = 'thumb-typing-rule' + keymap = prefs.get_value(section, 'list')[method] + for key in keymap.keys(): + value = keymap[key] ch = prefs.typing_from_config_key(key) if ch == '': continue @@ -521,9 +489,9 @@ class AnthySetup(object): (value[1] != None and value[1] != '') or \ (value[2] != None and value[2] != '')): rule[ch] = {} - rule[ch][0] = prefs.str(value[0]) - rule[ch][1] = prefs.str(value[1]) - rule[ch][2] = prefs.str(value[2]) + rule[ch][0] = value[0] + rule[ch][1] = value[1] + rule[ch][2] = value[2] for key, value in sorted(rule.items(), \ cmp = self.__japanese_thumb_sort): ls.append(['thumb', key, value[0], value[2], value[1]]) @@ -609,7 +577,7 @@ class AnthySetup(object): combobox.disconnect_by_func(self.on_cb_custom_key_table_changed) def __run_dialog_custom_key_table(self, widget, mode): - prefs = self.prefs + prefs = self.__prefs dlg = self.__builder.get_object('dialog_custom_key_table') dlg.set_transient_for(widget.get_toplevel()) label = self.__builder.get_object('label_custom_key_table') @@ -633,15 +601,15 @@ class AnthySetup(object): label.set_label(_("_Thumb Shift Key Table:")) label_output.set_label(_("Single _Output Chars")) list_labels = [['base', _("Base")], - ['nicola_j_table', _("NICOLA-J key extension")], - ['nicola_a_table', _("NICOLA-A key extension")], - ['nicola_f_table', _("NICOLA-F key extension")], - ['kb231_j_fmv_table', _("FMV KB231-J key extension")], - ['kb231_a_fmv_table', _("FMV KB231-A key extension")], - ['kb231_f_fmv_table', _("FMV KB231-F key extension")], - ['kb611_j_fmv_table', _("FMV KB611-J key extension")], - ['kb611_a_fmv_table', _("FMV KB611-A key extension")], - ['kb611_f_fmv_table', _("FMV KB611-F key extension")], + ['nicola-j-table', _("NICOLA-J key extension")], + ['nicola-a-table', _("NICOLA-A key extension")], + ['nicola-f-table', _("NICOLA-F key extension")], + ['kb231-j-fmv-table', _("FMV KB231-J key extension")], + ['kb231-a-fmv-table', _("FMV KB231-A key extension")], + ['kb231-f-fmv-table', _("FMV KB231-F key extension")], + ['kb611-j-fmv-table', _("FMV KB611-J key extension")], + ['kb611-a-fmv-table', _("FMV KB611-A key extension")], + ['kb611-f-fmv-table', _("FMV KB611-F key extension")], ] self.__show_dialog_custom_key_table_extention(mode) ls = Gtk.ListStore(str, str) @@ -655,17 +623,17 @@ class AnthySetup(object): tv = None if mode == 'romaji': - method = prefs.get_value('romaji_typing_rule', 'method') + method = prefs.get_value('romaji-typing-rule', 'method') if method == None: method = 'default' tv = self.__get_romaji_treeview_custom_key_table(method) if mode == 'kana': - method = prefs.get_value('kana_typing_rule', 'method') + method = prefs.get_value('kana-typing-rule', 'method') if method == None: method = 'jp' tv = self.__get_kana_treeview_custom_key_table(method) if mode == 'thumb': - method = prefs.get_value('thumb_typing_rule', 'method') + method = prefs.get_value('thumb-typing-rule', 'method') if method == None: method = 'base' tv = self.__get_thumb_treeview_custom_key_table(method) @@ -675,10 +643,15 @@ class AnthySetup(object): id = 0 # thumb uses all tables so the default is always 0. if mode != 'thumb': + id = -1 for index, labels in enumerate(list_labels): if labels[0] == method: id = index break + if id == -1: + ls.append([method, method]) + combobox.set_model(ls) + id = len(list_labels) combobox.set_active(id) combobox.connect('changed', self.on_cb_custom_key_table_changed, mode) @@ -693,7 +666,7 @@ class AnthySetup(object): return section, key = self.__get_section_key( Gtk.Buildable.get_name(self.__thumb_kb_layout_mode)) - layout_mode = self.prefs.get_value(section, key) + layout_mode = self.__prefs.get_value(section, key) if layout_mode: self.__thumb_kb_layout.set_sensitive(False) else: @@ -730,60 +703,52 @@ class AnthySetup(object): return id def __get_dict_file_from_id(self, selected_id): - files = self.prefs.get_value('dict', 'files') - retval = None - - for file in files: - id = self.__get_quoted_id(file) - # The selected_id is already quoted. - if selected_id == id: - retval = file - break - return retval + files = self.__prefs.get_value('dict', 'files') + return files.get(selected_id, None) def __is_system_dict_file_from_id(self, selected_id): - prefs = self.prefs - section = 'dict/file/' + selected_id - key = 'is_system' - - if key not in prefs.keys(section): - return False - return prefs.get_value(section, key) + prefs = self.__prefs + dict_item = prefs.get_value('dict', 'list')[selected_id] + return dict_item.is_system - def __append_dict_id_in_model(self, id, is_gettext): - prefs = self.prefs + def __append_dict_id_in_model(self, id): + prefs = self.__prefs section = 'dict/file/' + id - # user value is dbus.String - prefs.set_value(section, 'short_label', - prefs.str(prefs.get_value(section, 'short_label'))) - prefs.set_value(section, 'long_label', - prefs.str(prefs.get_value(section, 'long_label'))) - short_label = prefs.get_value(section, 'short_label') - long_label = prefs.get_value(section, 'long_label') - embed = prefs.get_value(section, 'embed') - single = prefs.get_value(section, 'single') - reverse = prefs.get_value(section, 'reverse') - if is_gettext: + dicts = prefs.get_value('dict', 'list') + dict_item = dicts[id] + short_label = dict_item.short_label + long_label = dict_item.long_label + embed = dict_item.embed + single = dict_item.single + reverse = dict_item.reverse + if dict_item.is_system: long_label = _(long_label) l = self.__builder.get_object('dict:view').get_model() l.append([id, short_label, long_label, embed, single, reverse]) def __append_dicts_in_model(self): - prefs = self.prefs - for file in prefs.get_value('dict', 'files'): - if not path.exists(file): + prefs = self.__prefs + order = prefs.get_value('dict', 'order') + dict_files = prefs.get_value('dict', 'files') + if len(order) == 0: + order = list(dict_files.keys()) + for id in order: + if id == 'embedded': continue - id = self.__get_quoted_id(file) - section = 'dict/file/' + id - if section not in prefs.sections(): - self.__fetch_dict_values(section) - is_system_dict = self.__is_system_dict_file_from_id(id) - self.__append_dict_id_in_model(id, is_system_dict) + files = dict_files[id] + for file in files: + if not path.exists(file): + continue + self.__append_dict_id_in_model(id) def __append_user_dict_from_dialog(self, file, id, new): - files = self.prefs.get_value('dict', 'files') + files_dict = self.__prefs.get_value('dict', 'files') if new: + files = [] + for v in files_dict.values(): + for f in v: + files.append(f) if file in files: self.__run_message_dialog(_("Your choosed file has already been added: ") + file, Gtk.MessageType.ERROR) @@ -800,6 +765,8 @@ class AnthySetup(object): self.__run_message_dialog(_("You cannot add dictionaries in the anthy private directory: " + file), Gtk.MessageType.ERROR) return + else: + file = files_dict[id][0] if new: id = self.__get_quoted_id(file) @@ -817,15 +784,23 @@ class AnthySetup(object): long_label = self.__builder.get_object('dict:long_entry').get_text() if new: - files.append(file) - self.prefs.set_value('dict', 'files', files) - + order = self.__prefs.get_value('dict', 'order') + if len(order) == 0: + order = list(self.__prefs.get_value('dict', 'files').keys()) + order.append(id) + self.__prefs.set_value('dict', 'order', order) + self.__prefs.set_list_item('dict', 'files', id, [file]) + + filename = file + if filename.find('/') >=0: + filename = filename[filename.rindex('/') + 1:] + if filename.find('.') >=0: + filname = filename[:filename.rindex('.')] if short_label == None or short_label == '': - short_label = id[0] + short_label = filename[0] if long_label == None or long_label == '': - long_label = id + long_label = filename self.__update_dict_values(new, id, short_label, long_label, embed, single, reverse) - self.__builder.get_object('btn_apply').set_sensitive(True) files = [] def __init_dict_chooser_dialog(self): @@ -851,18 +826,16 @@ class AnthySetup(object): if selected_id == None: return None - is_system_dict = self.__is_system_dict_file_from_id(selected_id) - - prefs = self.prefs - section = 'dict/file/' + selected_id - short_label = prefs.get_value(section, 'short_label') - long_label = prefs.get_value(section, 'long_label') - embed = prefs.get_value(section, 'embed') - single = prefs.get_value(section, 'single') - reverse = prefs.get_value(section, 'reverse') + dict_item = self.__prefs.get_value('dict', 'list')[selected_id] + short_label = dict_item.short_label + long_label = dict_item.long_label + embed = dict_item.embed + single = dict_item.single + reverse = dict_item.reverse + is_system_dict = dict_item.is_system - if len(prefs.unicode(short_label)) > 1: - short_label = prefs.unicode(short_label)[0].encode('utf-8') + if len(self.__prefs.unicode(short_label)) > 1: + short_label = self.__prefs.unicode(short_label)[0].encode('utf-8') self.__builder.get_object('dict:single').set_active(single) self.__builder.get_object('dict:embed').set_active(embed) self.__builder.get_object('dict:reverse').set_active(reverse) @@ -880,56 +853,32 @@ class AnthySetup(object): return selected_id - def __fetch_dict_values(self, section): - prefs = self.prefs - prefs.set_new_section(section) - prefs.set_new_key(section, 'short_label') - prefs.fetch_item(section, 'short_label') - # user value is dbus.String - prefs.set_value(section, 'short_label', - prefs.str(prefs.get_value(section, 'short_label'))) - prefs.set_new_key(section, 'long_label') - prefs.fetch_item(section, 'long_label') - prefs.set_value(section, 'long_label', - prefs.str(prefs.get_value(section, 'long_label'))) - prefs.set_new_key(section, 'embed') - prefs.fetch_item(section, 'embed') - prefs.set_new_key(section, 'single') - prefs.fetch_item(section, 'single') - prefs.set_new_key(section, 'reverse') - prefs.fetch_item(section, 'reverse') - def __update_dict_values(self, new, id, short_label, long_label, embed, single, reverse): - prefs = self.prefs - section = 'dict/file/' + id - if section not in prefs.sections(): - prefs.set_new_section(section) - - is_system_dict = self.__is_system_dict_file_from_id(id) - if is_system_dict: - if 'short_label' in prefs.keys(section): - short_label = prefs.get_value(section, 'short_label') - if 'long_label' in prefs.keys(section): - long_label = prefs.get_value(section, 'long_label') + prefs = self.__prefs if new: + dict_item = prefs.get_value('dict', 'template') + dict_item.id = id + dict_item.short_label = short_label + dict_item.long_label = long_label + dict_item.embed = embed + dict_item.single = single + dict_item.reverse = reverse l = self.__builder.get_object('dict:view').get_model() l.append([id, short_label, long_label, embed, single, reverse]) else: + dict_item = prefs.get_value('dict', 'list')[id] + if not dict_item.is_system: + dict_item.short_label = short_label + dict_item.long_label = long_label + dict_item.embed = embed + dict_item.single = single + dict_item.reverse = reverse l, i = self.__builder.get_object('dict:view').get_selection().get_selected() if i : l[i] = [id, short_label, long_label, embed, single, reverse] - key = 'short_label' - prefs.set_value(section, key, short_label) - key = 'long_label' - prefs.set_value(section, key, long_label) - key = 'embed' - prefs.set_value(section, key, embed) - key = 'single' - prefs.set_value(section, key, single) - key = 'reverse' - prefs.set_value(section, key, reverse) + prefs.set_list_item('dict', 'list', id, dict_item) def __text_cell_data_cb(self, column, renderer, model, iter, id): l = self.__builder.get_object('dict:view').get_model() @@ -1104,13 +1053,13 @@ class AnthySetup(object): def __update_keymap_label(self): self.__resync_engine_file() - prefs = self.prefs + prefs = self.__prefs keymap = self.__get_keymap() if keymap == None: return if keymap == '': keymap = 'default' - keymap_list = prefs.get_value('common', 'keyboard_layouts') + keymap_list = prefs.get_value('common', 'keyboard-layouts') if keymap != None and not keymap in keymap_list: keymap_list.append(keymap) index = -1 @@ -1130,11 +1079,6 @@ class AnthySetup(object): self.on_cb_keymap_changed, 0) - def __save_preferences(self): - self.prefs.commit_all() - if self.__keymap != None: - self.__save_keymap() - def __search_and_mark(self, buffer, text, start, end, onetime, forward): if forward: match = start.forward_search(text, 0, end) @@ -1217,51 +1161,12 @@ class AnthySetup(object): button = self.__builder.get_object('button_remove_custom_key') button.set_sensitive(True) - def on_main_delete(self, widget, event): - self.on_btn_cancel_clicked(widget) + def on_main_quit(self, widget, event): + Gtk.main_quit() return True - def on_btn_ok_clicked(self, widget): - if self.__builder.get_object('btn_apply').get_state() == \ - Gtk.StateType.INSENSITIVE: - Gtk.main_quit() - return True - dlg = self.__builder.get_object('quit_check') - dlg.set_transient_for(widget.get_toplevel()) - dlg.set_markup('<big><b>%s</b></big>' % _("Confirmation")) - dlg.format_secondary_text( - _("You are about to close the setup dialog, is that OK?")) - id = dlg.run() - dlg.hide() - if id == Gtk.ResponseType.YES: - self.__save_preferences() - Gtk.main_quit() - return True - - def on_btn_cancel_clicked(self, widget): - if self.__builder.get_object('btn_apply').get_state() == \ - Gtk.StateType.INSENSITIVE: - Gtk.main_quit() - return True - dlg = self.__builder.get_object('quit_check_without_save') - dlg.set_transient_for(widget.get_toplevel()) - dlg.set_markup('<big><b>%s</b></big>' % _("Notice!")) - dlg.format_secondary_text( - _("You are about to close the setup dialog without saving your changes, is that OK?")) - id = dlg.run() - dlg.hide() - if id == Gtk.ResponseType.YES: - Gtk.main_quit() - return True - - def on_btn_apply_clicked(self, widget): - self.__save_preferences() - widget.set_sensitive(False) - - def on_cb_changed(self, widget): - section, key = self.__get_section_key(Gtk.Buildable.get_name(widget)) - self.prefs.set_value(section, key, widget.get_active()) - self.__builder.get_object('btn_apply').set_sensitive(True) + def on_btn_close_clicked(self, widget): + Gtk.main_quit() def on_cb_keymap_changed(self, widget, id): it = widget.get_active() @@ -1272,10 +1177,11 @@ class AnthySetup(object): if self.__keymap == keymap: return self.__keymap = keymap - self.__builder.get_object('btn_apply').set_sensitive(True) + self.__save_keymap() + self.__keymap = None def on_cb_custom_key_table_changed(self, widget, user_data): - prefs = self.prefs + prefs = self.__prefs tv = self.__builder.get_object('treeview_custom_key_table') mode = user_data id = widget.get_active() @@ -1289,27 +1195,12 @@ class AnthySetup(object): if mode == 'romaji': tv = self.__get_romaji_treeview_custom_key_table(method) elif mode == 'kana': - prefs.set_value('kana_typing_rule', 'method', method) - self.__builder.get_object('btn_apply').set_sensitive(True) + prefs.set_value('kana-typing-rule', 'method', method) tv = self.__get_kana_treeview_custom_key_table(method) elif mode == 'thumb': # thumb uses all tables so do not save the method. tv = self.__get_thumb_treeview_custom_key_table(method) - def on_sb_changed(self, widget): - section, key = self.__get_section_key(Gtk.Buildable.get_name(widget)) - self.prefs.set_value(section, key, widget.get_value_as_int()) - self.__builder.get_object('btn_apply').set_sensitive(True) - - def on_ck_toggled(self, widget): - section, key = self.__get_section_key(Gtk.Buildable.get_name(widget)) - self.prefs.set_value(section, key, widget.get_active()) - self.__builder.get_object('btn_apply').set_sensitive(True) - if self.__thumb_kb_layout_mode and \ - Gtk.Buildable.get_name(widget) == \ - Gtk.Buildable.get_name(self.__thumb_kb_layout_mode): - self.__set_thumb_kb_label() - def on_btn_edit_clicked(self, widget): ls, it = self.__builder.get_object('shortcut').get_selection().get_selected() m = self.__builder.get_object('es:treeview').get_model() @@ -1326,19 +1217,20 @@ class AnthySetup(object): if id == Gtk.ResponseType.OK: new = l_to_s([m[i][0] for i in range(len(m))]) if new != ls.get(it, 1)[0]: - sec = self._get_shortcut_sec() - self.prefs.set_value(sec, ls.get(it, 0)[0], s_to_l(new)) + group = self.__get_shortcut_group() + self.__prefs.set_list_item('shortcut', group, + ls.get(it, 0)[0], s_to_l(new)) ls.set(it, 1, new) - self.__builder.get_object('btn_apply').set_sensitive(True) def on_btn_default_clicked(self, widget): ls, it = self.__builder.get_object('shortcut').get_selection().get_selected() - sec = self._get_shortcut_sec() - new = l_to_s(self.prefs.default[sec][ls.get(it, 0)[0]]) + group = self.__get_shortcut_group() + shortcuts = self.__prefs.get_default_value('shortcut', group) + new = l_to_s(shortcuts[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)) + self.__prefs.set_list_item('shortcut', group, + ls.get(it, 0)[0], s_to_l(new)) ls.set(it, 1, new) - self.__builder.get_object('btn_apply').set_sensitive(True) def on_btn_romaji_custom_table_clicked(self, widget): self.__run_dialog_custom_key_table(widget, 'romaji') @@ -1350,7 +1242,7 @@ class AnthySetup(object): self.__run_dialog_custom_key_table(widget, 'thumb') def on_btn_add_custom_key(self, widget, user_data): - prefs = self.prefs + prefs = self.__prefs input = self.__builder.get_object('entry_input_custom_key') output = self.__builder.get_object('entry_output_custom_key') left = self.__builder.get_object('entry_left_thumb_shift_custom_key') @@ -1381,43 +1273,33 @@ class AnthySetup(object): return if type == 'romaji': - section_base = 'romaji_typing_rule' + section = 'romaji-typing-rule' model.append([type, key, value]) elif type == 'kana': - section_base = 'kana_typing_rule' + section = 'kana-typing-rule' model.append([type, key, value]) elif type == 'thumb': - section_base = 'thumb_typing_rule' + section = 'thumb-typing-rule' model.append([type, key, value, left_text, right_text]) - if section_base == None: + if section == None: self.__run_message_dialog(_("Your custom key is not assigned in any sections. Maybe a bug.")) return gkey = prefs.typing_to_config_key(key) if gkey == '': return key = gkey - section = section_base + '/' + method - if key not in prefs.keys(section): - # ibus does not support gconf_client_all_entries(). - # prefs.fetch_section() doesn't get the keys if they exist - # in gconf only. - # Use newkeys for that way. - newkeys = prefs.get_value(section_base, 'newkeys') - if key not in newkeys: - newkeys.append(key) - prefs.set_value(section_base, 'newkeys', newkeys) if type != 'thumb': - prefs.set_value(section, key, value) + prefs.set_list_item(section, 'list', (method, key), value) else: - prefs.set_value(section, key, [value, right_text, left_text]) + prefs.set_list_item(section, 'list', + (method, key), [value, right_text, left_text]) left.set_text('') right.set_text('') input.set_text('') output.set_text('') - self.__builder.get_object('btn_apply').set_sensitive(True) def on_btn_remove_custom_key(self, widget, user_data): - prefs = self.prefs + prefs = self.__prefs combobox = self.__builder.get_object('combobox_custom_key_table') id = combobox.get_active() model_combobox = combobox.get_model() @@ -1428,31 +1310,21 @@ class AnthySetup(object): key = l[i][1] section_base = None if type == 'romaji': - section_base = 'romaji_typing_rule' + section = 'romaji-typing-rule' elif type == 'kana': - section_base = 'kana_typing_rule' + section = 'kana-typing-rule' elif type == 'thumb': - section_base = 'thumb_typing_rule' - if section_base == None: + section = 'thumb-typing-rule' + if section == None: self.__run_message_dialog(_("Your custom key is not assigned in any sections. Maybe a bug.")) return - section = section_base + '/' + method - newkeys = prefs.get_value(section_base, 'newkeys') gkey = prefs.typing_to_config_key(key) if gkey == '': return key = gkey - if key in newkeys: - newkeys.remove(key) - prefs.set_value(section_base, 'newkeys', newkeys) - # config.set_value(key, None) is not supported. - if type != 'thumb': - prefs.set_value(section, key, '') - else: - prefs.set_value(section, key, ['', '', '']) + prefs.delete_list_item(section, 'list', (method, key)) l.remove(i) widget.set_sensitive(False) - self.__builder.get_object('btn_apply').set_sensitive(True) def on_btn_thumb_key_clicked(self, widget): if Gtk.Buildable.get_name(widget) == 'thumb:button_ls': @@ -1487,18 +1359,17 @@ class AnthySetup(object): new = l[i][0] if new != text: section, key = self.__get_section_key(entry) - self.prefs.set_value(section, key, new) + self.__prefs.set_value(section, key, new) self.__builder.get_object(entry).set_text(new) - self.__builder.get_object('btn_apply').set_sensitive(True) def on_btn_dict_command_clicked(self, widget): if Gtk.Buildable.get_name(widget) == 'dict:btn_edit_dict_command': - key = 'dict_admin_command' + key = 'dict-admin-command' elif Gtk.Buildable.get_name(widget) == 'dict:btn_add_word_command': - key = 'add_word_command' + key = 'add-word-command' else: return - command = self.prefs.get_value('common', key) + command = self.__prefs.get_value('common', key) if not path.exists(command[0]): self.__run_message_dialog(_("Your file does not exist: ") + command[0], Gtk.MessageType.ERROR) @@ -1559,17 +1430,19 @@ class AnthySetup(object): if selected_id == None: return - if self.__is_system_dict_file_from_id(selected_id): + dict_item = self.__prefs.get_value('dict', 'list')[selected_id] + if dict_item.is_system: self.__run_message_dialog(_("You cannot delete the system dictionary."), Gtk.MessageType.ERROR) return file = self.__get_dict_file_from_id(selected_id) if file != None: - files = self.prefs.get_value('dict', 'files') - files.remove(file) - self.prefs.set_value('dict', 'files', files) - self.__builder.get_object('btn_apply').set_sensitive(True) + order = self.__prefs.get_value('dict', 'order') + order.remove(selected_id) + order = self.__prefs.set_value('dict', 'order', order) + self.__prefs.delete_list_item('dict', 'files', selected_id) + self.__prefs.delete_list_item('dict', 'list', selected_id) l.remove(i) return @@ -1586,27 +1459,19 @@ class AnthySetup(object): self.__run_message_dialog(_("Your file is not good."), Gtk.MessageType.ERROR) return - if not path.exists(dict_file): + if not path.exists(dict_file[0]): self.__run_message_dialog(_("Your file does not exist: ") + dict_file, Gtk.MessageType.ERROR) return - if dict_file == None: - return - # The selected id is already quoted. - section = 'dict/file/' + selected_id - if 'preview_lines' not in self.prefs.keys(section): - section = 'dict/file/default' - nline = self.prefs.get_value(section, 'preview_lines') - - section = 'dict/file/' + selected_id - if 'encoding' not in self.prefs.keys(section): - section = 'dict/file/default' - encoding = self.prefs.get_value(section, 'encoding') + dicts = self.__prefs.get_value('dict', 'list') + dict_item = dicts[selected_id] + nline = dict_item.preview_lines + encoding = dict_item.encoding lines = ''; - for i, line in enumerate(file(dict_file)): + for i, line in enumerate(file(dict_file[0])): if nline >= 0 and i >= nline: break; lines = lines + line @@ -1651,7 +1516,6 @@ class AnthySetup(object): dlg.destroy() def on_btn_dict_order_clicked(self, widget): - dict_file = None l, it = self.__builder.get_object('dict:view').get_selection().get_selected() if not it: @@ -1672,45 +1536,35 @@ class AnthySetup(object): if next_it: l.swap(it, next_it) - dict_file = self.__get_dict_file_from_id(selected_id) - files = self.prefs.get_value('dict', 'files') + order = self.__prefs.get_value('dict', 'order') + if len(order) == 0: + order = list(self.__prefs.get_value('dict', 'files').keys()) + i = order.index(selected_id) - if dict_file == None: - return - - i = files.index(dict_file) if Gtk.Buildable.get_name(widget) == 'dict:btn_up': if i <= 0: return next_i = i - 1 elif Gtk.Buildable.get_name(widget) == 'dict:btn_down': - if i + 1 >= len(dict_file): + if i + 1 >= len(order): return next_i = i + 1 - f = files[i] - files[i] = files[next_i] - files[next_i] = f - self.prefs.set_value('dict', 'files', files) - self.__builder.get_object('btn_apply').set_sensitive(True) - - def _get_shortcut_sec(self): - l = ['default', 'atok', 'wnn'] - iter = self.__builder.get_object('shortcut_type').get_active_iter() - model = self.__builder.get_object('shortcut_type').get_model() - s_type = model[iter][0].lower() - return 'shortcut/' + (s_type if s_type in l else 'default') + f = order[i] + order[i] = order[next_i] + order[next_i] = f + self.__prefs.set_value('dict', 'order', order) def on_shortcut_type_changed(self, widget): ls = self.__builder.get_object('shortcut').get_model() ls.clear() - sec = self._get_shortcut_sec() - for k in self.prefs.keys(sec): - ls.append([k, l_to_s(self.prefs.get_value(sec, k))]) + group = self.__get_shortcut_group() + shortcuts = self.__prefs.get_value('shortcut', group) + for k in shortcuts.keys(): + ls.append([k, l_to_s(shortcuts[k])]) section, key = self.__get_section_key(Gtk.Buildable.get_name(widget)) - self.prefs.set_value(section, key, sec[len('shortcut/'):]) - self.__builder.get_object('btn_apply').set_sensitive(True) + self.__prefs.set_value(section, key, group) def on_shortcut_key_release_event(self, widget, event): if event.hardware_keycode in [36, 65]: @@ -1755,7 +1609,9 @@ class AnthySetup(object): if not widget.get_text(): return list = widget.get_text().split() - if list[0][0] == '/': + if len(list) == 0: + return + elif list[0][0] == '/': if len(list) == 1: list.append(list[0][list[0].rfind('/') + 1:]) else: @@ -1766,14 +1622,13 @@ class AnthySetup(object): else: list.insert(0, '/usr/bin/' + list[0]) list[1] = list[1][list[1].rfind('/') + 1:] - if Gtk.Buildable.get_name(widget) == 'dict:entry_edit_dict_command': - key = 'dict_admin_command' - elif Gtk.Buildable.get_name(widget) == 'dict:entry_add_word_command': - key = 'add_word_command' + if Gtk.Buildable.get_name(widget) == 'dict:entry-edit-dict-command': + key = 'dict-admin-command' + elif Gtk.Buildable.get_name(widget) == 'dict:entry-add-word-command': + key = 'add-word-command' else: return - self.prefs.set_value('common', key, list) - self.__builder.get_object('btn_apply').set_sensitive(True) + self.__prefs.set_value('common', key, list) def on_es_entry_changed(self, widget): if not widget.get_text(): diff --git a/setup/python2/prefs.py b/setup/python2/prefs.py index 520742e..5429f10 100644 --- a/setup/python2/prefs.py +++ b/setup/python2/prefs.py @@ -4,8 +4,8 @@ # # Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> # Copyright (c) 2009 Hideaki ABE <abe.sendai@gmail.com> -# Copyright (c) 2010-2016 Takao Fujiwara <takao.fujiwara1@gmail.com> -# Copyright (c) 2007-2016 Red Hat, Inc. +# Copyright (c) 2010-2017 Takao Fujiwara <takao.fujiwara1@gmail.com> +# Copyright (c) 2007-2017 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,39 +24,101 @@ import sys from gi import require_version as gi_require_version +gi_require_version('Gio', '2.0') gi_require_version('GLib', '2.0') gi_require_version('IBus', '1.0') +from gi.repository import Gio from gi.repository import GLib +from gi.repository import GObject from gi.repository import IBus -class Prefs(object): - _prefix = 'engine/dummy' - - def __init__(self, bus=None, config=None): - self.default = {} - self.modified = {} - self.new = {} - self.__no_key_warning = False - - # self._config is used by AnthyPrefs . - self._config = config if config else \ - bus.get_config() if bus else \ - IBus.Bus().get_config() - - # ibus_config_get_values enhances the performance. - self.__has_config_get_values = False - - if self._config != None: - self.__has_config_get_values = hasattr(self._config, 'get_values') - else: - self.printerr( - 'ibus-config is not running or bus address is not correct.') - - def __log_handler(self, domain, level, message, data): - if not data: - return - GLib.log_default_handler(domain, level, message, '') +class DictItem(): + def __init__(self, + id='', + short_label='', + long_label='', + icon='', + is_system=False, + preview_lines=-1, + embed=False, + single=True, + reverse=False, + encoding='utf-8'): + self.id = id + self.short_label = short_label + self.long_label = long_label + self.icon = icon + self.is_system = is_system + self.preview_lines = preview_lines + self.embed = embed + self.single = single + self.reverse = reverse + self.encoding = encoding + + def __str__(self): + retval = ('id:', self.id, + 'short-label:', self.short_label, + 'long-label:', self.long_label, + 'icon:', self.icon, + 'is-system:', self.is_system, + 'preview-lines:', self.preview_lines, + 'embed:', self.embed, + 'single:', self.single, + 'reverse:', self.reverse, + 'encoding:', self.encoding) + return str(retval) + + @classmethod + def serialize(cls, dict_item): + builder = GLib.VariantBuilder(GLib.VariantType('r')) + builder.add_value(GLib.Variant.new_string(dict_item.id)) + builder.add_value(GLib.Variant.new_string(dict_item.short_label)) + builder.add_value(GLib.Variant.new_string(dict_item.long_label)) + builder.add_value(GLib.Variant.new_string(dict_item.icon)) + builder.add_value(GLib.Variant.new_boolean(dict_item.is_system)) + builder.add_value(GLib.Variant.new_int32(dict_item.preview_lines)) + builder.add_value(GLib.Variant.new_boolean(dict_item.embed)) + builder.add_value(GLib.Variant.new_boolean(dict_item.single)) + builder.add_value(GLib.Variant.new_boolean(dict_item.reverse)) + builder.add_value(GLib.Variant.new_string(dict_item.encoding)) + return builder.end() + +class Prefs(GObject.GObject): + __gsignals__ = { + 'changed' : ( + GObject.SignalFlags.RUN_FIRST, + None, + (str, str, GLib.Variant)), + } + + def __init__(self): + super(Prefs, self).__init__() + self.__cache = {} + self.__settings = {} + self.__schema_prefix = 'org.freedesktop.ibus.engine.anthy.' + self.__schema_sections = ['common', + 'shortcut', + 'romaji-typing-rule', + 'kana-typing-rule', + 'thumb-typing-rule', + 'thumb', + 'dict'] + for section in self.__schema_sections: + self.__settings[section] = Gio.Settings( + schema=self.__schema_prefix + section) + self.__settings[section].connect('changed', + self.__settings_on_changed) + + def __settings_on_changed(self, settings, key): + section = settings.props.schema[len(self.__schema_prefix):] + variant_value = self.__settings[section].get_value(key) + variant_key = self.__cache.get(section) + if variant_key == None: + variant_key = {} + variant_key[key] = variant_value + self.__cache[section] = variant_key + self.emit('changed', section, key, variant_value) def variant_to_value(self, variant): if type(variant) != GLib.Variant: @@ -68,7 +130,9 @@ class Prefs(object): return variant.get_int32() elif type_string == 'b': return variant.get_boolean() - elif type_string == 'as': + elif type_string == 'v': + return variant.unpack() + elif len(type_string) > 0 and type_string[0] == 'a': # Use unpack() instead of dup_strv() in python. # In the latest pygobject3 3.3.4 or later, g_variant_dup_strv # returns the allocated strv but in the previous release, @@ -79,174 +143,165 @@ class Prefs(object): sys.abrt() return variant - def set_no_key_warning(self, no_key_warning): - if no_key_warning and hasattr(IBus, 'unset_log_handler'): - self.__no_key_warning = True - else: - self.__no_key_warning = False - - def keys(self, section): - return self.default[section].keys() - - def sections(self): - return self.default.keys() - - def set_new_section(self, section): - self.default.setdefault(section, {}) + def variant_from_value(self, value): + variant = None + if type(value) == str: + variant = GLib.Variant.new_string(value) + elif type(value) == int: + variant = GLib.Variant.new_int32(value) + elif type(value) == bool: + variant = GLib.Variant.new_boolean(value) + elif type(value) == list: + variant = GLib.Variant.new_strv(value) + if variant == None: + self.printerr('Unknown value type: %s' % type(value)) + return variant - def set_new_key(self, section, key): - self.default[section].setdefault(key) + def get_variant(self, section, key): + variant_key = self.__cache.get(section) + if variant_key != None: + variant_value = variant_key.get(key) + if variant_value != None: + return variant_value + variant_value = self.__settings[section].get_value(key) + if variant_key == None: + variant_key = {} + variant_key[key] = variant_value + self.__cache[section] = variant_key + return variant_value + + def get_default_variant(self, section, key): + return self.__settings[section].get_default_value(key) + + def get_readable_value(self, section, key, variant): + value = self.variant_to_value(variant) + if section == 'dict' and key == 'list': + dicts = {} + for item in value: + dict_item = DictItem(*item) + dicts[dict_item.id] = dict_item + value = dicts + if section == 'dict' and key == 'template': + value = DictItem(*value) + return value def get_value(self, section, key): - try: - return self.new[section][key] - except: - try: - return self.modified[section][key] - except: - return self.default[section][key] + variant = self.get_variant(section, key) + return self.get_readable_value(section, key, variant) - def get_value_direct(self, section, key, default=None): - if self._config == None: - return default + def get_default_value(self, section, key): + variant = self.get_default_variant(section, key) + return self.get_readable_value(section, key, variant) - s = section - section = '/'.join( - [s for s in '/'.join([self._prefix, section]).split('/') if s]) - try: - if self.__no_key_warning: - IBus.set_log_handler(False) - variant = self._config.get_value(section, key) - if self.__no_key_warning: - IBus.unset_log_handler() - return self.variant_to_value(variant) - except: - return default + def set_variant(self, section, key, variant): + self.__settings[section].set_value(key, variant) + self.__settings[section].apply() def set_value(self, section, key, value): - if section not in self.sections(): - self.set_new_section(section) - if key not in self.keys(section): - self.set_new_key(section, key) - self.default[section][key] - self.new.setdefault(section, {})[key] = value - - def fetch_all(self): - for s in self.sections(): - self.fetch_section(s) - - def fetch_section(self, section): - if self._config == None: + variant = self.variant_from_value(value) + if variant == None: return + self.set_variant(section, key, variant) - if not self.__has_config_get_values: - for k in self.keys(section): - self.fetch_item(section, k) + def set_list_item(self, section, key, item, values): + variant = self.get_variant(section, key) + if variant == None: + printerrr('%s:%s does not exist' % (section, key)) return - - s = '/'.join( - [s for s in '/'.join([self._prefix, section]).split('/') if s]) - variant = self._config.get_values(s) - for key in variant.keys(): - v = variant[key] - self.modified.setdefault(section, {})[key] = v if v != [''] else [] - # FIXME: ibus-dconf converts the keys. - if section == 'common': - self.fetch_item(section, 'show-input-mode') - self.fetch_item(section, 'show-typing-method') - self.fetch_item(section, 'show-segment-mode') - self.fetch_item(section, 'show-dict-mode') - self.fetch_item(section, 'show-dict-config') - self.fetch_item(section, 'show-preferences') - - def fetch_item(self, section, key, readonly=False): - if self._config == None: + if section == 'shortcut': + variant_dict = GLib.VariantDict(variant) + array = [] + for value in values: + array.append(GLib.Variant.new_string(value)) + varray = GLib.Variant.new_array(GLib.VariantType('s'), array) + variant_dict.insert_value(item, varray) + # GVariantDict uses GHashTable internally and + # GVariantDict.end() does not support the order. + self.set_variant(section, key, variant_dict.end()) + return + if section == 'romaji-typing-rule' or \ + section == 'kana-typing-rule' or \ + section == 'thumb-typing-rule': + (method, keymap_key) = item + variant_dict = GLib.VariantDict(variant) + keymap = variant_dict.lookup_value(method, None) + keymap_dict = GLib.VariantDict(keymap) + if section == 'thumb-typing-rule': + array = [] + for value in values: + array.append(GLib.Variant.new_string(value)) + vvalue = GLib.Variant.new_array(GLib.VariantType('s'), array) + else: + vvalue = GLib.Variant.new_string(values) + keymap_dict.insert_value(keymap_key, vvalue) + keymap = keymap_dict.end() + variant_dict.insert_value(method, keymap) + self.set_variant(section, key, variant_dict.end()) + return + if section == 'dict' and key == 'files': + variant_dict = GLib.VariantDict(variant) + array = [] + for value in values: + array.append(GLib.Variant.new_string(value)) + varray = GLib.Variant.new_array(GLib.VariantType('s'), array) + variant_dict.insert_value(item, varray) + self.set_variant(section, key, variant_dict.end()) + return + if section == 'dict' and key == 'list': + array = [] + has_item = False + for v in variant: + dict_item = DictItem(*v) + if dict_item.id == values.id: + array.append(GLib.Variant.new_variant( + DictItem.serialize(values))) + has_item = True + else: + array.append(GLib.Variant.new_variant( + DictItem.serialize(dict_item))) + if not has_item: + array.append(GLib.Variant.new_variant(DictItem.serialize(values))) + varray = GLib.Variant.new_array(GLib.VariantType('v'), array) + self.set_variant(section, key, varray) return - s = '/'.join( - [s for s in '/'.join([self._prefix, section]).split('/') if s]) - try: - v = None - # gobject-introspection has a bug. - # https://bugzilla.gnome.org/show_bug.cgi?id=670509 - # GLib.log_set_handler("IBUS", GLib.LogLevelFlags.LEVEL_MASK, - # self.__log_handler, False) - if self.__no_key_warning: - IBus.set_log_handler(False) - variant = self._config.get_value(s, key) - if self.__no_key_warning: - IBus.unset_log_handler() - v = self.variant_to_value(variant) - except: - v = None - if readonly: - return v != None - if v != None: - self.modified.setdefault(section, {})[key] = v if v != [''] else [] - return True - - def commit_all(self): - for s in self.new.keys(): - self.commit_section(s) - - def commit_section(self, section): - if section in self.new: - for k in self.new[section].keys(): - self.commit_item(section, k) - - def commit_item(self, section, key): - if section in self.new and key in self.new[section]: - s = '/'.join( - [s for s in '/'.join([self._prefix, section]).split('/') if s]) - v = self.new[section][key] - if v == []: - v = [''] - variant = None - if type(v) == str: - variant = GLib.Variant.new_string(v) - elif type(v) == int: - variant = GLib.Variant.new_int32(v) - elif type(v) == bool: - variant = GLib.Variant.new_boolean(v) - elif type(v) == list: - variant = GLib.Variant.new_strv(v) - if variant == None: - self.printerr('Unknown value type:', type(v)) - sys.abrt() - if self._config != None: - self._config.set_value(s, key, variant) - self.modified.setdefault(section, {})[key] = v - del(self.new[section][key]) - - def undo_all(self): - self.new.clear() - - def undo_section(self, section): - try: - del(self.new[section]) - except: - pass - - def undo_item(self, section, key): - try: - del(self.new[section][key]) - except: - pass - - def set_default_all(self): - for s in self.sections(): - self.set_default_section(s) - - def set_default_section(self, section): - for k in self.keys(section): - self.set_default_item(section, k) + def delete_list_item(self, section, key, item): + variant = self.get_variant(section, key) + if variant == None: + printerrr('%s:%s does not exist' % (section, key)) + return + if section == 'romaji-typing-rule' or \ + section == 'kana-typing-rule' or \ + section == 'thumb-typing-rule': + (method, keymap_key) = item + variant_dict = GLib.VariantDict(variant) + keymap = variant_dict.lookup_value(method, None) + keymap_dict = GLib.VariantDict(keymap) + keymap_dict.remove(keymap_key) + keymap = keymap_dict.end() + variant_dict.insert_value(method, keymap) + self.set_variant(section, key, variant_dict.end()) + return + if section == 'dict' and key == 'files': + variant_dict = GLib.VariantDict(variant) + variant_dict.remove(item) + self.set_variant(section, key, variant_dict.end()) + return + if section == 'dict' and key == 'list': + array = [] + for v in variant: + dict_item = DictItem(*v) + if dict_item.id == item: + continue + else: + array.append(GLib.Variant.new_variant( + DictItem.serialize(dict_item))) + varray = GLib.Variant.new_array(GLib.VariantType('v'), array) + self.set_variant(section, key, varray) + return - def set_default_item(self, section, key): - try: - if key in self.modified[section] or key in self.new[section]: - self.new[section][key] = self.default[section][key] - except: - pass + def bind(self, section, key, object, property, flags): + self.__settings[section].bind(key, object, property, flags) # Convert DBus.String to str # sys.getdefaultencoding() == 'utf-8' with pygtk2 but diff --git a/setup/python2/setup.ui b/setup/python2/setup.ui index f0acbc6..61d9325 100644 --- a/setup/python2/setup.ui +++ b/setup/python2/setup.ui @@ -196,7 +196,7 @@ <property name="visible">False</property> <property name="title" translatable="yes">Setup - IBus-Anthy</property> <property name="type_hint">dialog</property> - <signal handler="on_main_delete" name="delete_event"/> + <signal handler="on_main_quit" name="delete_event"/> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="visible">True</property> @@ -232,7 +232,7 @@ <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> + <property name="mnemonic_widget">input-mode</property> </object> <packing> <property name="x_options">GTK_FILL</property> @@ -240,9 +240,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="input_mode"> + <object class="GtkComboBox" id="input-mode"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model1</property> <child> <object class="GtkCellRendererText" id="renderer1"/> @@ -263,7 +262,7 @@ <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="mnemonic_widget">typing-method</property> </object> <packing> <property name="top_attach">1</property> @@ -273,9 +272,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="typing_method"> + <object class="GtkComboBox" id="typing-method"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model2</property> <child> <object class="GtkCellRendererText" id="renderer2"/> @@ -298,7 +296,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Conversion _Mode:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">conversion_segment_mode</property> + <property name="mnemonic_widget">conversion-segment-mode</property> </object> <packing> <property name="top_attach">2</property> @@ -308,9 +306,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="conversion_segment_mode"> + <object class="GtkComboBox" id="conversion-segment-mode"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model3</property> <child> <object class="GtkCellRendererText" id="renderer3"/> @@ -366,7 +363,7 @@ <property name="vscrollbar_policy">automatic</property> <property name="shadow_type">in</property> <child> - <object class="GtkTreeView" id="menu_visible:treeview"> + <object class="GtkTreeView" id="menu-visible:treeview"> <property name="visible">True</property> <property name="can_focus">True</property> </object> @@ -430,7 +427,7 @@ <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="mnemonic_widget">period-style</property> </object> <packing> <property name="x_options">GTK_FILL</property> @@ -443,7 +440,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Symbo_l Style:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">symbol_style</property> + <property name="mnemonic_widget">symbol-style</property> </object> <packing> <property name="top_attach">1</property> @@ -458,7 +455,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Numpad _Key Type:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">ten_key_mode</property> + <property name="mnemonic_widget">ten-key-mode</property> </object> <packing> <property name="top_attach">2</property> @@ -468,9 +465,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="ten_key_mode"> + <object class="GtkComboBox" id="ten-key-mode"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model4</property> <child> <object class="GtkCellRendererText" id="renderer4"/> @@ -488,9 +484,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="symbol_style"> + <object class="GtkComboBox" id="symbol-style"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model5</property> <child> <object class="GtkCellRendererText" id="renderer5"/> @@ -508,9 +503,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="period_style"> + <object class="GtkComboBox" id="period-style"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model6</property> <child> <object class="GtkCellRendererText" id="renderer6"/> @@ -531,7 +525,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">_Behavior on Period:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">behavior_on_period</property> + <property name="mnemonic_widget">behavior-on-period</property> </object> <packing> <property name="top_attach">3</property> @@ -546,7 +540,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Behavior on _Focus Out:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">behavior_on_focus_out</property> + <property name="mnemonic_widget">behavior-on-focus-out</property> </object> <packing> <property name="top_attach">4</property> @@ -556,9 +550,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="behavior_on_period"> + <object class="GtkComboBox" id="behavior-on-period"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model7</property> <child> <object class="GtkCellRendererText" id="renderer7"/> @@ -576,9 +569,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="behavior_on_focus_out"> + <object class="GtkComboBox" id="behavior-on-focus-out"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model8</property> <child> <object class="GtkCellRendererText" id="renderer8"/> @@ -636,7 +628,7 @@ <property name="xalign">0</property> <property name="label" translatable="yes">Candidate _Window Page Size:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">page_size</property> + <property name="mnemonic_widget">page-size</property> </object> <packing> <property name="expand">False</property> @@ -645,12 +637,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="page_size"> + <object class="GtkSpinButton" id="page-size"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="adjustment">adjustment1</property> <property name="climb_rate">0.97999999999999998</property> - <signal handler="on_sb_changed" name="value_changed"/> </object> <packing> <property name="expand">False</property> @@ -664,14 +655,13 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="half_width_symbol"> + <object class="GtkCheckButton" id="half-width-symbol"> <property name="label" translatable="yes">Convert _symbols with the one column width</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="S" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </object> <packing> @@ -681,14 +671,13 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="half_width_number"> + <object class="GtkCheckButton" id="half-width-number"> <property name="label" translatable="yes">Convert _numbers with the one column width</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="N" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </object> <packing> @@ -698,14 +687,13 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="half_width_space"> + <object class="GtkCheckButton" id="half-width-space"> <property name="label" translatable="yes">Con_vert spaces with the one column width</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="v" modifiers="GDK_MOD1_MASK" signal="activate"/> </object> <packing> @@ -715,14 +703,13 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="latin_with_shift"> + <object class="GtkCheckButton" id="latin-with-shift"> <property name="label" translatable="yes">Swi_tch “Hiragana” and “Latin” with Shift key and Hiragana–Katakana key in preedit</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="t" modifiers="GDK_MOD1_MASK" signal="activate"/> </object> <packing> @@ -777,7 +764,7 @@ <property name="label" translatable="yes">_Shortcut Type:</property> <property name="use_underline">True</property> <property name="wrap_mode">word-char</property> - <property name="mnemonic_widget">shortcut_type</property> + <property name="mnemonic_widget">shortcut-type</property> </object> <packing> <property name="expand">False</property> @@ -787,7 +774,7 @@ </packing> </child> <child> - <object class="GtkComboBox" id="shortcut_type"> + <object class="GtkComboBox" id="shortcut-type"> <property name="visible">True</property> <signal handler="on_shortcut_type_changed" name="changed"/> <property name="model">model9</property> @@ -1271,7 +1258,7 @@ </packing> </child> <child> - <object class="GtkCheckButton" id="thumb:keyboard_layout_mode"> + <object class="GtkCheckButton" id="thumb:keyboard-layout-mode"> <property name="label" translatable="yes">Adjust _input method layout to system keyboard layout</property> <property name="tooltip_text" translatable="yes">Adjust IM layout to XKB layout</property> <property name="visible">True</property> @@ -1279,7 +1266,6 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="I" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </object> <packing> @@ -1299,7 +1285,7 @@ <property name="xalign">0</property> <property name="use_underline">True</property> <property name="label" translatable="yes">Input _Method Layout:</property> - <property name="mnemonic_widget">thumb:keyboard_layout</property> + <property name="mnemonic_widget">thumb:keyboard-layout</property> </object> <packing> <property name="expand">False</property> @@ -1308,9 +1294,8 @@ </packing> </child> <child> - <object class="GtkComboBox" id="thumb:keyboard_layout"> + <object class="GtkComboBox" id="thumb:keyboard-layout"> <property name="visible">True</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model51</property> <child> <object class="GtkCellRendererText" id="renderer10"/> @@ -1378,7 +1363,7 @@ <property name="xalign">0</property> <property name="use_underline">True</property> <property name="label" translatable="yes">_Additional Key Arrangement:</property> - <property name="mnemonic_widget">thumb:fmv_extension</property> + <property name="mnemonic_widget">thumb:fmv-extension</property> </object> <packing> <property name="expand">False</property> @@ -1387,10 +1372,9 @@ </packing> </child> <child> - <object class="GtkComboBox" id="thumb:fmv_extension"> + <object class="GtkComboBox" id="thumb:fmv-extension"> <property name="visible">True</property> <property name="tooltip_text" translatable="yes">'~', '『', '¢', '£' and so on can be output with Thumb Shift key</property> - <signal handler="on_cb_changed" name="changed"/> <property name="model">model11</property> <child> <object class="GtkCellRendererText" id="renderer11"/> @@ -1457,7 +1441,6 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> - <signal handler="on_ck_toggled" name="toggled"/> <accelerator key="E" modifiers="GDK_MOD1_MASK" signal="grab_focus"/> </object> <packing> @@ -1576,7 +1559,7 @@ <property name="visible">True</property> <property name="label" translatable="yes">_Edit Dictionary Command:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">dict:entry_edit_dict_command</property> + <property name="mnemonic_widget">dict:entry-edit-dict-command</property> </object> <packing> <property name="x_options">GTK_FILL</property> @@ -1587,7 +1570,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="dict:entry_edit_dict_command"> + <object class="GtkEntry" id="dict:entry-edit-dict-command"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> @@ -1627,7 +1610,7 @@ <property name="visible">True</property> <property name="label" translatable="yes">_Add Word Command:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">dict:entry_add_word_command</property> + <property name="mnemonic_widget">dict:entry-add-word-command</property> </object> <packing> <property name="x_options">GTK_FILL</property> @@ -1640,7 +1623,7 @@ </packing> </child> <child> - <object class="GtkEntry" id="dict:entry_add_word_command"> + <object class="GtkEntry" id="dict:entry-add-word-command"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> @@ -1921,15 +1904,14 @@ <property name="orientation">horizontal</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="btn_apply"> - <property name="label" translatable="yes">_Apply</property> + <object class="GtkButton" id="btn_close"> + <property name="label" translatable="yes">_Close</property> <property name="use_underline">True</property> <property name="visible">True</property> - <property name="sensitive">False</property> <property name="can_focus">True</property> <property name="can_default">True</property> <property name="receives_default">False</property> - <signal handler="on_btn_apply_clicked" name="clicked"/> + <signal handler="on_btn_close_clicked" name="clicked"/> </object> <packing> <property name="expand">False</property> @@ -1937,38 +1919,6 @@ <property name="position">0</property> </packing> </child> - <child> - <object class="GtkButton" id="btn_cancel"> - <property name="label" translatable="yes">_Cancel</property> - <property name="use_underline">True</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <signal handler="on_btn_cancel_clicked" name="clicked"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkButton" id="btn_ok"> - <property name="label" translatable="yes">_OK</property> - <property name="use_underline">True</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">False</property> - <signal handler="on_btn_ok_clicked" name="clicked"/> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> </object> <packing> <property name="expand">False</property> @@ -1979,9 +1929,7 @@ </object> </child> <action-widgets> - <action-widget response="-10">btn_apply</action-widget> - <action-widget response="-6">btn_cancel</action-widget> - <action-widget response="-5">btn_ok</action-widget> + <action-widget response="-5">btn_close</action-widget> </action-widgets> </object> <object class="GtkDialog" id="edit_shortcut"> @@ -2762,8 +2710,8 @@ <property name="program-name">IBus-Anthy</property> <property name="copyright">Copyright © 2007–2008 Peng Huang Copyright © 2009 Hideaki ABE -Copyright © 2009–2016 Takao Fujiwara -Copyright © 2007–2016 Red Hat, Inc.</property> +Copyright © 2009–2017 Takao Fujiwara +Copyright © 2007–2017 Red Hat, Inc.</property> <property name="comments" translatable="yes">The Anthy engine for the IBus input platform</property> <property name="license">GPL</property> <property name="website">https://github.com/ibus/ibus/wiki</property> |