Last active
September 27, 2015 10:38
-
-
Save iwagaki/1256975 to your computer and use it in GitHub Desktop.
ibus 1.3.9 + cherry-pick e3140b7206d409419faa0c8bfa50f25ad3644cd0 + this fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --cc bus/ibusimpl.c | |
index da24354,79dbf27..0000000 | |
--- a/bus/ibusimpl.c | |
+++ b/bus/ibusimpl.c | |
@@@ -196,11 -316,43 +196,42 @@@ bus_ibus_impl_set_trigger (BusIBusImpl | |
IBUS_CONTROL_MASK, | |
hotkey); | |
} | |
-#endif | |
} | |
+ /** | |
+ * bus_ibus_impl_set_enable_unconditional: | |
+ * | |
+ * A function to be called when "enable_unconditional" config is updated. | |
+ */ | |
+ static void | |
+ bus_ibus_impl_set_enable_unconditional (BusIBusImpl *ibus, | |
- GVariant *value) | |
++ GValue *value) | |
+ { | |
+ GQuark hotkey = g_quark_from_static_string ("enable-unconditional"); | |
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value); | |
+ } | |
+ | |
+ /** | |
+ * bus_ibus_impl_set_disable_unconditional: | |
+ * | |
+ * A function to be called when "disable_unconditional" config is updated. | |
+ */ | |
+ static void | |
+ bus_ibus_impl_set_disable_unconditional (BusIBusImpl *ibus, | |
- GVariant *value) | |
++ GValue *value) | |
+ { | |
+ GQuark hotkey = g_quark_from_static_string ("disable-unconditional"); | |
+ bus_ibus_impl_set_hotkey (ibus, hotkey, value); | |
+ } | |
+ | |
+ /** | |
+ * bus_ibus_impl_set_next_engine_in_menu: | |
+ * | |
+ * A function to be called when "next_engine_in_menu" config is updated. | |
+ */ | |
static void | |
bus_ibus_impl_set_next_engine_in_menu (BusIBusImpl *ibus, | |
- GVariant *value) | |
+ GValue *value) | |
{ | |
GQuark hotkey = g_quark_from_static_string ("next-engine-in-menu"); | |
bus_ibus_impl_set_hotkey (ibus, hotkey, value); | |
@@@ -370,69 -539,68 +401,94 @@@ bus_ibus_impl_set_default_preload_engin | |
/* sort engines by rank */ | |
engines = g_list_sort (engines, (GCompareFunc) _engine_desc_cmp); | |
- GVariantBuilder builder; | |
- g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); | |
- GList *list; | |
+ g_value_init (&value, G_TYPE_VALUE_ARRAY); | |
+ array = g_value_array_new (5); | |
for (list = engines; list != NULL; list = list->next) { | |
- IBusEngineDesc *desc = (IBusEngineDesc *) list->data; | |
- /* ignore engines with rank <= 0 */ | |
- if (ibus_engine_desc_get_rank (desc) > 0) | |
- g_variant_builder_add (&builder, "s", ibus_engine_desc_get_name (desc)); | |
- } | |
- | |
- GVariant *value = g_variant_builder_end (&builder); | |
- if (value != NULL) { | |
- if (g_variant_n_children (value) > 0) { | |
- ibus_config_set_value (ibus->config, | |
- "general", "preload_engines", value); | |
- } else { | |
- /* We don't update preload_engines with an empty string for safety. | |
- * Just unref the floating value. */ | |
- g_variant_unref (value); | |
- } | |
+ IBusEngineDesc *desc; | |
+ GValue name = { 0 }; | |
+ desc = (IBusEngineDesc *)list->data; | |
+ | |
+ /* ignore engines with rank <== 0 */ | |
+ if (desc->rank <= 0) | |
+ break; | |
+ g_value_init (&name, G_TYPE_STRING); | |
+ g_value_set_string (&name, desc->name); | |
+ g_value_array_append (array, &name); | |
} | |
+ g_value_take_boxed (&value, array); | |
+ ibus_config_set_value (ibus->config, "general", "preload_engines", &value); | |
+ g_value_unset (&value); | |
g_list_free (engines); | |
-#endif | |
} | |
+ /* The list of config entries that are related to ibus-daemon. */ | |
+ const static struct { | |
+ gchar *section; | |
+ gchar *key; | |
+ void (*func) (BusIBusImpl *, GVariant *); | |
+ } bus_ibus_impl_config_items [] = { | |
+ { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | |
+ { "general/hotkey", "enable_unconditional", bus_ibus_impl_set_enable_unconditional }, | |
+ { "general/hotkey", "disable_unconditional", bus_ibus_impl_set_disable_unconditional }, | |
+ { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine_in_menu }, | |
+ { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine }, | |
+ { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | |
+ { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout }, | |
+ { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, | |
+ { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, | |
+ { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, | |
+ }; | |
+ | |
+ /** | |
+ * bus_ibus_impl_reload_config | |
+ * | |
+ * Read config entries (e.g. preload_engines) from the config daemon. | |
+ */ | |
static void | |
bus_ibus_impl_reload_config (BusIBusImpl *ibus) | |
{ | |
g_assert (BUS_IS_IBUS_IMPL (ibus)); | |
gint i; | |
- for (i = 0; i < G_N_ELEMENTS (bus_ibus_impl_config_items); i++) { | |
- GVariant *variant = NULL; | |
- if (ibus->config != NULL) | |
- variant = ibus_config_get_value (ibus->config, | |
- bus_ibus_impl_config_items[i].section, | |
- bus_ibus_impl_config_items[i].key); | |
- bus_ibus_impl_config_items[i].func (ibus, variant); /* variant could be NULL if the deamon is not ready yet. */ | |
- if (variant) g_variant_unref (variant); | |
+ GValue value = { 0 }; | |
+ | |
+ const static struct { | |
+ gchar *section; | |
+ gchar *key; | |
+ void ( *func) (BusIBusImpl *, GValue *); | |
+ } entries [] = { | |
+ { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | |
++ { "general/hotkey", "enable_unconditional", bus_ibus_impl_set_enable_unconditional }, | |
++ { "general/hotkey", "disable_unconditional", bus_ibus_impl_set_disable_unconditional }, | |
+ #if 0 | |
+ /* Only for backward compatibility, shall be removed later. */ | |
+ { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine_in_menu }, | |
+ #endif | |
+ { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine_in_menu }, | |
+ #if 0 | |
+ /* Only for backward compatibility, shall be removed later. */ | |
+ { "general/hotkey", "prev_engine", bus_ibus_impl_set_previous_engine }, | |
+ #endif | |
+ { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine }, | |
+ { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | |
+ { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout }, | |
+ { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, | |
+ { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, | |
+ { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, | |
+ }; | |
+ | |
+ for (i = 0; i < G_N_ELEMENTS (entries); i++) { | |
+ if (ibus->config != NULL && | |
+ ibus_config_get_value (ibus->config, | |
+ entries[i].section, | |
+ entries[i].key, | |
+ &value)) { | |
+ entries[i].func (ibus, &value); | |
+ g_value_unset (&value); | |
+ } | |
+ else { | |
+ entries[i].func (ibus, NULL); | |
+ } | |
} | |
} | |
@@@ -450,34 -623,10 +506,36 @@@ _config_value_changed_cb (IBusConfig * | |
g_assert (BUS_IS_IBUS_IMPL (ibus)); | |
gint i; | |
- for (i = 0; i < G_N_ELEMENTS (bus_ibus_impl_config_items); i++) { | |
- if (g_strcmp0 (bus_ibus_impl_config_items[i].section, section) == 0 && | |
- g_strcmp0 (bus_ibus_impl_config_items[i].key, key) == 0) { | |
- bus_ibus_impl_config_items[i].func (ibus, value); | |
+ | |
+ const static struct { | |
+ gchar *section; | |
+ gchar *key; | |
+ void ( *func) (BusIBusImpl *, GValue *); | |
+ } entries [] = { | |
+ { "general/hotkey", "trigger", bus_ibus_impl_set_trigger }, | |
++ { "general/hotkey", "enable_unconditional", bus_ibus_impl_set_enable_unconditional }, | |
++ { "general/hotkey", "disable_unconditional", bus_ibus_impl_set_disable_unconditional }, | |
+ #if 0 | |
+ /* Only for backward compatibility, shall be removed later. */ | |
+ { "general/hotkey", "next_engine", bus_ibus_impl_set_next_engine_in_menu }, | |
+ #endif | |
+ { "general/hotkey", "next_engine_in_menu", bus_ibus_impl_set_next_engine_in_menu }, | |
+ #if 0 | |
+ /* Only for backward compatibility, shall be removed later. */ | |
+ { "general/hotkey", "prev_engine", bus_ibus_impl_set_previous_engine }, | |
+ #endif | |
+ { "general/hotkey", "previous_engine", bus_ibus_impl_set_previous_engine }, | |
+ { "general", "preload_engines", bus_ibus_impl_set_preload_engines }, | |
+ { "general", "use_system_keyboard_layout", bus_ibus_impl_set_use_sys_layout }, | |
+ { "general", "use_global_engine", bus_ibus_impl_set_use_global_engine }, | |
+ { "general", "embed_preedit_text", bus_ibus_impl_set_embed_preedit_text }, | |
+ { "general", "enable_by_default", bus_ibus_impl_set_enable_by_default }, | |
+ }; | |
+ | |
+ for (i = 0; i < G_N_ELEMENTS (entries); i++) { | |
+ if (g_strcmp0 (entries[i].section, section) == 0 && | |
+ g_strcmp0 (entries[i].key, key) == 0) { | |
+ entries[i].func (ibus, value); | |
break; | |
} | |
} | |
@@@ -1882,8 -1962,22 +1944,22 @@@ bus_ibus_impl_filter_keyboard_shortcut | |
} | |
return (enabled != bus_input_context_is_enabled (context)); | |
} | |
+ if (event == enable_unconditional) { | |
+ gboolean enabled = bus_input_context_is_enabled (context); | |
+ if (!enabled) { | |
+ bus_input_context_enable (context); | |
+ } | |
+ return bus_input_context_is_enabled (context); | |
+ } | |
+ if (event == disable_unconditional) { | |
+ gboolean enabled = bus_input_context_is_enabled (context); | |
+ if (enabled) { | |
+ bus_input_context_disable (context); | |
+ } | |
+ return !bus_input_context_is_enabled (context); | |
+ } | |
if (event == next) { | |
- if (bus_input_context_is_enabled (context)) { | |
+ if (bus_input_context_is_enabled(context)) { | |
bus_ibus_impl_context_request_next_engine_in_menu (ibus, context); | |
} | |
else { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment