diff options
author | Benjamin Otte <otte@redhat.com> | 2016-10-06 19:59:53 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-10-16 18:17:21 +0200 |
commit | 361d322bfb3a3896d447c6b1fe0bfefa5dc599fd (patch) | |
tree | da712d85c9e124182ef8ba78d82409e0804c9ed6 /gtk/gtkimmodule.c | |
parent | 1aa336b500c80a32fde0a3d6501ff8d61a50002b (diff) | |
download | gtk+-361d322bfb3a3896d447c6b1fe0bfefa5dc599fd.tar.gz |
immodules: Move path code out of gtkrc
Diffstat (limited to 'gtk/gtkimmodule.c')
-rw-r--r-- | gtk/gtkimmodule.c | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c index 24a5f62302..289cec06a0 100644 --- a/gtk/gtkimmodule.c +++ b/gtk/gtkimmodule.c @@ -33,6 +33,7 @@ #include <gmodule.h> #include "gtkimmoduleprivate.h" #include "gtkimcontextsimple.h" +#include "gtkmodulesprivate.h" #include "gtksettings.h" #include "gtkprivate.h" #include "gtkutilsprivate.h" @@ -63,8 +64,6 @@ #define GDK_DEPRECATED #define GDK_DEPRECATED_FOR(f) -#include "deprecated/gtkrc.h" - /* We need to call getc() a lot in a loop. This is suboptimal, * as getc() does thread locking on the FILE it is given. * To optimize that, lock the file first, then call getc(), @@ -332,12 +331,71 @@ add_builtin_module (const gchar *module_name, return module; } +/* + * gtk_get_im_module_path: + * + * Obtains the path in which to look for IM modules. See the documentation + * of the `GTK_PATH` + * environment variable for more details about looking up modules. This + * function is useful solely for utilities supplied with GTK+ and should + * not be used by applications under normal circumstances. + * + * Returns: (type filename): a newly-allocated string containing the + * path in which to look for IM modules. + */ +gchar * +gtk_get_im_module_path (void) +{ + gchar **paths = _gtk_get_module_path ("immodules"); + gchar *result = g_strjoinv (G_SEARCHPATH_SEPARATOR_S, paths); + g_strfreev (paths); + + return result; +} + +/* + * gtk_get_im_module_file: + * + * Obtains the path to the IM modules file. See the documentation + * of the `GTK_IM_MODULE_FILE` + * environment variable for more details. + * + * Returns: (type filename): a newly-allocated string containing the + * name of the file listing the IM modules available for loading + */ +gchar * +gtk_get_im_module_file (void) +{ + const gchar *var = g_getenv ("GTK_IM_MODULE_FILE"); + gchar *result = NULL; + + if (var) + result = g_strdup (var); + + if (!result) + { + const gchar *var; + gchar *path; + + var = g_getenv ("GTK_EXE_PREFIX"); + + if (var) + path = g_build_filename (var, "lib", "gtk-3.0", GTK_BINARY_VERSION, "immodules.cache", NULL); + else + path = g_build_filename (_gtk_get_libdir (), "gtk-3.0", GTK_BINARY_VERSION, "immodules.cache", NULL); + + return path; + } + + return result; +} + static void gtk_im_module_initialize (void) { GString *line_buf = g_string_new (NULL); GString *tmp_buf = g_string_new (NULL); - gchar *filename = gtk_rc_get_im_module_file(); + gchar *filename = gtk_get_im_module_file(); FILE *file; gboolean have_error = FALSE; |