summaryrefslogtreecommitdiff
path: root/gtk/gtkimmodule.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2011-11-05 01:47:46 -0400
committerMatthias Clasen <mclasen@redhat.com>2011-11-05 01:48:59 -0400
commit4d7e47ddd0590a6cad1bdf5d785203e8aa9f259e (patch)
tree6857ce9bcc8975da4bcc63055e88f81c4750d819 /gtk/gtkimmodule.c
parenta72a3160a8d79af5da1f7b239478c0d727cfeb00 (diff)
downloadgtk+-4d7e47ddd0590a6cad1bdf5d785203e8aa9f259e.tar.gz
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
Diffstat (limited to 'gtk/gtkimmodule.c')
-rw-r--r--gtk/gtkimmodule.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index ef547fc5f9..093a557d9b 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -632,6 +632,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
@@ -648,7 +668,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;
@@ -656,11 +676,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.
*/
@@ -671,15 +696,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)