X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtkimmodule.c;h=e6372f2edb6763b233b81164d2618e952e98033a;hb=9f41970832b60f3cf6644dfbd154df7ec24f26ce;hp=70a689d39c68f4b1c1345d79b7684385b58a0474;hpb=5f1b5d24067468fc86b28dccc504c71abdaf68b8;p=~andy%2Fgtk
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c
index 70a689d39..e6372f2ed 100644
--- a/gtk/gtkimmodule.c
+++ b/gtk/gtkimmodule.c
@@ -12,8 +12,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see .Free
*/
/*
@@ -32,21 +31,18 @@
#include
#include
-#include "gtkimmodule.h"
+#include "gtkimmoduleprivate.h"
#include "gtkimcontextsimple.h"
#include "gtksettings.h"
-#include "gtkmain.h"
-#include "gtkrc.h"
+#include "gtkprivate.h"
#include "gtkintl.h"
-/* Do *not* include "gtkprivate.h" in this file. If you do, the
- * correct_libdir_prefix() and correct_localedir_prefix() functions
- * below will have to move somewhere else.
- */
+#undef GDK_DEPRECATED
+#undef GDK_DEPRECATED_FOR
+#define GDK_DEPRECATED
+#define GDK_DEPRECATED_FOR(f)
-#ifdef __GTK_PRIVATE_H__
-#error gtkprivate.h should not be included in this file
-#endif
+#include "deprecated/gtkrc.h"
#define SIMPLE_ID "gtk-im-context-simple"
@@ -240,10 +236,7 @@ add_module (GtkIMModule *module, GSList *infos)
static void
correct_libdir_prefix (gchar **path)
{
- /* GTK_LIBDIR here is supposed to still have the definition from
- * Makefile.am, i.e. the build-time value. Do *not* include gtkprivate.h
- * in this file.
- */
+ /* GTK_LIBDIR is the build-time libdir */
if (strncmp (*path, GTK_LIBDIR, strlen (GTK_LIBDIR)) == 0)
{
/* This is an entry put there by make install on the
@@ -254,7 +247,6 @@ correct_libdir_prefix (gchar **path)
* builder's machine. Replace the path with the real
* one on this machine.
*/
- extern const gchar *_gtk_get_libdir ();
gchar *tem = *path;
*path = g_strconcat (_gtk_get_libdir (), tem + strlen (GTK_LIBDIR), NULL);
g_free (tem);
@@ -264,12 +256,9 @@ correct_libdir_prefix (gchar **path)
static void
correct_localedir_prefix (gchar **path)
{
- /* As above, but for GTK_LOCALEDIR. Use separate function in case
- * GTK_LOCALEDIR isn't a subfolder of GTK_LIBDIR.
- */
+ /* See above */
if (strncmp (*path, GTK_LOCALEDIR, strlen (GTK_LOCALEDIR)) == 0)
{
- extern const gchar *_gtk_get_localedir ();
gchar *tem = *path;
*path = g_strconcat (_gtk_get_localedir (), tem + strlen (GTK_LOCALEDIR), NULL);
g_free (tem);
@@ -649,6 +638,28 @@ 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
+ {
+ gboolean found;
+ gchar *context_id;
+ found = g_hash_table_lookup_extended (contexts_hash, *immodules_list,
+ (gpointer *) &context_id, NULL);
+ if (found)
+ return context_id;
+ }
+ immodules_list++;
+ }
+
+ return NULL;
+}
+
/**
* _gtk_im_module_get_default_context_id:
* @client_window: a window
@@ -665,7 +676,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;
@@ -673,30 +684,29 @@ _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.
*/
- if (GDK_IS_DRAWABLE (client_window))
+ if (GDK_IS_WINDOW (client_window))
{
- screen = gdk_drawable_get_screen (GDK_DRAWABLE (client_window));
+ screen = gdk_window_get_screen (client_window);
settings = gtk_settings_get_for_screen (screen);
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)