add options for enter key, original feature is commit original english text, new...
authorYuren Ju <yurenju@gmail.com>
Wed, 20 Oct 2010 10:44:23 +0000 (18:44 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Fri, 22 Oct 2010 11:38:26 +0000 (20:38 +0900)
po/zh_TW.po
setup/ibus-pinyin-preferences.ui
setup/main.py
src/PYBopomofoEditor.cc
src/PYConfig.cc
src/PYConfig.h

index b9d68c6..02f8832 100644 (file)
@@ -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 "<b>Other</b>"
+msgstr "<b>其他</b>"
+
+msgid "Commit original text"
+msgstr "輸出原本的英文字"
+
+msgid "Commit first candidate"
+msgstr "輸出第一個候選詞"
index 2a4d7ad..5be2914 100644 (file)
                         <property name="position">1</property>
                       </packing>
                     </child>
+                    <child>
+                      <object class="GtkFrame" id="frame10">
+                        <property name="visible">True</property>
+                        <property name="label_xalign">0</property>
+                        <property name="shadow_type">none</property>
+                        <child>
+                          <object class="GtkAlignment" id="alignment16">
+                            <property name="visible">True</property>
+                            <property name="top_padding">6</property>
+                            <property name="left_padding">12</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox16">
+                                <property name="visible">True</property>
+                                <property name="spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="LabelEnter">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Feature of Enter key:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkRadioButton" id="CommitFirstCandidate">
+                                    <property name="label" translatable="yes">Commit first candidate</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="active">True</property>
+                                    <property name="draw_indicator">True</property>
+                                    <property name="group">CommitOriginalText</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">2</property>
+                                    <property name="right_attach">3</property>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkRadioButton" id="CommitOriginalText">
+                                    <property name="label" translatable="yes">Commit original text</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="draw_indicator">True</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child type="label">
+                          <object class="GtkLabel" id="labelOther">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">&lt;b&gt;Other&lt;/b&gt;</property>
+                            <property name="use_markup">True</property>
+                          </object>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
                   </object>
                 </child>
               </object>
index 693d0eb..86ad0bf 100644 (file)
@@ -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
index d83086b..e0a76c1 100644 (file)
@@ -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;
index 77d619d..114b74c 100644 (file)
@@ -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> PinyinConfig::m_instance;
 std::unique_ptr<BopomofoConfig> 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;
index 6db9c83..cec46e8 100644 (file)
@@ -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 */