[gtk2] Add the backport patch from gtk-2-24 branch to allow fallback for immodules.
Akira TAGOH
tagoh at fedoraproject.org
Fri Jun 8 02:49:00 UTC 2012
commit 13d75ee043e44156495ff4c2ffa87fda93efc40f
Author: Akira TAGOH <tagoh at redhat.com>
Date: Fri Jun 8 11:48:56 2012 +0900
Add the backport patch from gtk-2-24 branch to allow fallback for immodules.
This would solves the unexpected immodules selection. (#828764)
allow-fallback-for-immodules.patch | 130 ++++++++++++++++++++++++++++++++++++
1 files changed, 130 insertions(+), 0 deletions(-)
---
diff --git a/allow-fallback-for-immodules.patch b/allow-fallback-for-immodules.patch
new file mode 100644
index 0000000..147975e
--- /dev/null
+++ b/allow-fallback-for-immodules.patch
@@ -0,0 +1,130 @@
+From 0b59fbfb9d677b77b392c0c6d327ddecd7978d89 Mon Sep 17 00:00:00 2001
+From: Matthias Clasen <mclasen at redhat.com>
+Date: Tue, 5 Jun 2012 17:03:42 -0400
+Subject: [PATCH] Allow fallback for input method modules
+
+Accept a :-separated list of module names in GTK_IM_MODULE and
+the corresponding setting, to deal a bit better with broken
+situations.
+
+https://bugzilla.gnome.org/show_bug.cgi?id=603559
+
+Patch by Akira Tagoh, backported from GTK+ 3. The backport
+is required because GTK+ 2 and 3 are listening to the same env
+vars and settings for immodules.
+---
+ docs/reference/gtk/running.sgml | 2 ++
+ gtk/gtkimmodule.c | 49 +++++++++++++++++++++++++++------------
+ gtk/gtksettings.c | 2 ++
+ 3 files changed, 38 insertions(+), 15 deletions(-)
+
+diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
+index 8371832..11fa0d1 100644
+--- a/docs/reference/gtk/running.sgml
++++ b/docs/reference/gtk/running.sgml
+@@ -264,6 +264,8 @@ additional environment variables.
+ that enables <literal>XSETTINGS</literal> and has a value in
+ <literal>Gtk/IMModule</literal>, that will be used for the default
+ IM module.
++ This also can be a colon-separated list of input-methods, which
++ GTK+ will try in turn until it finds one available on the system.
+ </para>
+ </formalpara>
+
+diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
+index f1da875..f7baa03 100644
+--- a/gtk/gtkimmodule.c
++++ b/gtk/gtkimmodule.c
+@@ -650,6 +650,26 @@ match_locale (const gchar *locale,
+ return 0;
+ }
+
++static const gchar *
++lookup_immodule (gchar **immodules_list)
++{
++ while (immodules_list && *immodules_list)
++ {
++ if (g_strcmp0 (*immodules_list, SIMPLE_ID) == 0)
++ return SIMPLE_ID;
++ else
++ {
++ GtkIMModule *module;
++ module = g_hash_table_lookup (contexts_hash, *immodules_list);
++ if (module)
++ return module->contexts[0]->context_id;
++ }
++ immodules_list++;
++ }
++
++ return NULL;
++}
++
+ /**
+ * _gtk_im_module_get_default_context_id:
+ * @client_window: a window
+@@ -666,7 +686,7 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
+ const gchar *context_id = NULL;
+ gint best_goodness = 0;
+ gint i;
+- gchar *tmp_locale, *tmp;
++ gchar *tmp_locale, *tmp, **immodules;
+ const gchar *envvar;
+ GdkScreen *screen;
+ GtkSettings *settings;
+@@ -674,11 +694,16 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
+ if (!contexts_hash)
+ gtk_im_module_initialize ();
+
+- envvar = g_getenv ("GTK_IM_MODULE");
+- if (envvar &&
+- (strcmp (envvar, SIMPLE_ID) == 0 ||
+- g_hash_table_lookup (contexts_hash, envvar)))
+- return envvar;
++ envvar = g_getenv("GTK_IM_MODULE");
++ if (envvar)
++ {
++ immodules = g_strsplit(envvar, ":", 0);
++ context_id = lookup_immodule(immodules);
++ g_strfreev(immodules);
++
++ if (context_id)
++ return context_id;
++ }
+
+ /* Check if the certain immodule is set in XSETTINGS.
+ */
+@@ -689,15 +714,9 @@ _gtk_im_module_get_default_context_id (GdkWindow *client_window)
+ g_object_get (G_OBJECT (settings), "gtk-im-module", &tmp, NULL);
+ if (tmp)
+ {
+- if (strcmp (tmp, SIMPLE_ID) == 0)
+- context_id = SIMPLE_ID;
+- else
+- {
+- GtkIMModule *module;
+- module = g_hash_table_lookup (contexts_hash, tmp);
+- if (module)
+- context_id = module->contexts[0]->context_id;
+- }
++ immodules = g_strsplit(tmp, ":", 0);
++ context_id = lookup_immodule(immodules);
++ g_strfreev(immodules);
+ g_free (tmp);
+
+ if (context_id)
+diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c
+index f83a54b..c5f77fe 100644
+--- a/gtk/gtksettings.c
++++ b/gtk/gtksettings.c
+@@ -850,6 +850,8 @@ gtk_settings_class_init (GtkSettingsClass *class)
+ * Which IM (input method) module should be used by default. This is the
+ * input method that will be used if the user has not explicitly chosen
+ * another input method from the IM context menu.
++ * This also can be a colon-separated list of input methods, which GTK+
++ * will try in turn until it finds one available on the system.
+ *
+ * See #GtkIMContext and see the #GtkSettings:gtk-show-input-method-menu property.
+ */
+--
+1.7.10.2
+
More information about the scm-commits
mailing list