diff options
| author | Peng Wu <alexepico@gmail.com> | 2025-03-11 14:36:29 +0800 |
|---|---|---|
| committer | Peng Wu <alexepico@gmail.com> | 2025-03-11 14:40:16 +0800 |
| commit | 4b1150480d26f9ae39e8f9e6f0b7de1c7eae8ec7 (patch) | |
| tree | 01f8a271685a32d29bed6b2a91e59f1046979bf1 /src | |
| parent | bbf2962050bccb4267b7d75af01c6f652b4e9ecb (diff) | |
| download | ibus-libpinyin-4b1150480d26f9ae39e8f9e6f0b7de1c7eae8ec7.tar.gz ibus-libpinyin-4b1150480d26f9ae39e8f9e6f0b7de1c7eae8ec7.tar.xz ibus-libpinyin-4b1150480d26f9ae39e8f9e6f0b7de1c7eae8ec7.zip | |
Refactor PinyinProperties::propertyActivate method
Diffstat (limited to 'src')
| -rw-r--r-- | src/PYPinyinProperties.cc | 40 | ||||
| -rw-r--r-- | src/PYPinyinProperties.h | 4 |
2 files changed, 27 insertions, 17 deletions
diff --git a/src/PYPinyinProperties.cc b/src/PYPinyinProperties.cc index 3f7f890..612db43 100644 --- a/src/PYPinyinProperties.cc +++ b/src/PYPinyinProperties.cc @@ -239,23 +239,7 @@ PinyinProperties::propertyActivate (const gchar *prop_name, guint prop_state) { #ifdef IBUS_BUILD_LUA_EXTENSION const int len = strlen("LuaConverter."); if (0 == strncmp (prop_name, "LuaConverter.", len)) { - if (prop_state == PROP_STATE_CHECKED) { - std::string name = prop_name + len; - if (name == "None") - m_config.luaConverter (""); - else - m_config.luaConverter (name); - } - - for (auto iter = m_props_lua_converter_vec.begin (); - iter != m_props_lua_converter_vec.end (); ++iter) { - Property *prop = *iter; - if (0 == g_strcmp0 (prop->getKey (), prop_name)) { - prop->setState ((IBusPropState) prop_state); - updateProperty (*prop); - } - } - + toggleLuaConverter (len, prop_name, prop_state); return TRUE; } #endif @@ -270,6 +254,28 @@ PinyinProperties::setLuaPlugin (IBusEnginePlugin *plugin) { return TRUE; } +void +PinyinProperties::toggleLuaConverter (const int prefix_len, + const gchar *prop_name, + guint prop_state) { + if (prop_state == PROP_STATE_CHECKED) { + std::string name = prop_name + prefix_len; + if (name == "None") + m_config.luaConverter (""); + else + m_config.luaConverter (name); + } + + for (auto iter = m_props_lua_converter_vec.begin (); + iter != m_props_lua_converter_vec.end (); ++iter) { + Property *prop = *iter; + if (0 == g_strcmp0 (prop->getKey (), prop_name)) { + prop->setState ((IBusPropState) prop_state); + updateProperty (*prop); + } + } +} + gboolean PinyinProperties::appendLuaConverter (void) { if (!m_lua_plugin) diff --git a/src/PYPinyinProperties.h b/src/PYPinyinProperties.h index 69632d1..6706032 100644 --- a/src/PYPinyinProperties.h +++ b/src/PYPinyinProperties.h @@ -92,6 +92,10 @@ private: public: gboolean setLuaPlugin (IBusEnginePlugin *plugin); + void toggleLuaConverter (const int prefix_len, + const gchar *prop_name, + guint prop_state); + gboolean appendLuaConverter (void); #endif }; |
