From 905a2d787f8b32325fcfb6472942ee67523402ed Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Thu, 9 Jan 2025 15:17:22 +0800 Subject: [PATCH] Fix PinyinProperties::propertyActivate method --- src/PYPinyinProperties.cc | 25 ++++++++++++++++++------- src/PYProperty.h | 5 +++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/PYPinyinProperties.cc b/src/PYPinyinProperties.cc index 455a5099..dad5dfae 100644 --- a/src/PYPinyinProperties.cc +++ b/src/PYPinyinProperties.cc @@ -237,13 +237,24 @@ PinyinProperties::propertyActivate (const gchar *prop_name, guint prop_state) { } const int len = strlen("LuaConverter."); - if (0 == strncmp (prop_name, "LuaConverter.", len) && - prop_state == PROP_STATE_CHECKED) { - std::string name = prop_name + len; - if (name == "None") - m_config.luaConverter (""); - else - m_config.luaConverter (name); + 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); + } + } + return TRUE; } diff --git a/src/PYProperty.h b/src/PYProperty.h index 9a1d3814..24923e40 100644 --- a/src/PYProperty.h +++ b/src/PYProperty.h @@ -39,6 +39,11 @@ class Property : public Object { IBusPropList *props = NULL) : Object (ibus_property_new (key, type, label, icon, tooltip, sensitive, visible, state, props)) { } + const gchar * getKey (void) + { + return ibus_property_get_key (get ()); + } + void setLabel (IBusText *text) { ibus_property_set_label (get (), text);