From 0318d1b391a0f4f926ee6075cbff24a6c9819aaa Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Aug 14 2011 00:10:20 +0000 Subject: Fixed compatible issues with gnome-shell 3.1.4 --- diff --git a/.gitignore b/.gitignore index d735925..16a805a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,5 +12,4 @@ ibus-1.3.6.tar.gz /ibus-1.3.99.20110408.tar.gz /ibus-1.3.99.20110419.tar.gz /ibus_master_da.po -/ibus-gjs-1.3.99.20110720.tar.gz -/ibus-gjs-1.3.99.20110806.tar.gz +/ibus-gjs-1.3.99.20110814.tar.gz diff --git a/ibus-541492-xkb.patch b/ibus-541492-xkb.patch index 6a64b82..003baf4 100644 --- a/ibus-541492-xkb.patch +++ b/ibus-541492-xkb.patch @@ -1,6 +1,6 @@ -From a253acde0935efae4bbc8aa59ca47ab273b9907b Mon Sep 17 00:00:00 2001 +From 2d0081ff5f19101a0348461b914274fc8bd63a19 Mon Sep 17 00:00:00 2001 From: fujiwarat -Date: Fri, 5 Aug 2011 20:22:42 +0900 +Date: Thu, 11 Aug 2011 19:07:38 +0900 Subject: [PATCH] Add XKB layouts --- @@ -13,7 +13,7 @@ Subject: [PATCH] Add XKB layouts ibus/bus.py | 3 + ibus/interface/iibus.py | 3 + ibus/xkblayout.py.in | 230 +++++++++++++++++ - ibus/xkbxml.py.in | 416 ++++++++++++++++++++++++++++++ + ibus/xkbxml.py.in | 419 ++++++++++++++++++++++++++++++ setup/Makefile.am | 1 + setup/enginecombobox.py | 7 +- setup/main.py | 3 + @@ -32,9 +32,9 @@ Subject: [PATCH] Add XKB layouts xkb/xkblayoutconfig.xml.in | 6 + xkb/xkblib.c | 327 ++++++++++++++++++++++++ xkb/xkblib.h | 41 +++ - xkb/xkbxml.c | 339 ++++++++++++++++++++++++ + xkb/xkbxml.c | 345 +++++++++++++++++++++++++ xkb/xkbxml.h | 113 ++++++++ - 30 files changed, 4027 insertions(+), 4 deletions(-) + 30 files changed, 4036 insertions(+), 4 deletions(-) create mode 100644 ibus/xkblayout.py.in create mode 100644 ibus/xkbxml.py.in create mode 100644 setup/xkbsetup.py @@ -537,10 +537,10 @@ index 0000000..11fce12 + self.__default_option = self.get_option() diff --git a/ibus/xkbxml.py.in b/ibus/xkbxml.py.in new file mode 100644 -index 0000000..16f47df +index 0000000..9407c13 --- /dev/null +++ b/ibus/xkbxml.py.in -@@ -0,0 +1,416 @@ +@@ -0,0 +1,419 @@ +# vim:set et sts=4 sw=4: +# +# ibus - The Input Bus @@ -836,7 +836,7 @@ index 0000000..16f47df + layout_desc=None, + variant=None, + variant_desc=None, -+ name_prefix='xkb:layout:'): ++ name=None): + if variant_desc != None: + longname = variant_desc + elif layout != None and variant != None: @@ -845,12 +845,15 @@ index 0000000..16f47df + longname = layout_desc + else: + longname = layout ++ name_prefix='xkb:layout:' + if variant != None: -+ name = name_prefix + layout + ':' + variant ++ if name == None: ++ name = name_prefix + layout + ':' + variant + desc = 'XKB ' + layout + '(' + variant + ') keyboard layout' + engine_layout = layout + '(' + variant + ')' + else: -+ name = name_prefix + layout ++ if name == None: ++ name = name_prefix + layout + desc = 'XKB ' + layout + ' keyboard layout' + engine_layout = layout + @@ -2991,7 +2994,7 @@ index 0000000..ad9cdd9 +endif diff --git a/xkb/ibus-engine-xkb-main.c b/xkb/ibus-engine-xkb-main.c new file mode 100644 -index 0000000..a2f131c +index 0000000..0fb0f0c --- /dev/null +++ b/xkb/ibus-engine-xkb-main.c @@ -0,0 +1,413 @@ @@ -3324,7 +3327,7 @@ index 0000000..a2f131c + NULL, + NULL, + NULL); -+ ibus_component_add_engine (component, engine); ++ ibus_component_add_engine (component, engine); + } + } + variants = (GList *) g_hash_table_lookup (layout_list, keys->data); @@ -3994,10 +3997,10 @@ index 0000000..15e5d18 +#endif diff --git a/xkb/xkbxml.c b/xkb/xkbxml.c new file mode 100644 -index 0000000..ad10c28 +index 0000000..d59a929 --- /dev/null +++ b/xkb/xkbxml.c -@@ -0,0 +1,339 @@ +@@ -0,0 +1,345 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* vim:set et sts=4: */ +/* bus - The Input Bus @@ -4267,19 +4270,17 @@ index 0000000..ad10c28 + const gchar *layout_desc, + const gchar *variant, + const gchar *variant_desc, -+ const gchar *name_prefix) ++ const gchar *alt_name) +{ + IBusEngineDesc *engine; + gchar *name = NULL; + gchar *longname = NULL; + gchar *desc = NULL; + gchar *engine_layout = NULL; ++ const gchar *name_prefix = "xkb:layout:"; + + g_return_val_if_fail (lang != NULL && layout != NULL, NULL); + -+ if (name_prefix == NULL) { -+ name_prefix = "xkb:layout:"; -+ } + if (variant_desc) { + longname = g_strdup (variant_desc); + } else if (layout && variant) { @@ -4290,11 +4291,19 @@ index 0000000..ad10c28 + longname = g_strdup (layout); + } + if (variant) { -+ name = g_strdup_printf ("%s%s:%s", name_prefix, layout, variant); ++ if (alt_name) { ++ name = g_strdup (alt_name); ++ } else { ++ name = g_strdup_printf ("%s%s:%s", name_prefix, layout, variant); ++ } + desc = g_strdup_printf ("XKB %s(%s) keyboard layout", layout, variant); + engine_layout = g_strdup_printf ("%s(%s)", layout, variant); + } else { -+ name = g_strdup_printf ("%s%s", name_prefix, layout); ++ if (alt_name) { ++ name = g_strdup (alt_name); ++ } else { ++ name = g_strdup_printf ("%s%s", name_prefix, layout); ++ } + desc = g_strdup_printf ("XKB %s keyboard layout", layout); + engine_layout = g_strdup (layout); + } diff --git a/ibus-xx-bridge-hotkey.patch b/ibus-xx-bridge-hotkey.patch index 0b59020..5a325d8 100644 --- a/ibus-xx-bridge-hotkey.patch +++ b/ibus-xx-bridge-hotkey.patch @@ -1,43 +1,40 @@ -From 9d5387ea430adbce81899a1a2bece6c8520848b1 Mon Sep 17 00:00:00 2001 +From 5136e4136e38271da195da76e1377308dbc2ed64 Mon Sep 17 00:00:00 2001 From: fujiwarat -Date: Fri, 5 Aug 2011 20:54:37 +0900 +Date: Fri, 12 Aug 2011 16:42:52 +0900 Subject: [PATCH] Add a bridge hotkey which use prev-next engines instead of on-off. --- bus/Makefile.am | 20 +- - bus/ibusimpl.c | 425 +++++++++++++++++++++++++++++++++------ - bus/inputcontext.c | 39 ++++ + bus/ibusimpl.c | 501 ++++++++++++++++++++++++++++++++++----- + bus/inputcontext.c | 39 +++ bus/inputcontext.h | 22 ++ - bus/registry.c | 36 ++++ + bus/registry.c | 61 +++++ + bus/registry.h | 10 + configure.ac | 31 +++ data/Makefile.am | 6 +- - data/ibus.schemas.in | 287 -------------------------- - data/ibus.schemas.in.in | 300 +++++++++++++++++++++++++++ + data/ibus.schemas.in | 287 ---------------------- + data/ibus.schemas.in.in | 300 +++++++++++++++++++++++ ibus/_config.py.in | 6 + - ibus/inputcontext.py | 14 ++- + ibus/inputcontext.py | 14 +- ibus/interface/iinputcontext.py | 4 +- ibus/xkbxml.py.in | 4 + setup/enginecombobox.py | 3 + - setup/enginetreeview.py | 16 ++- - setup/main.py | 24 +++ + setup/enginetreeview.py | 8 +- + setup/main.py | 24 ++ setup/setup.ui | 55 +++++- src/Makefile.am | 18 +- src/ibushotkey.c | 11 + src/ibushotkey.h | 11 + src/ibusutil.c | 12 + - src/ibusutil.h | 14 ++ - ui/gtk/Makefile.am | 2 + - ui/gtk/panel.py | 288 ++++++++++++++++++++++++-- - ui/gtk/xkbengine.py | 93 +++++++++ - ui/gtk/xkbfactory.py | 117 +++++++++++ + src/ibusutil.h | 14 + + ui/gtk/panel.py | 271 ++++++++++++++++++++-- xkb/Makefile.am | 2 + + xkb/ibus-engine-xkb-main.c | 19 ++ xkb/xkbxml.c | 10 +- - 28 files changed, 1480 insertions(+), 390 deletions(-) + 28 files changed, 1374 insertions(+), 391 deletions(-) delete mode 100644 data/ibus.schemas.in create mode 100644 data/ibus.schemas.in.in - create mode 100644 ui/gtk/xkbengine.py - create mode 100644 ui/gtk/xkbfactory.py diff --git a/bus/Makefile.am b/bus/Makefile.am index 074b456..0efaa1b 100644 @@ -71,7 +68,7 @@ index 074b456..0efaa1b 100644 AM_LDADD = \ @GOBJECT2_LIBS@ \ diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c -index f13d8e0..44fe954 100644 +index 853465c..00864ac 100644 --- a/bus/ibusimpl.c +++ b/bus/ibusimpl.c @@ -20,12 +20,17 @@ @@ -112,38 +109,120 @@ index f13d8e0..44fe954 100644 /* functions prototype */ static void bus_ibus_impl_destroy (BusIBusImpl *ibus); static void bus_ibus_impl_service_method_call -@@ -285,6 +296,30 @@ _panel_destroy_cb (BusPanelProxy *panel, +@@ -285,6 +296,112 @@ _panel_destroy_cb (BusPanelProxy *panel, g_object_unref (panel); } -+static IBusEngineDesc * -+_find_engine_desc_by_name (BusIBusImpl *ibus, -+ const gchar *engine_name) ++/** ++ * _foreach_remove_engine_hotkey: ++ * ++ * Remove the engine-specific hot key of the engine, and update ibus->engines_hotkey_profile. ++ */ ++gboolean ++_foreach_remove_engine_hotkey (gpointer key, ++ gpointer value, ++ gpointer data) +{ -+ IBusEngineDesc *desc = NULL; -+ GList *p; ++ GQuark event = GPOINTER_TO_UINT (value); ++ struct _impl_and_desc { ++ BusIBusImpl *ibus; ++ IBusEngineDesc *desc; ++ } *id = (struct _impl_and_desc *) data; ++ BusIBusImpl *ibus = id->ibus; ++ IBusEngineDesc *desc = id->desc; ++ GList *engine_list; + -+ /* find engine in registered engine list */ -+ for (p = ibus->register_engine_list; p != NULL; p = p->next) { -+ desc = (IBusEngineDesc *) p->data; -+ if (g_strcmp0 (ibus_engine_desc_get_name (desc), engine_name) == 0) -+ return desc; ++ g_assert (ibus != NULL); ++ g_assert (desc != NULL); ++ ++ if (event == 0) { ++ return FALSE; + } + -+ /* find engine in preload engine list */ -+ for (p = ibus->engine_list; p != NULL; p = p->next) { -+ desc = (IBusEngineDesc *) p->data; -+ if (g_strcmp0 (ibus_engine_desc_get_name (desc), engine_name) == 0) -+ return desc; ++ engine_list = g_hash_table_lookup (ibus->hotkey_to_engines_map, ++ GUINT_TO_POINTER (event)); ++ ++ /* As we will rebuild the engines hotkey map whenever an engine was ++ * added or removed, we don't need to hold a reference of the engine ++ * here. */ ++ if (engine_list && g_list_find (engine_list, desc) != NULL) { ++ engine_list = g_list_remove (engine_list, desc); + } + -+ return NULL; ++ /* We need to steal the value before adding it back, otherwise it will ++ * be destroyed. */ ++ g_hash_table_steal (ibus->hotkey_to_engines_map, GUINT_TO_POINTER (event)); ++ ++ if (engine_list != NULL) { ++ g_hash_table_insert (ibus->hotkey_to_engines_map, ++ GUINT_TO_POINTER (event), engine_list); ++ } ++ ++ return FALSE; ++} ++ ++/** ++ * _add_engine_hotkey_with_hotkeys: ++ * ++ * Check the engine-specific hot key of the engine, and update ibus->engines_hotkey_profile. ++ */ ++static void ++_add_engine_hotkey_with_hotkeys (IBusEngineDesc *engine, ++ BusIBusImpl *ibus, ++ const gchar *hotkeys) ++{ ++ gchar **hotkey_list; ++ gchar **p; ++ gchar *hotkey; ++ GList *engine_list; ++ ++ GQuark event; ++ guint keyval; ++ guint modifiers; ++ ++ g_assert (engine != NULL); ++ g_assert (hotkeys && *hotkeys); ++ ++ hotkey_list = g_strsplit_set (hotkeys, ";,", 0); ++ ++ for (p = hotkey_list; p && *p; ++p) { ++ hotkey = g_strstrip (*p); ++ if (!*hotkey || !ibus_key_event_from_string (hotkey, &keyval, &modifiers)) { ++ continue; ++ } ++ ++ /* If the hotkey already exists, we won't need to add it again. */ ++ event = ibus_hotkey_profile_lookup_hotkey (ibus->engines_hotkey_profile, ++ keyval, modifiers); ++ if (event == 0) { ++ event = g_quark_from_string (hotkey); ++ ibus_hotkey_profile_add_hotkey (ibus->engines_hotkey_profile, ++ keyval, modifiers, event); ++ } ++ ++ engine_list = g_hash_table_lookup (ibus->hotkey_to_engines_map, ++ GUINT_TO_POINTER (event)); ++ ++ /* As we will rebuild the engines hotkey map whenever an engine was ++ * added or removed, we don't need to hold a reference of the engine ++ * here. */ ++ engine_list = g_list_append (engine_list, engine); ++ ++ /* We need to steal the value before adding it back, otherwise it will ++ * be destroyed. */ ++ g_hash_table_steal (ibus->hotkey_to_engines_map, GUINT_TO_POINTER (event)); ++ ++ g_hash_table_insert (ibus->hotkey_to_engines_map, ++ GUINT_TO_POINTER (event), engine_list); ++ } ++ ++ g_strfreev (hotkey_list); +} + static void _config_set_value_done (GObject *object, GAsyncResult *res, -@@ -562,6 +597,67 @@ bus_ibus_impl_set_hotkey (BusIBusImpl *i +@@ -562,6 +679,67 @@ bus_ibus_impl_set_hotkey (BusIBusImpl *i } @@ -211,7 +290,7 @@ index f13d8e0..44fe954 100644 /** * bus_ibus_impl_set_trigger: * -@@ -573,7 +669,15 @@ bus_ibus_impl_set_trigger (BusIBusImpl * +@@ -573,7 +751,15 @@ bus_ibus_impl_set_trigger (BusIBusImpl * { GQuark hotkey = g_quark_from_static_string ("trigger"); if (value != NULL) { @@ -227,135 +306,90 @@ index f13d8e0..44fe954 100644 } #ifndef OS_CHROMEOS else { -@@ -1182,28 +1286,110 @@ _ibus_get_address (BusIBusImpl - g_variant_new ("(s)", bus_server_get_address ())); +@@ -639,6 +825,72 @@ bus_ibus_impl_set_previous_engine (BusIB + bus_ibus_impl_set_hotkey (ibus, hotkey, value); } --static IBusEngineDesc * --_find_engine_desc_by_name (BusIBusImpl *ibus, -- const gchar *engine_name) --{ -- IBusEngineDesc *desc = NULL; -- GList *p; -+/** -+ * _foreach_remove_engine_hotkey: -+ * -+ * Remove the engine-specific hot key of the engine, and update ibus->engines_hotkey_profile. -+ */ -+gboolean -+_foreach_remove_engine_hotkey (gpointer key, -+ gpointer value, -+ gpointer data) ++#if USE_BRIDGE_HOTKEY ++static gint ++_engine_desc_name_cmp (IBusEngineDesc *desc1, ++ IBusEngineDesc *desc2) +{ -+ GQuark event = GPOINTER_TO_UINT (value); -+ struct _impl_and_desc { -+ BusIBusImpl *ibus; -+ IBusEngineDesc *desc; -+ } *id = (struct _impl_and_desc *) data; -+ BusIBusImpl *ibus = id->ibus; -+ IBusEngineDesc *desc = id->desc; -+ GList *engine_list; - -- /* find engine in registered engine list */ -- for (p = ibus->register_engine_list; p != NULL; p = p->next) { -- desc = (IBusEngineDesc *) p->data; -- if (g_strcmp0 (ibus_engine_desc_get_name (desc), engine_name) == 0) -- return desc; -+ g_assert (ibus != NULL); -+ g_assert (desc != NULL); -+ -+ if (event == 0) { -+ return FALSE; - } - -- /* find engine in preload engine list */ -- for (p = ibus->engine_list; p != NULL; p = p->next) { -- desc = (IBusEngineDesc *) p->data; -- if (g_strcmp0 (ibus_engine_desc_get_name (desc), engine_name) == 0) -- return desc; -+ engine_list = g_hash_table_lookup (ibus->hotkey_to_engines_map, -+ GUINT_TO_POINTER (event)); -+ -+ /* As we will rebuild the engines hotkey map whenever an engine was -+ * added or removed, we don't need to hold a reference of the engine -+ * here. */ -+ if (engine_list && g_list_find (engine_list, desc) != NULL) { -+ engine_list = g_list_remove (engine_list, desc); - } - -- return NULL; -+ /* We need to steal the value before adding it back, otherwise it will -+ * be destroyed. */ -+ g_hash_table_steal (ibus->hotkey_to_engines_map, GUINT_TO_POINTER (event)); -+ -+ if (engine_list != NULL) { -+ g_hash_table_insert (ibus->hotkey_to_engines_map, -+ GUINT_TO_POINTER (event), engine_list); -+ } -+ -+ return FALSE; ++ return g_strcmp0 (ibus_engine_desc_get_name (desc1), ++ ibus_engine_desc_get_name (desc2)); +} + -+/** -+ * _add_engine_hotkey_with_hotkeys: -+ * -+ * Check the engine-specific hot key of the engine, and update ibus->engines_hotkey_profile. -+ */ +static void -+_add_engine_hotkey_with_hotkeys (IBusEngineDesc *engine, -+ BusIBusImpl *ibus, -+ const gchar *hotkeys) ++_set_register_engines (BusIBusImpl *ibus, ++ GVariant *value) +{ -+ gchar **hotkey_list; -+ gchar **p; -+ gchar *hotkey; -+ GList *engine_list; ++ GList *engine_list = NULL; + -+ GQuark event; -+ guint keyval; -+ guint modifiers; -+ -+ g_assert (engine != NULL); -+ g_assert (hotkeys && *hotkeys); -+ -+ hotkey_list = g_strsplit_set (hotkeys, ";,", 0); ++ g_assert (BUS_IS_IBUS_IMPL (ibus)); + -+ for (p = hotkey_list; p && *p; ++p) { -+ hotkey = g_strstrip (*p); -+ if (!*hotkey || !ibus_key_event_from_string (hotkey, &keyval, &modifiers)) { -+ continue; ++ engine_list = ibus->register_engine_list; ++ if (value != NULL && g_variant_classify (value) == G_VARIANT_CLASS_ARRAY) { ++ GVariantIter iter; ++ g_variant_iter_init (&iter, value); ++ const gchar *engine_name = NULL; ++ while (g_variant_iter_loop (&iter, "&s", &engine_name)) { ++ IBusEngineDesc *engine = bus_registry_find_engine_by_name (ibus->registry, engine_name); ++ if (engine == NULL || g_list_find (engine_list, engine) != NULL) ++ continue; ++ engine_list = g_list_append (engine_list, g_object_ref (engine)); + } ++ } else if (value != NULL) { ++ g_variant_unref (value); ++ } + -+ /* If the hotkey already exists, we won't need to add it again. */ -+ event = ibus_hotkey_profile_lookup_hotkey (ibus->engines_hotkey_profile, -+ keyval, modifiers); -+ if (event == 0) { -+ event = g_quark_from_string (hotkey); -+ ibus_hotkey_profile_add_hotkey (ibus->engines_hotkey_profile, -+ keyval, modifiers, event); ++ ibus->register_engine_list = engine_list; ++ ++ if (engine_list) { ++ BusComponent *component = bus_component_from_engine_desc ((IBusEngineDesc *) engine_list->data); ++ if (component && !bus_component_is_running (component)) { ++ bus_component_start (component, g_verbose); + } ++ } ++} + -+ engine_list = g_hash_table_lookup (ibus->hotkey_to_engines_map, -+ GUINT_TO_POINTER (event)); ++static void ++_set_default_keyboard_layout_engines (BusIBusImpl *ibus) ++{ ++ GList *engines = NULL; ++ GList *list; ++ GVariantBuilder builder; + -+ /* As we will rebuild the engines hotkey map whenever an engine was -+ * added or removed, we don't need to hold a reference of the engine -+ * here. */ -+ engine_list = g_list_append (engine_list, engine); ++ g_assert (BUS_IS_IBUS_IMPL (ibus)); + -+ /* We need to steal the value before adding it back, otherwise it will -+ * be destroyed. */ -+ g_hash_table_steal (ibus->hotkey_to_engines_map, GUINT_TO_POINTER (event)); ++ engines = bus_registry_get_engines_by_name_prefix (ibus->registry, ++ DEFAULT_BRIDGE_ENGINE_NAME); ++ /* sort engines by rank */ ++ engines = g_list_sort (engines, (GCompareFunc) _engine_desc_name_cmp); + -+ g_hash_table_insert (ibus->hotkey_to_engines_map, -+ GUINT_TO_POINTER (event), engine_list); ++ g_variant_builder_init (&builder, G_VARIANT_TYPE ("as")); ++ for (list = engines; list != NULL; list = list->next) { ++ IBusEngineDesc *desc = (IBusEngineDesc *)list->data; ++ g_variant_builder_add (&builder, "s", ibus_engine_desc_get_name (desc)); + } ++ _set_register_engines (ibus, g_variant_builder_end (&builder)); ++ g_list_free (engines); ++} ++#endif + -+ g_strfreev (hotkey_list); - } - /** -@@ -1216,7 +1402,71 @@ _context_request_engine_cb (BusInputCont + * bus_ibus_impl_set_preload_engines: + * +@@ -658,6 +910,9 @@ bus_ibus_impl_set_preload_engines (BusIB + _set_preload_engines (ibus, value); + } + } ++#if USE_BRIDGE_HOTKEY ++ _set_default_keyboard_layout_engines (ibus); ++#endif + #else + _set_preload_engines (ibus, value); + #endif +@@ -1216,7 +1471,71 @@ _context_request_engine_cb (BusInputCont const gchar *engine_name, BusIBusImpl *ibus) { @@ -428,7 +462,22 @@ index f13d8e0..44fe954 100644 } /** -@@ -2270,6 +2520,9 @@ bus_ibus_impl_filter_keyboard_shortcuts +@@ -1255,8 +1574,13 @@ bus_ibus_impl_get_engine_desc (BusIBusIm + if (!desc) { + if (ibus->register_engine_list) { + desc = (IBusEngineDesc *) ibus->register_engine_list->data; ++#if USE_BRIDGE_HOTKEY ++ if (engine_name == NULL) { ++ desc = NULL; ++ } ++#endif + } +- else if (ibus->engine_list) { ++ if (!desc && ibus->engine_list) { + desc = (IBusEngineDesc *) ibus->engine_list->data; + } + } +@@ -2267,6 +2591,9 @@ bus_ibus_impl_filter_keyboard_shortcuts GQuark event; GList *engine_list; @@ -438,7 +487,7 @@ index f13d8e0..44fe954 100644 if (trigger == 0) { trigger = g_quark_from_static_string ("trigger"); -@@ -2334,6 +2587,12 @@ bus_ibus_impl_filter_keyboard_shortcuts +@@ -2331,6 +2658,12 @@ bus_ibus_impl_filter_keyboard_shortcuts return FALSE; } @@ -451,7 +500,7 @@ index f13d8e0..44fe954 100644 /* Then try engines hotkeys. */ event = ibus_hotkey_profile_filter_key_event (ibus->engines_hotkey_profile, keyval, -@@ -2355,6 +2614,24 @@ bus_ibus_impl_filter_keyboard_shortcuts +@@ -2352,6 +2685,24 @@ bus_ibus_impl_filter_keyboard_shortcuts g_assert (new_engine_desc); @@ -476,7 +525,7 @@ index f13d8e0..44fe954 100644 /* Find out what engine we should switch to. If the current engine has * the same hotkey, then we should switch to the next engine with the * same hotkey in the list. Otherwise, we just switch to the first -@@ -2366,8 +2643,47 @@ bus_ibus_impl_filter_keyboard_shortcuts +@@ -2363,8 +2714,47 @@ bus_ibus_impl_filter_keyboard_shortcuts break; } } @@ -486,7 +535,7 @@ index f13d8e0..44fe954 100644 + if (context == NULL) { + return FALSE; + } -+ + + /* This means RequestEngine signal might be done but SetEngine signal + * has not been done yet by ibus status icon. */ + if (current_engine_desc == NULL && @@ -501,7 +550,7 @@ index f13d8e0..44fe954 100644 + current_engine_desc); + } + } - ++ + /* If the previous engine is not included in engine_list and + * the current engine is the defualt bridge engine, + * the current engine is also not included in engine_list. @@ -524,7 +573,7 @@ index f13d8e0..44fe954 100644 bus_ibus_impl_set_context_engine_from_desc (ibus, context, new_engine_desc); } -@@ -2472,59 +2788,54 @@ static void +@@ -2468,59 +2858,54 @@ static void _add_engine_hotkey (IBusEngineDesc *engine, BusIBusImpl *ibus) { const gchar *hotkeys; @@ -719,7 +768,7 @@ index bc4e096..c79e033 100644 G_END_DECLS #endif diff --git a/bus/registry.c b/bus/registry.c -index 7b74781..07e9148 100644 +index 7b74781..28e2abf 100644 --- a/bus/registry.c +++ b/bus/registry.c @@ -19,6 +19,11 @@ @@ -785,6 +834,59 @@ index 7b74781..07e9148 100644 } static void +@@ -516,6 +552,31 @@ bus_registry_get_engines_by_language (BusRegistry *registry, + return engines; + } + ++GList * ++bus_registry_get_engines_by_name_prefix (BusRegistry *registry, ++ const gchar *name_prefix) ++{ ++ GList *p1, *p2; ++ GList *engines = NULL; ++ ++ g_assert (BUS_IS_REGISTRY (registry)); ++ g_assert (name_prefix); ++ ++ p1 = bus_registry_get_engines (registry); ++ ++ for (p2 = p1; p2 != NULL; p2 = p2->next) { ++ IBusEngineDesc *desc = (IBusEngineDesc *) p2->data; ++ if (g_ascii_strncasecmp (ibus_engine_desc_get_name (desc), ++ name_prefix, ++ strlen (name_prefix)) == 0) { ++ engines = g_list_append (engines, desc); ++ } ++ } ++ ++ g_list_free (p1); ++ return engines; ++} ++ + IBusEngineDesc * + bus_registry_find_engine_by_name (BusRegistry *registry, + const gchar *name) +diff --git a/bus/registry.h b/bus/registry.h +index cdabec0..721187c 100644 +--- a/bus/registry.h ++++ b/bus/registry.h +@@ -73,6 +73,16 @@ GList *bus_registry_get_engines_by_language + const gchar *language); + + /** ++ * bus_registry_get_engines_by_name_prefix: ++ * @name_prefix: a prefix in the name of IBusEngineDesc. ++ * @returns: a list of IBusEngineDesc objects which has the name prefix. ++ * The caller has to call g_list_free for the returned list. ++ */ ++GList *bus_registry_get_engines_by_name_prefix ++ (BusRegistry *registry, ++ const gchar *name_prefix); ++ ++/** + * bus_registry_stop_all_components: + * + * Terminate all component processes. diff --git a/configure.ac b/configure.ac index 4c20ae7..21d35c3 100644 --- a/configure.ac @@ -844,7 +946,7 @@ diff --git a/data/Makefile.am b/data/Makefile.am index 99be41c..824da76 100644 --- a/data/Makefile.am +++ b/data/Makefile.am -@@ -30,7 +30,8 @@ SUBDIRS = \ +@@ -26,7 +26,8 @@ SUBDIRS = \ $(NULL) schemasdir = $(GCONF_SCHEMA_FILE_DIR) @@ -854,7 +956,7 @@ index 99be41c..824da76 100644 schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) @INTLTOOL_SCHEMAS_RULE@ -@@ -45,11 +46,12 @@ if GCONF_SCHEMAS_INSTALL +@@ -41,11 +42,12 @@ if GCONF_SCHEMAS_INSTALL endif EXTRA_DIST = \ @@ -869,7 +971,7 @@ index 99be41c..824da76 100644 -include $(top_srcdir)/git.mk diff --git a/data/ibus.schemas.in b/data/ibus.schemas.in.in -index 7ca4899..42d9297 +index 8979515..2a2b459 --- a/data/ibus.schemas.in +++ b/data/ibus.schemas.in.in @@ -31,7 +31,7 @@ @@ -952,7 +1054,7 @@ index 1d3cd2a..58d75e5 100644 @method() def Destroy(self): pass diff --git a/ibus/xkbxml.py.in b/ibus/xkbxml.py.in -index 16f47df..85d0651 100644 +index 9407c13..bf61810 100644 --- a/ibus/xkbxml.py.in +++ b/ibus/xkbxml.py.in @@ -33,6 +33,8 @@ import enginedesc @@ -964,11 +1066,11 @@ index 16f47df..85d0651 100644 try: from glib import get_user_config_dir -@@ -312,6 +314,8 @@ class XKBConfigRegistry(): +@@ -315,6 +317,8 @@ class XKBConfigRegistry(): engine_layout = layout icon = 'ibus-engine' -+ if name_prefix == DEFAULT_BRIDGE_ENGINE_NAME: ++ if name.startswith(DEFAULT_BRIDGE_ENGINE_NAME): + icon = get_ICON_KEYBOARD() engine = enginedesc.EngineDesc(name, longname, desc, lang, @@ -988,25 +1090,10 @@ index 7383177..d35757d 100644 if l not in lang: lang[l] = [] diff --git a/setup/enginetreeview.py b/setup/enginetreeview.py -index f620361..20cde3b 100644 +index f620361..664dc99 100644 --- a/setup/enginetreeview.py +++ b/setup/enginetreeview.py -@@ -162,6 +162,14 @@ class EngineTreeView(gtk.TreeView): - return row[0] - elif property.name == "engines": - engines = [ r[0] for r in self.__model if r[0] != None] -+ for i, e in enumerate(self.__engines): -+ if ibus.use_bridge_hotkey() and \ -+ e.name.startswith(ibus.DEFAULT_BRIDGE_ENGINE_NAME): -+ if i < len(engines): -+ engines.insert(i, e) -+ else: -+ engines.append(e) -+ break - return engines - else: - raise AttributeError, 'unknown property %s' % property.name -@@ -172,8 +180,12 @@ class EngineTreeView(gtk.TreeView): +@@ -172,8 +172,12 @@ class EngineTreeView(gtk.TreeView): for e in engines: if e in self.__engines: continue @@ -1248,24 +1335,19 @@ index 7cf1995..a19d16e 100644 +const gchar * ibus_get_default_bridge_engine_name (void); + #endif -diff --git a/ui/gtk/Makefile.am b/ui/gtk/Makefile.am -index 1f19748..1702613 100644 ---- a/ui/gtk/Makefile.am -+++ b/ui/gtk/Makefile.am -@@ -33,6 +33,8 @@ ui_gtk_PYTHON = \ - propitem.py \ - toolitem.py \ - engineabout.py \ -+ xkbengine.py \ -+ xkbfactory.py \ - $(NULL) - ui_gtkdir = $(pkgdatadir)/ui/gtk - diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py -index 8804634..d87c1d2 100644 +index 8804634..f7b3e50 100644 --- a/ui/gtk/panel.py +++ b/ui/gtk/panel.py -@@ -133,6 +133,15 @@ class Panel(ibus.PanelBase): +@@ -67,6 +67,7 @@ class Panel(ibus.PanelBase): + self.__data_dir = path.join(self.__prefix, "share", "ibus") + # self.__icons_dir = path.join(self.__data_dir, "icons") + self.__setup_cmd = path.join(self.__prefix, "bin", "ibus-setup") ++ self.__show = 0 + + # connect bus signal + self.__config.connect("value-changed", self.__config_value_changed_cb) +@@ -133,6 +134,14 @@ class Panel(ibus.PanelBase): # self.__bus.request_name(ibus.panel.IBUS_SERVICE_PANEL, 0) # init xkb @@ -1276,7 +1358,6 @@ index 8804634..d87c1d2 100644 + self.__disabled_engines_id = -1 + self.__disabled_engines_prev_id = -1 + self.__disabled_engines_swapped = 0 -+ self.__show = 0 + self.__xkblayout = ibus.XKBLayout(self.__config) use_xkb = self.__config.get_value("general", "use_system_keyboard_layout", False) @@ -1300,7 +1381,7 @@ index 8804634..d87c1d2 100644 def set_cursor_location(self, x, y, w, h): self.__candidate_panel.set_cursor_location(x, y, w, h) -@@ -233,12 +249,113 @@ class Panel(ibus.PanelBase): +@@ -233,12 +249,91 @@ class Panel(ibus.PanelBase): def __set_im_name(self, name): self.__language_bar.set_im_name(name) @@ -1343,37 +1424,15 @@ index 8804634..d87c1d2 100644 + model_desc = _("Default Layout") + if model != None: + model_desc = model_desc + " (" + model + ")" ++ name = ibus.DEFAULT_BRIDGE_ENGINE_NAME + "#" + str(i) + engine = registry.engine_desc_new(lang, + layout, + _("Default Layout"), + model, + model_desc, -+ ibus.DEFAULT_BRIDGE_ENGINE_NAME) ++ name) + self.__disabled_engines.append(engine) + self.__disabled_engines_id = self.__xkblayout.get_group() -+ if not use_bridge_hotkey: -+ return -+ if self.__disabled_engines != None and self.__disabled_engines != []: -+ component = ibus.Component("org.freedesktop.IBus.XKB", -+ _("XKB Component"), -+ "1.0", -+ "GPL", -+ "Takao Fujiwara", -+ "https://github.com/fujiwarat/ibus/tree/gjs") -+ for engine in self.__disabled_engines: -+ component.add_engine(engine.name, -+ engine.longname, -+ engine.description, -+ engine.language, -+ engine.license, -+ engine.author, -+ engine.icon, -+ engine.layout, -+ engine.hotkeys) -+ -+ import xkbfactory -+ self.__factory = xkbfactory.EngineFactory(self.__bus) -+ self.__bus.register_component(component) + if not use_bridge_hotkey: + return + if self.__disabled_engines != None and self.__disabled_engines != []: @@ -1415,7 +1474,7 @@ index 8804634..d87c1d2 100644 if not enabled: self.__set_im_icon(ICON_KEYBOARD) self.__set_im_name(None) -@@ -250,7 +367,7 @@ class Panel(ibus.PanelBase): +@@ -250,7 +345,7 @@ class Panel(ibus.PanelBase): self.__set_im_icon(engine.icon) self.__set_im_name(engine.longname) if self.__bus.get_use_sys_layout(): @@ -1424,7 +1483,7 @@ index 8804634..d87c1d2 100644 else: self.__set_im_icon(ICON_KEYBOARD) self.__set_im_name(None) -@@ -260,6 +377,8 @@ class Panel(ibus.PanelBase): +@@ -260,6 +355,8 @@ class Panel(ibus.PanelBase): def focus_out(self, ic): self.reset() @@ -1433,7 +1492,7 @@ index 8804634..d87c1d2 100644 self.__focus_ic = None self.__language_bar.set_enabled(False) self.__language_bar.focus_out() -@@ -273,7 +392,21 @@ class Panel(ibus.PanelBase): +@@ -273,7 +370,21 @@ class Panel(ibus.PanelBase): return enabled = self.__focus_ic.is_enabled() @@ -1456,7 +1515,7 @@ index 8804634..d87c1d2 100644 if enabled == False: self.reset() -@@ -287,7 +420,7 @@ class Panel(ibus.PanelBase): +@@ -287,7 +398,7 @@ class Panel(ibus.PanelBase): self.__set_im_icon(engine.icon) self.__set_im_name(engine.longname) if self.__bus.get_use_sys_layout(): @@ -1465,7 +1524,7 @@ index 8804634..d87c1d2 100644 else: self.__set_im_icon(ICON_KEYBOARD) self.__set_im_name(None) -@@ -315,6 +448,7 @@ class Panel(ibus.PanelBase): +@@ -315,6 +426,7 @@ class Panel(ibus.PanelBase): def __config_load_show(self): show = self.__config.get_value("panel", "show", 0) @@ -1473,7 +1532,7 @@ index 8804634..d87c1d2 100644 self.__language_bar.set_show(show) def __config_load_position(self): -@@ -443,6 +577,21 @@ class Panel(ibus.PanelBase): +@@ -443,6 +555,21 @@ class Panel(ibus.PanelBase): # menu.set_take_focus(False) # return menu @@ -1495,7 +1554,7 @@ index 8804634..d87c1d2 100644 def __create_im_menu(self): engines = self.__bus.list_active_engines() current_engine = \ -@@ -453,25 +602,34 @@ class Panel(ibus.PanelBase): +@@ -453,25 +580,39 @@ class Panel(ibus.PanelBase): size = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) menu = gtk.Menu() for i, engine in enumerate(engines): @@ -1511,19 +1570,24 @@ index 8804634..d87c1d2 100644 - item.set_image(_icon.IconWidget(ICON_ENGINE, size[0])) - item.connect("activate", self.__im_menu_item_activate_cb, engine) - menu.add(item) -+ if self.__use_bridge_hotkey() and \ -+ engine.name.startswith(ibus.DEFAULT_BRIDGE_ENGINE_NAME) and \ -+ self.__disabled_engines != None: -+ engine.is_bridge = True -+ engine.disabled_engines_id = 0 ++ if engine.name.startswith(ibus.DEFAULT_BRIDGE_ENGINE_NAME): ++ if not self.__use_bridge_hotkey(): ++ continue ++ if self.__disabled_engines == None: ++ continue ++ engine.disabled_engines_id = -1 + for j, kb_engine in enumerate(self.__disabled_engines): + if engine.name == kb_engine.name: + engine.disabled_engines_id = j + break ++ if engine.disabled_engines_id == -1: ++ continue ++ kb_engine = self.__disabled_engines[engine.disabled_engines_id] ++ kb_engine.is_bridge = True ++ kb_engine.disabled_engines_id = engine.disabled_engines_id + is_bold = True if (current_engine != None and \ -+ current_engine.name == engine.name and \ -+ j == self.__disabled_engines_id) else False -+ self.__add_engine_in_menu(menu, engine, ++ current_engine.name == kb_engine.name) else False ++ self.__add_engine_in_menu(menu, kb_engine, + is_bold, + size) + continue @@ -1543,7 +1607,7 @@ index 8804634..d87c1d2 100644 menu.show_all() menu.set_take_focus(False) -@@ -523,8 +681,25 @@ class Panel(ibus.PanelBase): +@@ -523,8 +664,25 @@ class Panel(ibus.PanelBase): if not self.__focus_ic: return if engine: @@ -1570,7 +1634,7 @@ index 8804634..d87c1d2 100644 self.__focus_ic.disable() def __sys_menu_item_activate_cb(self, item, command): -@@ -573,12 +748,85 @@ class Panel(ibus.PanelBase): +@@ -573,12 +731,85 @@ class Panel(ibus.PanelBase): self.__setup_pid = pid glib.child_watch_add(self.__setup_pid, self.__child_watch_cb) @@ -1658,228 +1722,6 @@ index 8804634..d87c1d2 100644 elif engine.layout != None and engine.layout.startswith("default"): return engine.layout else: -diff --git a/ui/gtk/xkbengine.py b/ui/gtk/xkbengine.py -new file mode 100644 -index 0000000..12c07cf ---- /dev/null -+++ b/ui/gtk/xkbengine.py -@@ -0,0 +1,93 @@ -+# vim:set et sts=4 sw=4: -+# -+# ibus - The Input Bus -+# -+# Copyright(c) 2011 Peng Huang -+# Copyright(c) 2011 Takao Fujiwara -+# Copyright(c) 2011 Red Hat, Inc. -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2 of the License, or(at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this program; if not, write to the -+# Free Software Foundation, Inc., 59 Temple Place, Suite 330, -+# Boston, MA 02111-1307 USA -+ -+import ibus -+ -+class Engine(ibus.EngineBase): -+ def __init__(self, bus, object_path): -+ super(Engine, self).__init__(bus, object_path) -+ -+ def update_aux_string(self, string, attrs, visible): -+ self.update_auxiliary_text(ibus.Text(string, attrs), visible) -+ -+ def page_up(self): -+ return True -+ -+ def page_down(self): -+ return True -+ -+ def cursor_up(self): -+ return True -+ -+ def cursor_down(self): -+ return True -+ -+ def candidate_clicked(self, index, button, state): -+ pass -+ -+ if ibus.get_version() >= '1.2.0': -+ def process_key_event(self, keyval, keycode, state): -+ try: -+ return self.process_key_event_internal2(keyval, keycode, state) -+ except: -+ import traceback -+ traceback.print_exc() -+ return False -+ else: -+ def process_key_event(self, keyval, state): -+ try: -+ return self.process_key_event_internal2(keyval, 0, state) -+ except: -+ import traceback -+ traceback.print_exc() -+ return False -+ -+ def property_activate(self, prop_name, state): -+ pass -+ -+ def focus_in(self): -+ pass -+ -+ def focus_out(self): -+ pass -+ -+ def disable(self): -+ pass -+ -+ def reset(self): -+ pass -+ -+ def do_destroy(self): -+ super(Engine,self).do_destroy() -+ -+#======================================================================= -+ @classmethod -+ def CONFIG_RELOADED(cls, bus): -+ print 'RELOADED' -+ -+ @classmethod -+ def CONFIG_VALUE_CHANGED(cls, bus, section, name, value): -+ print 'VALUE_CHAMGED =', section, name, value -+ -+ def process_key_event_internal2(self, keyval, keycode, state): -+ return False -diff --git a/ui/gtk/xkbfactory.py b/ui/gtk/xkbfactory.py -new file mode 100644 -index 0000000..014e20b ---- /dev/null -+++ b/ui/gtk/xkbfactory.py -@@ -0,0 +1,117 @@ -+# vim:set et sts=4 sw=4: -+# -+# ibus - The Input Bus -+# -+# Copyright(c) 2011 Peng Huang -+# Copyright(c) 2011 Takao Fujiwara -+# Copyright(c) 2011 Red Hat, Inc. -+# -+# This library is free software; you can redistribute it and/or -+# modify it under the terms of the GNU Lesser General Public -+# License as published by the Free Software Foundation; either -+# version 2 of the License, or(at your option) any later version. -+# -+# This library is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU Lesser General Public License for more details. -+# -+# You should have received a copy of the GNU Lesser General Public -+# License along with this program; if not, write to the -+# Free Software Foundation, Inc., 59 Temple Place, Suite 330, -+# Boston, MA 02111-1307 USA -+ -+import ibus -+import xkbengine -+ -+from gettext import dgettext -+_ = lambda a : dgettext("ibus", a) -+N_ = lambda a : a -+ -+ -+class EngineFactory(ibus.EngineFactoryBase): -+ FACTORY_PATH = "/com/redhat/IBus/engines/XKB/Factory" -+ ENGINE_PATH = "/com/redhat/IBus/engines/XKB/Engine" -+ NAME = "XKBFactory" -+ LANG = "en" -+ ICON = "ibus-engine" -+ AUTHORS = "Takao Fujiwara " -+ CREDITS = "GPLv2" -+ -+ def __init__(self, bus): -+ self.__bus = bus -+ super(EngineFactory, self).__init__(bus) -+ -+ self.__id = 0 -+ -+ def create_engine(self, engine_name): -+ if engine_name and \ -+ engine_name.startswith(ibus.DEFAULT_BRIDGE_ENGINE_NAME): -+ -+ self.__id += 1 -+ return xkbengine.Engine(self.__bus, "%s/%d" % (self.ENGINE_PATH, self.__id)) -+ return super(EngineFactory, self).create_engine(engine_name) -+ -+ -+def test(): -+ import gtk -+ component = ibus.Component("org.freedesktop.IBus.XKB", -+ _("XKB Component"), -+ "1.0", -+ "GPL", -+ "Takao Fujiwara", -+ "https://github.com/fujiwara") -+ engines = [] -+ engine = ibus.EngineDesc("xkb:layout:default:jp,us", -+ "Default Layout", -+ "XKB jp,us keyboard layout", -+ "jpn", -+ "LGPL2.1", -+ "fujiwara", -+ "ibus-engine", -+ "jp,us") -+ engines.append(engine) -+ engine = ibus.EngineDesc("xkb:layout:default:us", -+ "Default Layout", -+ "XKB us keyboard layout", -+ "eng", -+ "LGPL2.1", -+ "fujiwara", -+ "ibus-engine", -+ "us") -+ engines.append(engine) -+ for engine in engines: -+ component.add_engine(engine.name, -+ engine.longname, -+ engine.description, -+ engine.language, -+ engine.license, -+ engine.author, -+ engine.icon, -+ engine.layout, -+ engine.hotkeys) -+ -+ class TestWindow(gtk.Window): -+ def __init__(self): -+ super(TestWindow, self).__init__() -+ self.__bus = ibus.Bus() -+ self.__bus.connect("disconnected", gtk.main_quit) -+ path = self.__bus.create_input_context("Test") -+ self.__ic = ibus.InputContext(self.__bus, path) -+ self.__ic.set_capabilities(9) -+ factory = EngineFactory(self.__bus) -+ self.__bus.register_component(component) -+ #self.__bus.request_name("org.freedesktop.IBus.XKB", 0) -+ self.connect("focus-in-event", self.__focus_in) -+ -+ def __focus_in(self, widget, event): -+ print "focused in" -+ self.__ic.focus_in() -+ self.__ic.set_engine(engines[0]) -+ -+ window = TestWindow() -+ window.show_all() -+ gtk.main() -+ -+if __name__ == "__main__": -+ test() diff --git a/xkb/Makefile.am b/xkb/Makefile.am index ad9cdd9..c4d5afb 100644 --- a/xkb/Makefile.am @@ -1893,8 +1735,59 @@ index ad9cdd9..c4d5afb 100644 $(NULL) noinst_PROGRAMS = $(TESTS) +diff --git a/xkb/ibus-engine-xkb-main.c b/xkb/ibus-engine-xkb-main.c +index 0fb0f0c..4787bf2 100644 +--- a/xkb/ibus-engine-xkb-main.c ++++ b/xkb/ibus-engine-xkb-main.c +@@ -25,6 +25,7 @@ + #endif + + #include ++#include + #include + + #ifdef ENABLE_NLS +@@ -290,6 +291,9 @@ print_component () + const gchar *desc; + gchar *output; + GString *str; ++#if USE_BRIDGE_HOTKEY ++ int i; ++#endif + + #ifdef XKBLAYOUTCONFIG_FILE + layout_config = ibus_xkb_layout_config_new (XKBLAYOUTCONFIG_FILE); +@@ -302,6 +306,19 @@ print_component () + layout_desc = (GHashTable *) ibus_xkb_config_registry_get_layout_desc (config_registry); + variant_desc = (GHashTable *) ibus_xkb_config_registry_get_variant_desc (config_registry); + component = ibus_xkb_component_new (); ++#if USE_BRIDGE_HOTKEY ++ for (i = 0; i < 4; i++) { ++ gchar *name = g_strdup_printf ("%s#%d", DEFAULT_BRIDGE_ENGINE_NAME, i); ++ engine = ibus_xkb_engine_desc_new ("eng", ++ "us", ++ _("Default Layout"), ++ NULL, ++ NULL, ++ name); ++ g_free (name); ++ ibus_component_add_engine (component, engine); ++ } ++#endif + for (keys = g_hash_table_get_keys (layout_list); keys; keys = keys->next) { + if (keys->data == NULL) { + continue; +@@ -390,6 +407,8 @@ main (int argc, char **argv) + + #ifdef ENABLE_NLS + setlocale (LC_ALL, ""); ++ bindtextdomain (GETTEXT_PACKAGE, IBUS_LOCALEDIR); ++ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + #endif + + g_type_init (); diff --git a/xkb/xkbxml.c b/xkb/xkbxml.c -index ad10c28..968fb86 100644 +index d59a929..86bcf8f 100644 --- a/xkb/xkbxml.c +++ b/xkb/xkbxml.c @@ -25,6 +25,7 @@ @@ -1905,15 +1798,15 @@ index ad10c28..968fb86 100644 #include "xkbxml.h" #include "ibus.h" -@@ -274,6 +275,7 @@ ibus_xkb_engine_desc_new (const gchar *lang, - gchar *longname = NULL; +@@ -275,6 +276,7 @@ ibus_xkb_engine_desc_new (const gchar *l gchar *desc = NULL; gchar *engine_layout = NULL; + const gchar *name_prefix = "xkb:layout:"; + const gchar *icon = "ibus-engine"; g_return_val_if_fail (lang != NULL && layout != NULL, NULL); -@@ -298,6 +300,12 @@ ibus_xkb_engine_desc_new (const gchar *lang, +@@ -304,6 +306,12 @@ ibus_xkb_engine_desc_new (const gchar *l desc = g_strdup_printf ("XKB %s keyboard layout", layout); engine_layout = g_strdup (layout); } @@ -1926,7 +1819,7 @@ index ad10c28..968fb86 100644 engine = ibus_engine_desc_new (name, longname, -@@ -305,7 +313,7 @@ ibus_xkb_engine_desc_new (const gchar *lang, +@@ -311,7 +319,7 @@ ibus_xkb_engine_desc_new (const gchar *l lang, "LGPL2.1", "Takao Fujiwara ", diff --git a/ibus-xx-factory-signal.patch b/ibus-xx-factory-signal.patch index 04492b6..01b62c6 100644 --- a/ibus-xx-factory-signal.patch +++ b/ibus-xx-factory-signal.patch @@ -1,35 +1,17 @@ -From ff5db39a4651f4ecd3c2ba19dd315ed7b83662f4 Mon Sep 17 00:00:00 2001 +From 85d6a6d5d7e5673ac3bbc285589da18c48b562ae Mon Sep 17 00:00:00 2001 From: fujiwarat -Date: Fri, 5 Aug 2011 20:21:14 +0900 +Date: Sun, 14 Aug 2011 08:44:35 +0900 Subject: [PATCH] Add create-engine signal in IBusFactory for non-C applications. --- - bus/ibusimpl.c | 6 +++- - bus/inputcontext.c | 5 ++++ - src/ibusfactory.c | 54 ++++++++++++++++++++++++++++++++++++++++------- - src/ibusfactory.h | 7 +++++- + bus/inputcontext.c | 5 ++ + src/ibusfactory.c | 107 ++++++++++++++++++++++++++++++++++++++++------- + src/ibusfactory.h | 7 +++- src/ibusmarshalers.list | 1 + - src/ibusservice.h | 5 +-- - 6 files changed, 64 insertions(+), 14 deletions(-) + src/ibusservice.h | 5 +- + 5 files changed, 105 insertions(+), 20 deletions(-) -diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c -index 853465c..f13d8e0 100644 ---- a/bus/ibusimpl.c -+++ b/bus/ibusimpl.c -@@ -1604,8 +1604,10 @@ _ibus_register_component (BusIBusImpl *ibus, - g_object_ref_sink (buscomp)); - GList *engines = bus_component_get_engines (buscomp); - g_list_foreach (engines, (GFunc) g_object_ref, NULL); -- ibus->register_engine_list = g_list_concat (ibus->register_engine_list, -- engines); -+ /* We always override the register_engine_list or need to prepare -+ * unregister_component() method so that both ibus gtk and gnome-shell -+ * can call register_component. */ -+ ibus->register_engine_list = engines; - - g_signal_connect (buscomp, "destroy", G_CALLBACK (_component_destroy_cb), ibus); - diff --git a/bus/inputcontext.c b/bus/inputcontext.c index 47ac9d5..4e8cdc5 100644 --- a/bus/inputcontext.c @@ -47,7 +29,7 @@ index 47ac9d5..4e8cdc5 100644 g_object_unref (engine); bus_input_context_enable (data->context); diff --git a/src/ibusfactory.c b/src/ibusfactory.c -index 11d9a6d..f72f51e 100644 +index 11d9a6d..f28f074 100644 --- a/src/ibusfactory.c +++ b/src/ibusfactory.c @@ -21,6 +21,7 @@ @@ -75,17 +57,82 @@ index 11d9a6d..f72f51e 100644 /* functions prototype */ static void ibus_factory_destroy (IBusFactory *factory); static void ibus_factory_set_property (IBusFactory *engine, -@@ -113,6 +117,17 @@ ibus_factory_class_init (IBusFactoryClass *class) +@@ -95,6 +99,47 @@ static const gchar introspection_xml[] = + " " + ""; + ++static IBusEngine * ++_ibus_factory_create_engine (IBusFactory *factory, ++ const gchar *engine_name) ++{ ++ GType engine_type; ++ gchar *object_path = NULL; ++ IBusEngine *engine = NULL; ++ ++ engine_type = (GType) g_hash_table_lookup (factory->priv->engine_table, ++ engine_name); ++ ++ g_return_val_if_fail (engine_type != G_TYPE_INVALID, NULL); ++ ++ object_path = g_strdup_printf ("/org/freedesktop/IBus/Engine/%d", ++ ++factory->priv->id); ++ engine = ibus_engine_new_type (engine_type, ++ engine_name, ++ object_path, ++ ibus_service_get_connection ((IBusService *)factory)); ++ g_free (object_path); ++ ++ return engine; ++} ++ ++static gboolean ++_ibus_factory_create_engine_accumulator (GSignalInvocationHint *ihint, ++ GValue *return_accu, ++ const GValue *handler_return, ++ gpointer dummy) ++{ ++ gboolean retval = TRUE; ++ GObject *object = g_value_get_object (handler_return); ++ ++ if (object != NULL) { ++ g_value_copy (handler_return, return_accu); ++ retval = FALSE; ++ } ++ ++ return retval; ++} ++ + static void + ibus_factory_class_init (IBusFactoryClass *class) + { +@@ -109,10 +154,34 @@ ibus_factory_class_init (IBusFactoryClass *class) + IBUS_SERVICE_CLASS (class)->service_method_call = ibus_factory_service_method_call; + IBUS_SERVICE_CLASS (class)->service_get_property = ibus_factory_service_get_property; + IBUS_SERVICE_CLASS (class)->service_set_property = ibus_factory_service_set_property; ++ class->create_engine = _ibus_factory_create_engine; + ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml); g_type_class_add_private (class, sizeof (IBusFactoryPrivate)); + ++ /** ++ * IBusFactory::create-engine: ++ * @factory: the factory which received the signal ++ * @engine_name: the engine_name which received the signal ++ * @returns: (transfer none): An IBusEngine ++ * ++ * The ::create-engine signal is a signal to create IBusEngine ++ * with @engine_name, which gets emitted when IBusFactory ++ * received CreateEngine dbus method. The callback functions ++ * will be called until a callback returns a non-null object ++ * of IBusEngine. */ + factory_signals[CREATE_ENGINE] = + g_signal_new (I_("create-engine"), + G_TYPE_FROM_CLASS (gobject_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (IBusFactoryClass, create_engine), -+ NULL, NULL, ++ _ibus_factory_create_engine_accumulator, ++ NULL, + _ibus_marshal_OBJECT__STRING, + IBUS_TYPE_ENGINE, + 1, @@ -93,32 +140,34 @@ index 11d9a6d..f72f51e 100644 } static void -@@ -190,8 +205,20 @@ ibus_factory_service_method_call (IBusService *service, +@@ -190,25 +259,23 @@ ibus_factory_service_method_call (IBusService *service, if (g_strcmp0 (method_name, "CreateEngine") == 0) { gchar *engine_name = NULL; -+ GType engine_type; + IBusEngine *engine = NULL; + g_variant_get (parameters, "(&s)", &engine_name); - GType engine_type = (GType )g_hash_table_lookup (factory->priv->engine_table, engine_name); -+ engine_type = (GType) g_hash_table_lookup (factory->priv->engine_table, engine_name); ++ g_signal_emit (factory, factory_signals[CREATE_ENGINE], ++ 0, engine_name, &engine); + -+ if (engine_type == G_TYPE_INVALID) { -+ g_signal_emit (factory, factory_signals[CREATE_ENGINE], -+ 0, engine_name, &engine); ++ if (engine != NULL) { ++ gchar *object_path = NULL; ++ GValue value = { 0, }; + -+ if (engine != NULL && IBUS_IS_ENGINE (engine)) { -+ engine_type = G_OBJECT_TYPE (engine); -+ } -+ } ++ g_value_init (&value, G_TYPE_STRING); ++ g_object_get_property (G_OBJECT (engine), "object-path", &value); ++ object_path = g_value_dup_string (&value); ++ g_value_unset (&value); - if (engine_type == G_TYPE_INVALID) { - gchar *error_message = g_strdup_printf ("Can not fond engine %s", engine_name); -@@ -201,14 +228,25 @@ ibus_factory_service_method_call (IBusService *service, - error_message); - g_free (error_message); - } +- if (engine_type == G_TYPE_INVALID) { +- gchar *error_message = g_strdup_printf ("Can not fond engine %s", engine_name); +- g_dbus_method_invocation_return_error (invocation, +- G_DBUS_ERROR, +- G_DBUS_ERROR_FAILED, +- error_message); +- g_free (error_message); +- } - else { - gchar *object_path = g_strdup_printf ("/org/freedesktop/IBus/Engine/%d", - ++factory->priv->id); @@ -126,28 +175,26 @@ index 11d9a6d..f72f51e 100644 - engine_name, - object_path, - ibus_service_get_connection ((IBusService *)factory)); -+ else { -+ gchar *object_path = NULL; -+ if (engine == NULL) { -+ object_path = g_strdup_printf ("/org/freedesktop/IBus/Engine/%d", -+ ++factory->priv->id); -+ engine = ibus_engine_new_type (engine_type, -+ engine_name, -+ object_path, -+ ibus_service_get_connection ((IBusService *)factory)); -+ } else { -+ GValue value = { 0, }; -+ g_value_init (&value, G_TYPE_STRING); -+ g_object_get_property (G_OBJECT (engine), "object-path", &value); -+ object_path = g_value_dup_string (&value); -+ g_value_unset (&value); -+ } -+ g_assert (engine != NULL); + g_assert (object_path != NULL); g_object_ref_sink (engine); factory->priv->engine_list = g_list_append (factory->priv->engine_list, engine); g_signal_connect (engine, +@@ -219,6 +286,14 @@ ibus_factory_service_method_call (IBusService *service, + g_variant_new ("(o)", object_path)); + g_free (object_path); + } ++ else { ++ gchar *error_message = g_strdup_printf ("Can not fond engine %s", engine_name); ++ g_dbus_method_invocation_return_error (invocation, ++ G_DBUS_ERROR, ++ G_DBUS_ERROR_FAILED, ++ error_message); ++ g_free (error_message); ++ } + return; + } + diff --git a/src/ibusfactory.h b/src/ibusfactory.h index 47c06e0..03d1dea 100644 --- a/src/ibusfactory.h diff --git a/ibus.spec b/ibus.spec index c976b89..b54d56a 100644 --- a/ibus.spec +++ b/ibus.spec @@ -20,7 +20,7 @@ Name: ibus Version: 1.3.99.20110419 -Release: 13%{?dist} +Release: 14%{?dist} Summary: Intelligent Input Bus for Linux OS License: LGPLv2+ Group: System Environment/Libraries @@ -28,7 +28,7 @@ URL: http://code.google.com/p/ibus/ Source0: http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz Source1: xinput-ibus %if %have_gjsfile -Source2: http://fujiwara.fedorapeople.org/ibus/gnome-shell/ibus-gjs-1.3.99.20110806.tar.gz +Source2: http://fujiwara.fedorapeople.org/ibus/gnome-shell/ibus-gjs-1.3.99.20110814.tar.gz %endif Source3: https://www.transifex.net/projects/p/ibus/resource/master/l/da/download/ibus_master_da.po Patch0: ibus-HEAD.patch @@ -62,6 +62,9 @@ BuildRequires: iso-codes-devel %if %have_libxkbfile BuildRequires: libxkbfile-devel %endif +# for ibus-gjs-xx.tar.gz +BuildRequires: gjs +BuildRequires: gnome-shell Requires: %{name}-libs = %{version}-%{release} Requires: %{name}-gtk2 = %{version}-%{release} @@ -184,14 +187,6 @@ mv data/ibus.schemas.in data/ibus.schemas.in.in %patch91 -p1 -b .fallback-icon %build -%if %have_gjsfile -d=`basename %SOURCE2 .tar.gz` -cd $d -%configure -make %{?_smp_mflags} -cd .. -%endif - %if %have_libxkbfile aclocal -I m4 autoheader @@ -214,6 +209,16 @@ automake -a -c -f # make -C po update-gmo make %{?_smp_mflags} + +%if %have_gjsfile +d=`basename %SOURCE2 .tar.gz` +cd $d +export PKG_CONFIG_PATH=..:/usr/lib64/pkgconfig:/usr/lib/pkgconfig +%configure +make %{?_smp_mflags} +cd .. +%endif + %install rm -rf $RPM_BUILD_ROOT make DESTDIR=$RPM_BUILD_ROOT install @@ -364,7 +369,7 @@ fi %{_datadir}/gtk-doc/html/* %changelog -* Fri Aug 05 2011 Takao Fujiwara - 1.3.99.20110419-13 +* Fri Aug 12 2011 Takao Fujiwara - 1.3.99.20110419-14 - Updated ibus-HEAD.patch for upstream. - Removed ibus-435880-surrounding-text.patch as upstream. - Added ibus-711632-fedora-fallback-icon.patch diff --git a/sources b/sources index 90152fa..b0f89ef 100644 --- a/sources +++ b/sources @@ -1,3 +1,3 @@ d4f2729fecb92ae6b41f26c770b1a772 ibus-1.3.99.20110419.tar.gz -b2214490304ab89d599cf72d012fde3c ibus-gjs-1.3.99.20110806.tar.gz +8af38ef34d99c232c73a83735afa86dd ibus-gjs-1.3.99.20110814.tar.gz 698c90edf0f037488e1aa969804e891f ibus_master_da.po