diff options
author | Peng Wu <alexepico@gmail.com> | 2014-07-15 13:36:55 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-07-15 13:36:55 +0800 |
commit | f24733b19f659046deb6c68c7b647b5f2bd6f5b1 (patch) | |
tree | d9a29e804d97b7b78fed3adfedae75937b76fe75 | |
parent | 18c1dab51499105a2e32dab405cf6d8809cce281 (diff) | |
download | ibus-libzhuyin-f24733b19f659046deb6c68c7b647b5f2bd6f5b1.tar.gz ibus-libzhuyin-f24733b19f659046deb6c68c7b647b5f2bd6f5b1.tar.xz ibus-libzhuyin-f24733b19f659046deb6c68c7b647b5f2bd6f5b1.zip |
support user phrases
-rw-r--r-- | setup/main.py | 2 | ||||
-rw-r--r-- | src/ZYLibZhuyin.cc | 2 | ||||
-rw-r--r-- | src/ZYLibZhuyin.h | 2 | ||||
-rw-r--r-- | src/ZYZConfig.cc | 22 |
4 files changed, 24 insertions, 4 deletions
diff --git a/setup/main.py b/setup/main.py index ed2037f..b2840dc 100644 --- a/setup/main.py +++ b/setup/main.py @@ -249,7 +249,7 @@ class PreferencesWindow: def __clear_user_data_cb(self, widget, name): - self.__set_value("ClearUserData", name) + self.__set_value("clearuserdata", name) def __init_about(self): diff --git a/src/ZYLibZhuyin.cc b/src/ZYLibZhuyin.cc index bdaebad..9708bbb 100644 --- a/src/ZYLibZhuyin.cc +++ b/src/ZYLibZhuyin.cc @@ -194,7 +194,7 @@ LibZhuyinBackEnd::importZhuyinDictionary (const char * filename) } gboolean -LibZhuyinBackEnd::cleanZhuyinUserData (const char * target) +LibZhuyinBackEnd::clearZhuyinUserData (const char * target) { if (0 == strcmp ("all", target)) zhuyin_mask_out (m_zhuyin_context, 0x0, 0x0); diff --git a/src/ZYLibZhuyin.h b/src/ZYLibZhuyin.h index a9a3e13..0a2686c 100644 --- a/src/ZYLibZhuyin.h +++ b/src/ZYLibZhuyin.h @@ -48,7 +48,7 @@ public: void modified (void); gboolean importZhuyinDictionary (const char * filename); - gboolean cleanZhuyinUserData (const char * target); + gboolean clearZhuyinUserData (const char * target); /* use static initializer in C++. */ static LibZhuyinBackEnd & instance (void) { return *m_instance; } diff --git a/src/ZYZConfig.cc b/src/ZYZConfig.cc index 52b7754..c3b0e72 100644 --- a/src/ZYZConfig.cc +++ b/src/ZYZConfig.cc @@ -22,6 +22,7 @@ #include "ZYZConfig.h" #include <zhuyin.h> #include "ZYLibZhuyin.h" +#include <string.h> namespace ZY { @@ -38,6 +39,9 @@ const gchar * const CONFIG_ALWAYS_INPUT_NUMBERS = "alwaysinputnum"; const gchar * const CONFIG_KEYBOARD_LAYOUT = "keyboardlayout"; const gchar * const CONFIG_CANDIDATE_KEYS = "candidatekeys"; +const gchar * const CONFIG_IMPORT_DICTIONARY = "importdictionary"; +const gchar * const CONFIG_CLEAR_USER_DATA = "clearuserdata"; + const zhuyin_option_t ZHUYIN_DEFAULT_OPTION = USE_TONE | FORCE_TONE | @@ -142,6 +146,13 @@ ZhuyinConfig::readDefaultValues (void) GVariant *value; g_variant_iter_init (&iter, values); while (g_variant_iter_next (&iter, "{sv}", &name, &value)) { + /* skip signals here. */ + if (0 == strcmp(CONFIG_IMPORT_DICTIONARY, name)) + continue; + + if (0 == strcmp(CONFIG_CLEAR_USER_DATA, name)) + continue; + valueChanged (m_section, name, value); g_free (name); g_variant_unref (value); @@ -247,6 +258,14 @@ ZhuyinConfig::valueChanged (const std::string §ion, m_page_size = 10; g_warn_if_reached (); } + } + else if (CONFIG_IMPORT_DICTIONARY == name) { + std::string filename = normalizeGVariant (value, std::string("")); + LibZhuyinBackEnd::instance ().importZhuyinDictionary(filename.c_str ()); + } + else if (CONFIG_CLEAR_USER_DATA == name) { + std::string target = normalizeGVariant (value, std::string("")); + LibZhuyinBackEnd::instance ().clearZhuyinUserData(target.c_str ()); } /* fuzzy zhuyin */ else if (CONFIG_FUZZY_ZHUYIN == name) { if (normalizeGVariant (value, false)) @@ -283,7 +302,8 @@ ZhuyinConfig::valueChangedCallback (IBusConfig *config, self->valueChanged (section, name, value); - LibZhuyinBackEnd::instance ().setZhuyinOptions (self); + if (self->m_section == "engine/zhuyin") + LibZhuyinBackEnd::instance ().setZhuyinOptions (self); } }; |