From 1640e30cdc4d26a9247f6a74885c51f355433a7b Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Mar 17 2011 08:33:47 +0000 Subject: Fixed Bug 683484 - Timed out SetEngine when select an engine from panel. --- diff --git a/.gitignore b/.gitignore index a0e8a7a..bcd246c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,4 @@ ibus-1.3.6.tar.gz /ibus-1.3.99.20110206.tar.gz /ibus-ui-gjs-plugins-20110214.tar.bz2 /ibus-1.3.99.20110228.tar.gz -/gnome-shell-ibus-plugins-20110304.tar.bz2 +/gnome-shell-ibus-plugins-20110317.tar.bz2 diff --git a/ibus-657165-panel-libs.patch b/ibus-657165-panel-libs.patch index 401ebc2..b7b5b73 100644 --- a/ibus-657165-panel-libs.patch +++ b/ibus-657165-panel-libs.patch @@ -35,7 +35,7 @@ Subject: [PATCH] Implement APIs for another non-Python panel. src/ibustext.c | 18 ++ src/ibustext.h | 29 +++- src/ibustypes.h | 33 +++ - src/ibusutil.c | 169 ++++++++++++++++ + src/ibusutil.c | 180 ++++++++++++++++ src/ibusutil.h | 39 ++++ ui/gtk/gtkpanel.xml.in.in | 2 +- ui/gtk/main.py | 23 ++- @@ -704,18 +704,14 @@ diff --git a/bus/marshalers.list b/bus/marshalers.list index 15bdf02..514d6ea 100644 --- a/bus/marshalers.list +++ b/bus/marshalers.list -@@ -5,9 +5,10 @@ VOID:INT,UINT - VOID:UINT,UINT,UINT +@@ -4,6 +4,7 @@ VOID:INT,UINT VOID:INT,INT,INT,INT - VOID:STRING,INT --VOID:OBJECT - VOID:STRING,STRING,STRING -+VOID:OBJECT + VOID:OBJECT VOID:OBJECT,BOOLEAN +VOID:OBJECT,STRING VOID:OBJECT,UINT,BOOLEAN VOID:OBJECT,UINT,BOOLEAN,UINT - BOOL:UINT,UINT,UINT + VOID:STRING diff --git a/ibus/common.py b/ibus/common.py index cbc8d56..614d782 100644 --- a/ibus/common.py @@ -1146,7 +1142,7 @@ new file mode 100644 index 0000000..59291f9 --- /dev/null +++ b/src/ibusutil.c -@@ -0,0 +1,169 @@ +@@ -0,0 +1,180 @@ +/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ +/* vim:set et sts=4: */ +/* bus - The Input Bus @@ -1176,6 +1172,7 @@ index 0000000..59291f9 +#include +#include +#include ++#include +#include "ibusxml.h" + +#ifdef ENABLE_NLS @@ -1267,11 +1264,21 @@ index 0000000..59291f9 +const gchar * +ibus_get_language_name(const gchar *_locale) { + const gchar *retval; ++ gchar *p = NULL; ++ gchar *lang = NULL; + + if (__languages_dict == NULL ) { + _load_lang(); + } -+ retval = (const gchar *) g_hash_table_lookup (__languages_dict, _locale); ++ if ((p = strchr (_locale, '_')) != NULL) { ++ p = g_strndup (_locale, p - _locale); ++ } else { ++ p = g_strdup (_locale); ++ } ++ lang = g_ascii_strdown (p, -1); ++ g_free (p); ++ retval = (const gchar *) g_hash_table_lookup (__languages_dict, lang); ++ g_free (lang); + if (retval != NULL) { +#ifdef ENABLE_NLS + return dgettext("iso_639", retval); diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch index 5336954..3b0f1e5 100644 --- a/ibus-HEAD.patch +++ b/ibus-HEAD.patch @@ -94,3 +94,292 @@ index a2967cc..16104de 100644 -- 1.7.4.1 +From b9b2c42596e1a7394e89c11025074aed2fcb099a Mon Sep 17 00:00:00 2001 +From: Peng Huang +Date: Wed, 16 Mar 2011 10:02:47 -0400 +Subject: [PATCH] Fix issue of InputContext.SetEngine. + +InputContext.SetEngine returns error sometimes, because "request-engine" +signal handler calls an async function to set the engine of the context. +So checking context->engine != NULL just after emiting "request-engine" +signal is not correct. + +BUG=none +TEST=Linux desktop + +Review URL: http://codereview.appspot.com/4287049 +--- + bus/ibusimpl.c | 68 ++++++++++++++++++++++++----------- + bus/inputcontext.c | 97 +++++++++++++++++++++++++++++++++++++++++++-------- + bus/marshalers.list | 14 ++++---- + 3 files changed, 136 insertions(+), 43 deletions(-) + +diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c +index 8d4ec36..5a8e134 100644 +--- a/bus/ibusimpl.c ++++ b/bus/ibusimpl.c +@@ -186,6 +186,9 @@ static BusInputContext + (BusIBusImpl *ibus, + BusConnection *connection, + const gchar *client); ++static IBusEngineDesc ++ *bus_ibus_impl_get_engine_desc (BusIBusImpl *ibus, ++ const gchar *engine_name); + /* some callback functions */ + static void _context_engine_changed_cb (BusInputContext *context, + BusIBusImpl *ibus); +@@ -975,21 +978,30 @@ _find_engine_desc_by_name (BusIBusImpl *ibus, + * + * A callback function to be called when the "request-engine" signal is sent to the context. + */ +-static void ++static IBusEngineDesc * + _context_request_engine_cb (BusInputContext *context, + const gchar *engine_name, + BusIBusImpl *ibus) + { +- IBusEngineDesc *desc = NULL; ++ return bus_ibus_impl_get_engine_desc (ibus, engine_name); ++} + +- /* context should has focus before request an engine */ +- g_return_if_fail (bus_input_context_has_focus (context) || +- context == ibus->focused_context); ++/** ++ * bus_ibus_impl_get_engine_desc: ++ * ++ * Get the IBusEngineDesc by engine_name. If the engine_name is NULL, return ++ * a default engine desc. ++ */ ++static IBusEngineDesc * ++bus_ibus_impl_get_engine_desc (BusIBusImpl *ibus, ++ const gchar *engine_name) ++{ ++ IBusEngineDesc *desc = NULL; + + if (engine_name != NULL && engine_name[0] != '\0') { + /* request engine by name */ + desc = _find_engine_desc_by_name (ibus, engine_name); +- g_return_if_fail (desc != NULL); ++ g_return_val_if_fail (desc != NULL, NULL); + } + else { + /* Use global engine if possible. */ +@@ -1018,11 +1030,11 @@ _context_request_engine_cb (BusInputContext *context, + * not find any default engines. another possiblity is that the + * user hasn't installed an engine yet? just give up. */ + g_warning ("No engine is available. Run ibus-setup first."); +- return; ++ return NULL; + } + } + +- bus_ibus_impl_set_context_engine_from_desc (ibus, context, desc); ++ return desc; + } + + /** +@@ -1041,7 +1053,11 @@ bus_ibus_impl_context_request_next_engine_in_menu (BusIBusImpl *ibus, + + engine = bus_input_context_get_engine (context); + if (engine == NULL) { +- _context_request_engine_cb (context, NULL, ibus); ++ desc = bus_ibus_impl_get_engine_desc (ibus, NULL); ++ if (desc != NULL) ++ bus_ibus_impl_set_context_engine_from_desc (ibus, ++ context, ++ desc); + return; + } + +@@ -1112,7 +1128,14 @@ bus_ibus_impl_context_request_previous_engine (BusIBusImpl *ibus, + bus_ibus_impl_context_request_next_engine_in_menu (ibus, context); + return; + } +- _context_request_engine_cb (context, engine_name, ibus); ++ ++ IBusEngineDesc *desc = NULL; ++ desc = bus_ibus_impl_get_engine_desc (ibus, engine_name); ++ if (desc != NULL) { ++ bus_ibus_impl_set_context_engine_from_desc (ibus, ++ context, ++ desc); ++ } + } + + static void +diff --git a/bus/inputcontext.c b/bus/inputcontext.c +index c226a20..6d65830 100644 +--- a/bus/inputcontext.c ++++ b/bus/inputcontext.c +@@ -20,11 +20,13 @@ + * Boston, MA 02111-1307, USA. + */ + #include "inputcontext.h" +-#include "types.h" +-#include "marshalers.h" +-#include "ibusimpl.h" ++ + #include "engineproxy.h" + #include "factoryproxy.h" ++#include "ibusimpl.h" ++#include "marshalers.h" ++#include "option.h" ++#include "types.h" + + struct _SetEngineByDescData { + /* context related to the data */ +@@ -565,8 +567,8 @@ bus_input_context_class_init (BusInputContextClass *class) + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, +- bus_marshal_VOID__STRING, +- G_TYPE_NONE, ++ bus_marshal_OBJECT__STRING, ++ IBUS_TYPE_ENGINE_DESC, + 1, + G_TYPE_STRING); + +@@ -917,6 +919,26 @@ _ic_is_enabled (BusInputContext *context, + g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", context->enabled)); + } + ++static void ++_ic_set_engine_done (BusInputContext *context, ++ GAsyncResult *res, ++ GDBusMethodInvocation *invocation) ++{ ++ gboolean retval = FALSE; ++ GError *error = NULL; ++ ++ retval = bus_input_context_set_engine_by_desc_finish (context, ++ res, &error); ++ ++ if (!retval) { ++ g_dbus_method_invocation_return_gerror (invocation, error); ++ g_error_free (error); ++ } ++ else { ++ g_dbus_method_invocation_return_value (invocation, NULL); ++ } ++} ++ + /** + * _ic_set_engine: + * +@@ -930,16 +952,34 @@ _ic_set_engine (BusInputContext *context, + gchar *engine_name = NULL; + g_variant_get (parameters, "(&s)", &engine_name); + +- g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, engine_name); +- +- if (context->engine == NULL) { +- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, +- "Can not find engine '%s'.", engine_name); ++ if (!bus_input_context_has_focus (context)) { ++ g_dbus_method_invocation_return_error (invocation, ++ G_DBUS_ERROR, G_DBUS_ERROR_FAILED, ++ "Context which does not has focus can not change engine to %s.", ++ engine_name); ++ return; + } +- else { +- bus_input_context_enable (context); +- g_dbus_method_invocation_return_value (invocation, NULL); ++ ++ IBusEngineDesc *desc = NULL; ++ g_signal_emit (context, ++ context_signals[REQUEST_ENGINE], 0, ++ engine_name, ++ &desc); ++ if (desc == NULL) { ++ g_dbus_method_invocation_return_error (invocation, ++ G_DBUS_ERROR, G_DBUS_ERROR_FAILED, ++ "Can not find engine %s.", engine_name); ++ return; + } ++ ++ bus_input_context_set_engine_by_desc (context, ++ desc, ++ g_gdbus_timeout, ++ NULL, ++ (GAsyncReadyCallback)_ic_set_engine_done, ++ invocation); ++ ++ g_object_unref (desc); + } + + /** +@@ -1045,7 +1085,21 @@ bus_input_context_focus_in (BusInputContext *context) + + if (context->engine == NULL && context->enabled) { + /* request an engine, e.g. a global engine if the feature is enabled. */ +- g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL); ++ IBusEngineDesc *desc = NULL; ++ g_signal_emit (context, ++ context_signals[REQUEST_ENGINE], 0, ++ NULL, ++ &desc); ++ ++ if (desc != NULL) { ++ bus_input_context_set_engine_by_desc (context, ++ desc, ++ g_gdbus_timeout, /* timeout in msec. */ ++ NULL, /* we do not cancel the call. */ ++ NULL, /* use the default callback function. */ ++ NULL); ++ g_object_unref (desc); ++ } + } + + if (context->engine && context->enabled) { +@@ -1927,7 +1981,20 @@ bus_input_context_enable (BusInputContext *context) + } + + if (context->engine == NULL) { +- g_signal_emit (context, context_signals[REQUEST_ENGINE], 0, NULL); ++ IBusEngineDesc *desc = NULL; ++ g_signal_emit (context, ++ context_signals[REQUEST_ENGINE], 0, ++ NULL, ++ &desc); ++ if (desc != NULL) { ++ bus_input_context_set_engine_by_desc (context, ++ desc, ++ g_gdbus_timeout, /* timeout in msec. */ ++ NULL, /* we do not cancel the call. */ ++ NULL, /* use the default callback function. */ ++ NULL); ++ g_object_unref (desc); ++ } + } + + if (context->engine == NULL) +diff --git a/bus/marshalers.list b/bus/marshalers.list +index 15bdf02..159bc24 100644 +--- a/bus/marshalers.list ++++ b/bus/marshalers.list +@@ -1,13 +1,13 @@ +-VOID:VOID +-VOID:STRING +-VOID:OBJECT ++BOOL:UINT,UINT,UINT ++OBJECT:STRING + VOID:INT,UINT +-VOID:UINT,UINT,UINT + VOID:INT,INT,INT,INT +-VOID:STRING,INT + VOID:OBJECT +-VOID:STRING,STRING,STRING + VOID:OBJECT,BOOLEAN + VOID:OBJECT,UINT,BOOLEAN + VOID:OBJECT,UINT,BOOLEAN,UINT +-BOOL:UINT,UINT,UINT ++VOID:STRING ++VOID:STRING,INT ++VOID:STRING,STRING,STRING ++VOID:UINT,UINT,UINT ++VOID:VOID +-- +1.7.4.1 + diff --git a/ibus.spec b/ibus.spec index c2829c2..d96152f 100644 --- a/ibus.spec +++ b/ibus.spec @@ -13,7 +13,7 @@ Name: ibus Version: 1.3.99.20110228 -Release: 2%{?dist} +Release: 3%{?dist} Summary: Intelligent Input Bus for Linux OS License: LGPLv2+ Group: System Environment/Libraries @@ -21,7 +21,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/gnome-shell-ibus-plugins-20110304.tar.bz2 +Source2: http://fujiwara.fedorapeople.org/ibus/gnome-shell/gnome-shell-ibus-plugins-20110317.tar.bz2 %endif Patch0: ibus-HEAD.patch Patch1: ibus-435880-surrounding-text.patch @@ -327,8 +327,10 @@ fi %{_datadir}/gtk-doc/html/* %changelog -* Fri Mar 11 2011 Takao Fujiwara - 1.3.99.20110228-2 -- Revised ibus-530711-preload-sys.patch +* Thu Mar 17 2011 Takao Fujiwara - 1.3.99.20110228-3 +- Updated ibus-HEAD.patch + Fixed Bug 683484 - Timed out SetEngine when select an engine from panel. +- Updated ibus-657165-panel-libs.patch * Thu Mar 10 2011 Takao Fujiwara - 1.3.99.20110228-1 - Updated to 1.3.99.20110228 diff --git a/sources b/sources index 9151a4a..617504f 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ 223ce787c5357f833ba34cdaf502ef76 ibus-1.3.99.20110228.tar.gz -3d97318591cfb2aa82f97db3f3a5a7f2 gnome-shell-ibus-plugins-20110304.tar.bz2 +2d6991ca7d3147aa486b6297872bed5f gnome-shell-ibus-plugins-20110317.tar.bz2