Disabled Custom of SelectKey
authorBYVoid <byvoid1@gmail.com>
Fri, 4 Jun 2010 07:07:13 +0000 (15:07 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Fri, 4 Jun 2010 23:31:08 +0000 (07:31 +0800)
setup/ibus-pinyin-preferences.ui
setup/main.py
src/Bopomofo.h
src/BopomofoEditor.cc
src/Config.cc
src/Config.h

index 876afe3..2686191 100644 (file)
                                       </packing>
                                     </child>
                                     <child>
-                                      <object class="GtkComboBoxEntry" id="SelectKeys">
+                                      <object class="GtkComboBox" id="SelectKeys">
                                         <property name="visible">True</property>
                                         <property name="model">liststoreSelectionKeys</property>
                                         <property name="button_sensitivity">on</property>
@@ -1695,22 +1695,31 @@ koterpilla, Zerng07
     </columns>
     <data>
       <row>
-        <col id="0" translatable="no">1234567890</col>
+        <col id="0">1234567890</col>
       </row>
       <row>
-        <col id="0" translatable="no">asdfghjkl;</col>
+        <col id="0">asdfghjkl;</col>
       </row>
       <row>
-        <col id="0" translatable="no">1qaz2wsxed</col>
+        <col id="0">1qaz2wsxed</col>
       </row>
       <row>
-        <col id="0" translatable="no">asdfzxcvgb</col>
+        <col id="0">asdfzxcvgb</col>
       </row>
       <row>
-        <col id="0" translatable="no">1234qweras</col>
+        <col id="0">1234qweras</col>
       </row>
       <row>
-        <col id="0" translatable="no">aoeu;qjkix</col>
+        <col id="0">aoeu;qjkix</col>
+      </row>
+      <row>
+        <col id="0">aoeuhtnsid</col>
+      </row>
+      <row>
+        <col id="0">aoeuidhtns</col>
+      </row>
+      <row>
+        <col id="0">qweasdzxcr</col>
       </row>
     </data>
   </object>
index 7ffb4f3..e3166c1 100644 (file)
@@ -190,7 +190,8 @@ class PreferencesDialog:
         
         # selection mode
         self.__select_keys = self.__builder.get_object("SelectKeys")
-        self.__select_keys.set_text_column(0)
+        self.__select_keys.pack_start(renderer)
+        self.__select_keys.set_attributes(renderer, text=0)
         self.__guide_key = self.__builder.get_object("GuideKey")
         self.__auxiliary_select_key_f = self.__builder.get_object("AuxiliarySelectKey_F")
         self.__auxiliary_select_key_kp = self.__builder.get_object("AuxiliarySelectKey_KP")
@@ -198,7 +199,7 @@ class PreferencesDialog:
         # read value
         self.__bopomofo_keyboard_mapping.set_active(self.__get_value("BopomofoKeyboardMapping", 0))
         self.__incomplete_bopomofo.set_active(self.__get_value("IncompletePinyin", False))
-        self.__select_keys.get_child().set_text(self.__get_value("SelectKeys", "1234567890"))
+        self.__select_keys.set_active(self.__get_value("SelectKeys", 0))
         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))
@@ -207,7 +208,7 @@ class PreferencesDialog:
         def __bopomofo_keyboard_mapping_changed_cb(widget):
             self.__set_value("BopomofoKeyboardMapping", widget.get_active())
         def __select_keys_changed_cb(widget):
-            self.__set_value("SelectKeys", widget.get_active_text())
+            self.__set_value("SelectKeys", widget.get_active())
         
         self.__bopomofo_keyboard_mapping.connect("changed", __bopomofo_keyboard_mapping_changed_cb)
         self.__incomplete_bopomofo.connect("toggled", self.__toggled_cb, "IncompletePinyin")
index abd9813..ef278c3 100644 (file)
@@ -77,4 +77,16 @@ const static wchar_t bopomofo_char[] = {
     L'ˊ', L'ˇ', L'ˋ', L'˙',
 };
 
+const static gchar * bopomofo_select_keys[] = {
+    "1234567890",
+    "asdfghjkl;",
+    "1qaz2wsxed",
+    "asdfzxcvgb",
+    "1234qweras",
+    "aoeu;qjkix",
+    "aoeuhtnsid",
+    "aoeuidhtns",
+    "qweasdzxcr"
+};
+
 #endif /* __PY_BOPOMOFO_H_ */
index 83cd2d5..621cfd4 100644 (file)
@@ -291,13 +291,13 @@ BopomofoEditor::processSelectKey (guint keyval, guint keycode, guint modifiers)
     if (G_LIKELY (!m_select_mode && ((modifiers & IBUS_MOD1_MASK) == 0)))
         return FALSE;
 
-    const gchar * pos = strchr (m_config.selectKeys (), keyval);
+    const gchar * pos = strchr (bopomofo_select_keys[m_config.selectKeys ()], keyval);
     if (pos == NULL)
         return FALSE;
 
     m_select_mode = TRUE;
 
-    guint i = pos - m_config.selectKeys ();
+    guint i = pos - bopomofo_select_keys[m_config.selectKeys ()];
     selectCandidateInPage (i);
 
     return TRUE;
@@ -559,9 +559,9 @@ BopomofoEditor::updateLookupTableLabel ()
 {
     String str_label;
     guint color = m_select_mode ? 0x000000 : 0xBBBBBB;
-    for (const gchar *p = m_config.selectKeys (); *p; p++)
+    for (const gchar *p = bopomofo_select_keys[m_config.selectKeys ()]; *p; p++)
     {
-        guint i = p - m_config.selectKeys ();
+        guint i = p - bopomofo_select_keys[m_config.selectKeys ()];
         if (i >= m_config.pageSize ())
             break;
         str_label.printf ("%c.",*p);
index 2de2216..dbeffd8 100644 (file)
@@ -453,7 +453,7 @@ BopomofoConfig::readDefaultValues (void)
 
     m_bopomofo_keyboard_mapping = read (CONFIG_BOPOMOFO_KEYBOARD_MAPPING, 0);
 
-    m_select_keys = read (CONFIG_SELECT_KEYS, "1234567890");
+    m_select_keys = read (CONFIG_SELECT_KEYS, 0);
     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);
@@ -484,7 +484,7 @@ BopomofoConfig::valueChanged (const std::string & section,
     else if (CONFIG_BOPOMOFO_KEYBOARD_MAPPING == name)
         m_bopomofo_keyboard_mapping = normalizeGValue (value, 0);
     else if (CONFIG_SELECT_KEYS == name)
-        m_select_keys = normalizeGValue (value, "1234567890");
+        m_select_keys = normalizeGValue (value, 0);
     else if (CONFIG_GUIDE_KEY == name)
         m_guide_key = normalizeGValue (value, true);
     else if (CONFIG_AUXILIARY_SELECT_KEY_F == name)
index 080041a..0d2c4ed 100644 (file)
@@ -52,7 +52,7 @@ public:
     gboolean initSimpChinese (void) const       { return m_init_simp_chinese; }
     gboolean specialPhrases (void) const        { return m_special_phrases; }
     gint bopomofoKeyboardMapping (void) const   { return m_bopomofo_keyboard_mapping; }
-    const gchar * selectKeys (void) const       { return m_select_keys.c_str (); }
+    gint selectKeys (void) const                { return m_select_keys; }
     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; }
@@ -97,7 +97,7 @@ protected:
     gboolean m_special_phrases;
 
     gint m_bopomofo_keyboard_mapping;
-    std::string m_select_keys;
+    gint m_select_keys;
     gboolean m_guide_key;
     gboolean m_auxiliary_select_key_f;
     gboolean m_auxiliary_select_key_kp;