summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2014-04-29 12:30:15 +0800
committerPeng Wu <alexepico@gmail.com>2014-04-29 12:30:15 +0800
commit7813d0b1711f08b0164242499c6ac02d30fab966 (patch)
tree454f950e36ae4acf9dfefa998e78daf96756ecfb
parentad0e422ceaafe4fcddfc579d2061d93a6e711ab0 (diff)
downloadibus-libpinyin-7813d0b1711f08b0164242499c6ac02d30fab966.tar.gz
ibus-libpinyin-7813d0b1711f08b0164242499c6ac02d30fab966.tar.xz
ibus-libpinyin-7813d0b1711f08b0164242499c6ac02d30fab966.zip
improves m_bopomofo_keyboard_mapping read
-rw-r--r--src/PYConfig.h4
-rw-r--r--src/PYLibPinyin.cc22
-rw-r--r--src/PYPConfig.cc35
3 files changed, 35 insertions, 26 deletions
diff --git a/src/PYConfig.h b/src/PYConfig.h
index a0cdb17..263642a 100644
--- a/src/PYConfig.h
+++ b/src/PYConfig.h
@@ -58,7 +58,7 @@ public:
gboolean initFullPunct (void) const { return m_init_full_punct; }
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; }
+ ChewingScheme bopomofoKeyboardMapping (void) const { return m_bopomofo_keyboard_mapping; }
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; }
@@ -106,7 +106,7 @@ protected:
gboolean m_init_simp_chinese;
gboolean m_special_phrases;
- gint m_bopomofo_keyboard_mapping;
+ ChewingScheme m_bopomofo_keyboard_mapping;
gint m_select_keys;
gboolean m_guide_key;
gboolean m_auxiliary_select_key_f;
diff --git a/src/PYLibPinyin.cc b/src/PYLibPinyin.cc
index 78299d5..57b61fa 100644
--- a/src/PYLibPinyin.cc
+++ b/src/PYLibPinyin.cc
@@ -177,32 +177,14 @@ LibPinyinBackEnd::setPinyinOptions (Config *config)
return TRUE;
}
-/* Here are the chewing keyboard scheme mapping table. */
-static const struct {
- gint bopomofo_keyboard;
- ChewingScheme scheme;
-} chewing_options [] = {
- {0, CHEWING_STANDARD},
- {1, CHEWING_GINYIEH},
- {2, CHEWING_ETEN},
- {3, CHEWING_IBM}
-};
-
-
gboolean
LibPinyinBackEnd::setChewingOptions (Config *config)
{
if (NULL == m_chewing_context)
return FALSE;
- const gint map = config->bopomofoKeyboardMapping ();
- for (guint i = 0; i < G_N_ELEMENTS (chewing_options); i++) {
- if (map == chewing_options[i].bopomofo_keyboard) {
- /* TODO: set chewing scheme. */
- ChewingScheme scheme = chewing_options[i].scheme;
- pinyin_set_chewing_scheme (m_chewing_context, scheme);
- }
- }
+ ChewingScheme scheme = config->bopomofoKeyboardMapping ();
+ pinyin_set_chewing_scheme (m_chewing_context, scheme);
pinyin_option_t options = config->option() | USE_TONE;
pinyin_set_options(m_chewing_context, options);
diff --git a/src/PYPConfig.cc b/src/PYPConfig.cc
index fb42cdd..8597b07 100644
--- a/src/PYPConfig.cc
+++ b/src/PYPConfig.cc
@@ -428,6 +428,17 @@ LibPinyinPinyinConfig::valueChanged (const std::string &section,
return TRUE;
}
+/* Here are the chewing keyboard scheme mapping table. */
+static const struct {
+ gint bopomofo_keyboard;
+ ChewingScheme scheme;
+} chewing_schemes [] = {
+ {0, CHEWING_STANDARD},
+ {1, CHEWING_GINYIEH},
+ {2, CHEWING_ETEN},
+ {3, CHEWING_IBM}
+};
+
LibPinyinBopomofoConfig::LibPinyinBopomofoConfig (Bus & bus)
: LibPinyinConfig (bus, "bopomofo")
{
@@ -455,7 +466,15 @@ LibPinyinBopomofoConfig::readDefaultValues (void)
m_special_phrases = read (CONFIG_SPECIAL_PHRASES, false);
- m_bopomofo_keyboard_mapping = read (CONFIG_BOPOMOFO_KEYBOARD_MAPPING, 0);
+ const gint map = read (CONFIG_BOPOMOFO_KEYBOARD_MAPPING, 0);
+ m_bopomofo_keyboard_mapping = CHEWING_DEFAULT;
+
+ for (guint i = 0; i < G_N_ELEMENTS (chewing_schemes); i++) {
+ if (map == chewing_schemes[i].bopomofo_keyboard) {
+ /* set chewing scheme. */
+ m_bopomofo_keyboard_mapping = chewing_schemes[i].scheme;
+ }
+ }
m_select_keys = read (CONFIG_SELECT_KEYS, 0);
if (m_select_keys >= 9) m_select_keys = 0;
@@ -488,9 +507,17 @@ LibPinyinBopomofoConfig::valueChanged (const std::string &section,
m_init_simp_chinese = normalizeGVariant (value, false);
else if (CONFIG_SPECIAL_PHRASES == name)
m_special_phrases = normalizeGVariant (value, false);
- else if (CONFIG_BOPOMOFO_KEYBOARD_MAPPING == name)
- m_bopomofo_keyboard_mapping = normalizeGVariant (value, 0);
- else if (CONFIG_SELECT_KEYS == name) {
+ else if (CONFIG_BOPOMOFO_KEYBOARD_MAPPING == name) {
+ const gint map = normalizeGVariant (value, 0);
+ m_bopomofo_keyboard_mapping = CHEWING_DEFAULT;
+
+ for (guint i = 0; i < G_N_ELEMENTS (chewing_schemes); i++) {
+ if (map == chewing_schemes[i].bopomofo_keyboard) {
+ /* set chewing scheme. */
+ m_bopomofo_keyboard_mapping = chewing_schemes[i].scheme;
+ }
+ }
+ } else if (CONFIG_SELECT_KEYS == name) {
m_select_keys = normalizeGVariant (value, 0);
if (m_select_keys >= 9) m_select_keys = 0;
}