diff options
author | Peng Wu <alexepico@gmail.com> | 2014-04-24 11:55:55 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-04-24 11:55:55 +0800 |
commit | 2eb396d315b662481acdc244a72202959adb5a8f (patch) | |
tree | fc97780917820a7fb83b18b7b12ea97a1a517230 | |
parent | e7b159f7c3a3301c8c9c16702448fcd967fc7642 (diff) | |
download | ibus-libzhuyin-2eb396d315b662481acdc244a72202959adb5a8f.tar.gz ibus-libzhuyin-2eb396d315b662481acdc244a72202959adb5a8f.tar.xz ibus-libzhuyin-2eb396d315b662481acdc244a72202959adb5a8f.zip |
write LibZhuyinBackEnd::setZhuyinOptions
-rw-r--r-- | src/ZYLibZhuyin.cc | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/ZYLibZhuyin.cc b/src/ZYLibZhuyin.cc index b924e85..5ef26e8 100644 --- a/src/ZYLibZhuyin.cc +++ b/src/ZYLibZhuyin.cc @@ -72,10 +72,49 @@ LibZhuyinBackEnd::initZhuyinContext (Config *config) return context; } +/* Here are the zhuyin keyboard layout mapping table. */ +static const struct { + gint layout; + ZhuyinScheme scheme; +} zhuyin_options [] = { + {0, CHEWING_STANDARD}, + {1, CHEWING_HSU}, + {2, CHEWING_IBM}, + {3, CHEWING_GINYIEH}, + {4, CHEWING_ETEN}, + {5, CHEWING_ETEN26}, + {6, CHEWING_STANDARD_DVORAK}, + {7, CHEWING_HSU_DVORAK}, + {8, CHEWING_DACHEN_CP26}, + {9, FULL_PINYIN_HANYU}, + {10, FULL_PINYIN_LUOMA}, + {11, FULL_PINYIN_SECONDARY_BOPOMOFO}, +}; + gboolean LibZhuyinBackEnd::setZhuyinOptions (Config *config) { - assert (FALSE); + if (NULL == m_zhuyin_context) + return FALSE; + + gint layout = config->keyboardLayout (); + for (guint i = 0; i < G_N_ELEMENTS (zhuyin_options); ++i) { + if (zhuyin_options[i].layout == layout) { + ZhuyinScheme scheme = zhuyin_options[i].scheme; + switch (scheme) { + case CHEWING_STANDARD ... CHEWING_DACHEN_CP26: + zhuyin_set_chewing_scheme (m_zhuyin_context, scheme); + break; + case FULL_PINYIN_HANYU ... FULL_PINYIN_SECONDARY_BOPOMOFO: + zhuyin_set_full_pinyin_scheme (m_zhuyin_context, scheme); + break; + } + } + } + + zhuyin_option_t options = config->option (); + zhuyin_set_options (m_zhuyin_context, options); + return TRUE; } |