From d43d04a9b92f7abd719cf3da666c23eee43fb67c Mon Sep 17 00:00:00 2001 From: Yuren Ju Date: Wed, 20 Oct 2010 18:44:23 +0800 Subject: [PATCH] add options for enter key, original feature is commit original english text, new feature is commit first candidate phrase --- po/zh_TW.po | 12 +++++++ setup/ibus-pinyin-preferences.ui | 75 ++++++++++++++++++++++++++++++++++++++++ setup/main.py | 5 +++ src/PYBopomofoEditor.cc | 7 +++- src/PYConfig.cc | 4 +++ src/PYConfig.h | 3 ++ 6 files changed, 105 insertions(+), 1 deletion(-) diff --git a/po/zh_TW.po b/po/zh_TW.po index b9d68c6..02f8832 100644 --- a/po/zh_TW.po +++ b/po/zh_TW.po @@ -307,3 +307,15 @@ msgstr "[Shift]鍵選詞" #: ../setup/ibus-pinyin-preferences.ui.h:70 msgid "http://ibus.googlecode.com" msgstr "http://ibus.googlecode.com" + +msgid "Feature of Enter key:" +msgstr "Enter 鍵功能:" + +msgid "Other" +msgstr "其他" + +msgid "Commit original text" +msgstr "輸出原本的英文字" + +msgid "Commit first candidate" +msgstr "輸出第一個候選詞" diff --git a/setup/ibus-pinyin-preferences.ui b/setup/ibus-pinyin-preferences.ui index 2a4d7ad..5be2914 100644 --- a/setup/ibus-pinyin-preferences.ui +++ b/setup/ibus-pinyin-preferences.ui @@ -919,6 +919,81 @@ 1 + + + True + 0 + none + + + True + 6 + 12 + + + True + 6 + + + True + 0 + Feature of Enter key: + + + 3 + 4 + + + + + Commit first candidate + True + True + False + True + True + CommitOriginalText + + + 2 + 3 + 3 + 4 + + + + + Commit original text + True + True + False + True + + + 1 + 2 + 3 + 4 + + + + + + + + + True + <b>Other</b> + True + + + + + False + False + 2 + + diff --git a/setup/main.py b/setup/main.py index 693d0eb..86ad0bf 100644 --- a/setup/main.py +++ b/setup/main.py @@ -196,6 +196,9 @@ class PreferencesDialog: self.__auxiliary_select_key_f = self.__builder.get_object("AuxiliarySelectKey_F") self.__auxiliary_select_key_kp = self.__builder.get_object("AuxiliarySelectKey_KP") + # other + self.__enter_key = self.__builder.get_object("CommitFirstCandidate") + # read value self.__bopomofo_keyboard_mapping.set_active(self.__get_value("BopomofoKeyboardMapping", 0)) self.__incomplete_bopomofo.set_active(self.__get_value("IncompletePinyin", False)) @@ -203,6 +206,7 @@ class PreferencesDialog: self.__guide_key.set_active(self.__get_value("GuideKey", 1)) self.__auxiliary_select_key_f.set_active(self.__get_value("AuxiliarySelectKey_F", 1)) self.__auxiliary_select_key_kp.set_active(self.__get_value("AuxiliarySelectKey_KP", 1)) + self.__enter_key.set_active(self.__get_value("EnterKey", True)) # connect signals def __bopomofo_keyboard_mapping_changed_cb(widget): @@ -216,6 +220,7 @@ class PreferencesDialog: self.__guide_key.connect("toggled", self.__toggled_cb, "GuideKey") self.__auxiliary_select_key_f.connect("toggled", self.__toggled_cb, "AuxiliarySelectKey_F") self.__auxiliary_select_key_kp.connect("toggled", self.__toggled_cb, "AuxiliarySelectKey_KP") + self.__enter_key.connect("toggled", self.__toggled_cb, "EnterKey") def __init_input_custom(self): # others diff --git a/src/PYBopomofoEditor.cc b/src/PYBopomofoEditor.cc index d83086b..e0a76c1 100644 --- a/src/PYBopomofoEditor.cc +++ b/src/PYBopomofoEditor.cc @@ -456,7 +456,12 @@ BopomofoEditor::commit (void) m_buffer.clear (); - if (m_select_mode) { + if (!m_select_mode && m_config.enterKey ()) { + m_phrase_editor.selectCandidate(0); + } + + + if (m_select_mode || m_config.enterKey ()) { m_buffer << m_phrase_editor.selectedString (); const gchar *p; diff --git a/src/PYConfig.cc b/src/PYConfig.cc index 77d619d..114b74c 100644 --- a/src/PYConfig.cc +++ b/src/PYConfig.cc @@ -47,6 +47,7 @@ const gchar * const CONFIG_SELECT_KEYS = "SelectKeys"; const gchar * const CONFIG_GUIDE_KEY = "GuideKey"; const gchar * const CONFIG_AUXILIARY_SELECT_KEY_F = "AuxiliarySelectKey_F"; const gchar * const CONFIG_AUXILIARY_SELECT_KEY_KP = "AuxiliarySelectKey_KP"; +const gchar * const CONFIG_ENTER_KEY = "EnterKey"; std::unique_ptr PinyinConfig::m_instance; std::unique_ptr BopomofoConfig::m_instance; @@ -460,6 +461,7 @@ BopomofoConfig::readDefaultValues (void) m_guide_key = read (CONFIG_GUIDE_KEY, true); m_auxiliary_select_key_f = read (CONFIG_AUXILIARY_SELECT_KEY_F, true); m_auxiliary_select_key_kp = read (CONFIG_AUXILIARY_SELECT_KEY_KP, true); + m_enter_key = read (CONFIG_ENTER_KEY, true); } gboolean @@ -496,6 +498,8 @@ BopomofoConfig::valueChanged (const std::string & section, m_auxiliary_select_key_f = normalizeGValue (value, true); else if (CONFIG_AUXILIARY_SELECT_KEY_KP == name) m_auxiliary_select_key_kp = normalizeGValue (value, true); + else if (CONFIG_ENTER_KEY == name) + m_enter_key = normalizeGValue (value, true); else return FALSE; return TRUE; diff --git a/src/PYConfig.h b/src/PYConfig.h index 6db9c83..cec46e8 100644 --- a/src/PYConfig.h +++ b/src/PYConfig.h @@ -56,6 +56,7 @@ public: gboolean guideKey (void) const { return m_guide_key; } gboolean auxiliarySelectKeyF (void) const { return m_auxiliary_select_key_f; } gboolean auxiliarySelectKeyKP (void) const { return m_auxiliary_select_key_kp; } + gboolean enterKey (void) const { return m_enter_key; } protected: bool read (const gchar * name, bool defval); @@ -101,6 +102,8 @@ protected: gboolean m_guide_key; gboolean m_auxiliary_select_key_f; gboolean m_auxiliary_select_key_kp; + + gboolean m_enter_key; }; /* PinyinConfig */ -- 2.7.4