summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-02-19 05:33:34 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-02-19 05:33:34 +0000
commita255d9cd01ecfee761cf03e746a864ab6e735e51 (patch)
tree60794bf8b98ec89b5f4bef54a968e071c99efeb2
parentbd73a312f06ad6d1a448cab873f309264ee24b46 (diff)
downloadgtk+-a255d9cd01ecfee761cf03e746a864ab6e735e51.tar.gz
Add routines _gtk_find_module(), _gtk_get_module_path() to look up a
Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com> * gtk/gtkmain.[ch]: Add routines _gtk_find_module(), _gtk_get_module_path() to look up a module of an arbitrary type in a standard fashion. (#68474) * gtk/gtkrc.c: Make module_path keyword warn and do nothing. Remove the im_module_path keyword. * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix to return the standard path instead of one determined from im_module_path and GTK_IM_MODULE_PATH. * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
-rw-r--r--ChangeLog15
-rw-r--r--ChangeLog.pre-2-015
-rw-r--r--ChangeLog.pre-2-1015
-rw-r--r--ChangeLog.pre-2-215
-rw-r--r--ChangeLog.pre-2-415
-rw-r--r--ChangeLog.pre-2-615
-rw-r--r--ChangeLog.pre-2-815
-rw-r--r--docs/reference/ChangeLog5
-rw-r--r--docs/reference/gtk/running.sgml61
-rw-r--r--docs/reference/gtk/tmpl/gtkrc.sgml4
-rw-r--r--gtk+-2.0.pc.in1
-rw-r--r--gtk/Makefile.am1
-rw-r--r--gtk/gtkmain.c173
-rw-r--r--gtk/gtkmain.h3
-rw-r--r--gtk/gtkrc.c150
15 files changed, 303 insertions, 200 deletions
diff --git a/ChangeLog b/ChangeLog
index e0118971c9..fdf2605464 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index e0118971c9..fdf2605464 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,18 @@
+Mon Feb 18 23:16:16 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/gtkmain.[ch]: Add routines _gtk_find_module(),
+ _gtk_get_module_path() to look up a module of an arbitrary type in
+ a standard fashion. (#68474)
+
+ * gtk/gtkrc.c: Make module_path keyword warn and do
+ nothing. Remove the im_module_path keyword.
+
+ * gtk/gtkrc.c (gtk_rc_get_im_module_path): Fix
+ to return the standard path instead of one determined
+ from im_module_path and GTK_IM_MODULE_PATH.
+
+ * gtk+-2.0.pc.in: Add gtk_host to go along with gtk_binary_version.
+
2002-02-19 Matthias Clasen <maclas@gmx.de>
* docs/tutorial/gtk-tut.sgml, docs/examples/*: Trivial formatting
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog
index 13bc0125b3..0ae970070c 100644
--- a/docs/reference/ChangeLog
+++ b/docs/reference/ChangeLog
@@ -1,3 +1,8 @@
+Mon Feb 18 23:00:52 2002 Owen Taylor <otaylor@redhat.com>
+
+ * gtk/running.sgml: Remove docs for GTK_IM_MODULE_PATH,
+ replace docs for GTK_MODULE_PATH with docs for GTK_PATH.
+
Sun Feb 17 21:33:33 2002 Owen Taylor <otaylor@redhat.com>
* gtk/gtk-sections.txt: Updated for filesel changes.
diff --git a/docs/reference/gtk/running.sgml b/docs/reference/gtk/running.sgml
index 5365173543..8b78fedd53 100644
--- a/docs/reference/gtk/running.sgml
+++ b/docs/reference/gtk/running.sgml
@@ -205,18 +205,42 @@ or <envar>DISPLAY</envar>; mostly to determine paths to look for certain files.
</formalpara>
<formalpara>
- <title><envar>GTK_MODULE_PATH</envar></title>
+ <title><envar>GTK_PATH</envar></title>
<para>
- A list of directories to search for modules before the default module
- directory, which is <filename>&lt;libdir&gt;/gtk-2.0/modules</filename>.
- (If <envar>GTK_EXE_PREFIX</envar> is defined, &lt;libdir&gt; is
+ Specifies a list of directories to search when GTK+ is looking for
+ dynamically loaded objects such as the modules specified by
+ <envar>GTK_MODULES</envar>, theme engines, and input method
+ modules. If the path to the dynamically loaded object is given
+ as an absolute path name, then GTK+ loads it directly. Otherwise,
+ GTK+ goes in turn through the directories in GTK_PATH, followed
+ by the directory <filename>.gtk-2.0</filename> in the user's home
+ directory, followed by the system default directory,
+ which is <filename><replaceable>libdir</replaceable>/gtk-2.0/modules</filename>.
+ (If <envar>GTK_EXE_PREFIX</envar> is defined, <replaceable>libdir</replaceable> is
<filename>$GTK_EXE_PREFIX/lib</filename>. Otherwise it is the libdir
- specified when GTK+ was configured, usually
- <filename>/usr/local/lib</filename>.)
- For each directory in the list, GTK+ actually looks first in
- a subdirectory named after the version number of GTK+, then in the
- directory itself and finally in the system-specific library path.
+ specified when GTK+ was configured, usually
+ <filename>/usr/lib</filename>, or
+ <filename>/usr/local/lib</filename>.)
+ For each directory in this list, GTK+ actually looks in a
+ subdirectory
+ <filename><replaceable>directory</replaceable>/<replaceable>version</replaceable>/<replaceable>host</replaceable>/<replaceable>type</replaceable></filename>
+ Where <replaceable>version</replaceable> is derived from the
+ version of GTK+ (use <literal>pkg-config
+ --variable=gtk_binary_version gtk+-2.0</literal> to determine this from a
+ script), <replaceable>host</replaceable> is the architecture on
+ which GTK+ was built. (use <literal>pkg-config
+ --variable=gtk_host gtk+-2.0</literal> to determine this from a
+ script), and <replaceable>type</replaceable> is a directory
+ specific to the type of modules; currently it can be
+ <literal>modules</literal>, <literal>engines</literal> or
+ <literal>immodules</literal> corresponding to the three types of
+ modules above. Either <replaceable>version</replaceable>,
+ <replaceable>host</replaceable>, or both may be omitted. GTK+ looks
+ first in the most specific directory, then in directories with
+ fewer components.
+ The components of GTK_PATH are separated by the ':' character on
+ Linux and Unix, and the ';' character on Windows.
</para>
</formalpara>
@@ -229,19 +253,6 @@ or <envar>DISPLAY</envar>; mostly to determine paths to look for certain files.
</para>
</formalpara>
-<formalpara id="im-module-path">
- <title><envar>GTK_IM_MODULE_PATH</envar></title>
-
- <para>
- Specifies the path where GTK+ looks for IM modules. This environment
- variable overwrites the <literal>im_module_path</literal> specified in the
- RC files, which in turn overwrites the default
- value <filename>$lt;libdir$gt;/gtk-2.0/immodules/&lt;version&gt;</filename>
- (where &lt;version&gt; is the GTK+ version, and &lt;libdir&gt; is as
- explained above).
- </para>
-</formalpara>
-
<formalpara id="im-module-file">
<title><envar>GTK_IM_MODULE_FILE</envar></title>
@@ -249,8 +260,8 @@ or <envar>DISPLAY</envar>; mostly to determine paths to look for certain files.
Specifies the file listing the IM modules to load. This environment
variable overwrites the <literal>im_module_file</literal> specified in
the RC files, which in turn overwrites the default value
- <filename>&lt;sysconfdir&gt;/gtk-2.0/gtk.immodules</filename>
- (&lt;sysconfdir&gt; is the sysconfdir specified when GTK+ was configured,
+ <filename><replaceable>sysconfdir</replaceable>/gtk-2.0/gtk.immodules</filename>
+ (<replaceable>sysconfdir</replaceable> is the sysconfdir specified when GTK+ was configured,
usually <filename>/usr/local/etc</filename>.)
</para>
</formalpara>
@@ -294,7 +305,7 @@ nevertheless.
<para>
Specifies the directory to look for GdkPixbuf loader modules.
By default, GdkPixbuf looks for its loaders in
- <filename>&lt;libdir&gt;/gtk-2.0/&lt;version&gt;/loaders</filename>.
+ <filename><replaceable>libdir</replaceable>/gtk-2.0/<replaceable>version</replaceable>/loaders</filename>.
</para>
</formalpara>
diff --git a/docs/reference/gtk/tmpl/gtkrc.sgml b/docs/reference/gtk/tmpl/gtkrc.sgml
index 58596be833..29bcfbdbf9 100644
--- a/docs/reference/gtk/tmpl/gtkrc.sgml
+++ b/docs/reference/gtk/tmpl/gtkrc.sgml
@@ -776,12 +776,10 @@ that was expected but not found.
<!-- ##### FUNCTION gtk_rc_find_module_in_path ##### -->
<para>
-Looks up a file in the current module path.
</para>
@module_file: The name of the module to search for.
-@Returns: The filename, if found (must be freed with g_free()),
-otherwise %NULL.
+@Returns:
<!-- ##### FUNCTION gtk_rc_find_pixmap_in_path ##### -->
diff --git a/gtk+-2.0.pc.in b/gtk+-2.0.pc.in
index 97bd6e649b..8cfa00af80 100644
--- a/gtk+-2.0.pc.in
+++ b/gtk+-2.0.pc.in
@@ -5,6 +5,7 @@ includedir=@includedir@
target=@gdktarget@
gtk_binary_version=@GTK_BINARY_VERSION@
+gtk_host=@host@
Name: GTK+
Description: GIMP Tool Kit (${target} target)
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index f7c3145ced..57701300fd 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -10,6 +10,7 @@ INCLUDES = @STRIP_BEGIN@ \
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
-DGTK_VERSION=\"@GTK_VERSION@\" \
-DGTK_BINARY_VERSION=\"@GTK_BINARY_VERSION@\" \
+ -DGTK_HOST=\"@host@\" \
-DGTK_COMPILATION \
-I$(top_builddir)/gtk \
-I$(top_srcdir) -I../gdk \
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a6d5c1975a..2c3f202173 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -282,73 +282,158 @@ _gtk_get_data_prefix (void)
static gchar **
get_module_path (void)
{
- const gchar *module_path_env = g_getenv ("GTK_MODULE_PATH");
- const gchar *exe_prefix = g_getenv ("GTK_EXE_PREFIX");
- gchar **result;
+ const gchar *module_path_env;
+ const gchar *exe_prefix;
+ const gchar *home_dir;
+ gchar *home_gtk_dir = NULL;
gchar *module_path;
gchar *default_dir;
+ static gchar **result = NULL;
+
+ if (result)
+ return result;
+
+ home_dir = g_get_home_dir();
+ if (home_dir)
+ home_gtk_dir = g_build_filename (home_dir, ".gtk-2.0", NULL);
+
+ module_path_env = g_getenv ("GTK_PATH");
+ exe_prefix = g_getenv ("GTK_EXE_PREFIX");
if (exe_prefix)
- default_dir = g_build_filename (exe_prefix, "lib", "gtk-2.0", "modules", NULL);
+ default_dir = g_build_filename (exe_prefix, "lib", "gtk-2.0", NULL);
else
- default_dir = g_build_filename (GTK_LIBDIR, "gtk-2.0", "modules", NULL);
+ default_dir = g_build_filename (GTK_LIBDIR, "gtk-2.0", NULL);
+
+ if (module_path_env && home_gtk_dir)
+ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+ module_path_env, home_gtk_dir, default_dir, NULL);
+ else if (module_path_env)
+ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+ module_path_env, default_dir, NULL);
+ else if (home_gtk_dir)
+ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+ home_gtk_dir, default_dir, NULL);
+ else
+ module_path = g_build_path (G_SEARCHPATH_SEPARATOR_S,
+ default_dir, NULL);
- module_path = g_strconcat (module_path_env ? module_path_env : "",
- module_path_env ? G_SEARCHPATH_SEPARATOR_S : "",
- default_dir, NULL);
+ g_free (home_gtk_dir);
+ g_free (default_dir);
result = pango_split_file_list (module_path);
-
- g_free (default_dir);
g_free (module_path);
return result;
}
-static GModule *
-find_module (gchar **module_path,
- const gchar *name)
+/**
+ * _gtk_get_module_path:
+ * @type: the type of the module, for instance 'modules', 'engines', immodules'
+ *
+ * Determines the search path for a particular type of module.
+ *
+ * Return value: the search path for the module type. Free with g_strfreev().
+ **/
+gchar **
+_gtk_get_module_path (const gchar *type)
{
- GModule *module;
- gchar *module_name;
- gint i;
+ gchar **paths = get_module_path();
+ gchar **path;
+ gchar **result;
+ gint count = 0;
- if (g_path_is_absolute (name))
- return g_module_open (name, G_MODULE_BIND_LAZY);
+ for (path = paths; *path; path++)
+ count++;
- for (i = 0; module_path[i]; i++)
- {
- gchar *version_directory;
+ result = g_new (gchar *, count * 4 + 1);
- version_directory = g_build_filename (module_path[i], GTK_BINARY_VERSION, NULL);
- module_name = g_module_build_path (version_directory, name);
- g_free (version_directory);
-
- if (g_file_test (module_name, G_FILE_TEST_EXISTS))
- {
- module = g_module_open (module_name, G_MODULE_BIND_LAZY);
- g_free (module_name);
- return module;
- }
+ count = 0;
+ for (path = get_module_path (); *path; path++)
+ {
+ gint use_version, use_host;
- g_free (module_name);
+ for (use_version = TRUE; use_version >= FALSE; use_version--)
+ for (use_host = TRUE; use_host >= FALSE; use_host--)
+ {
+ gchar *tmp_dir;
+
+ if (use_version && use_host)
+ tmp_dir = g_build_filename (*path, GTK_BINARY_VERSION, GTK_HOST, type, NULL);
+ else if (use_version)
+ tmp_dir = g_build_filename (*path, GTK_BINARY_VERSION, type, NULL);
+ else if (use_host)
+ tmp_dir = g_build_filename (*path, GTK_HOST, type, NULL);
+ else
+ tmp_dir = g_build_filename (*path, type, NULL);
+
+ result[count++] = tmp_dir;
+ }
+ }
- module_name = g_module_build_path (module_path[i], name);
-
- if (g_file_test (module_name, G_FILE_TEST_EXISTS))
+ result[count++] = NULL;
+
+ return result;
+}
+
+/**
+ * _gtk_find_module:
+ * @name: the name of the module
+ * @type: the type of the module, for instance 'modules', 'engines', immodules'
+ *
+ * Looks for a dynamically module named @name of type @type in the standard GTK+
+ * module search path.
+ *
+ * Return value: the pathname to the found module, or %NULL if it wasn't found.
+ * Free with g_free().
+ **/
+gchar *
+_gtk_find_module (const gchar *name,
+ const gchar *type)
+{
+ gchar **paths;
+ gchar **path;
+ gchar *module_name = NULL;
+
+ if (g_path_is_absolute (name))
+ return g_strdup (name);
+
+ paths = _gtk_get_module_path (type);
+ for (path = paths; *path; path++)
+ {
+ gchar *tmp_name = g_module_build_path (*path, name);
+
+ if (g_file_test (tmp_name, G_FILE_TEST_EXISTS))
{
- module = g_module_open (module_name, G_MODULE_BIND_LAZY);
- g_free (module_name);
- return module;
+ module_name = tmp_name;
+ goto found;
}
-
- g_free (module_name);
+ else
+ g_free(tmp_name);
}
- /* As last resort, try loading without an absolute path (using system
- * library path)
- */
- module_name = g_module_build_path (NULL, name);
+ g_strfreev (paths);
+
+ found:
+ return module_name;
+}
+
+static GModule *
+find_module (gchar **module_path,
+ const gchar *name)
+{
+ GModule *module;
+ gchar *module_name;
+
+ module_name = _gtk_find_module (name, "modules");
+ if (!module_name)
+ {
+ /* As last resort, try loading without an absolute path (using system
+ * library path)
+ */
+ module_name = g_module_build_path (NULL, name);
+ }
+
module = g_module_open (module_name, G_MODULE_BIND_LAZY);
g_free(module_name);
diff --git a/gtk/gtkmain.h b/gtk/gtkmain.h
index 97b24b98ae..1f010d4943 100644
--- a/gtk/gtkmain.h
+++ b/gtk/gtkmain.h
@@ -204,6 +204,9 @@ gboolean _gtk_boolean_handled_accumulator (GSignalInvocationHint *ihint,
const GValue *handler_return,
gpointer dummy);
+gchar * _gtk_find_module (const gchar *name,
+ const gchar *type);
+gchar **_gtk_get_module_path (const gchar *type);
#ifdef __cplusplus
}
diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c
index 8d3d7ec187..1aa56683a0 100644
--- a/gtk/gtkrc.c
+++ b/gtk/gtkrc.c
@@ -52,6 +52,7 @@
#include "gtkthemes.h"
#include "gtkintl.h"
#include "gtkiconfactory.h"
+#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtksettings.h"
#include "gtkwindow.h"
@@ -166,8 +167,6 @@ static void gtk_rc_parse_pixmap_path_string (GtkRcContext *context,
GScanner *scanner,
const gchar *pix_path);
static guint gtk_rc_parse_module_path (GScanner *scanner);
-static void gtk_rc_parse_module_path_string (const gchar *mod_path);
-static guint gtk_rc_parse_im_module_path (GScanner *scanner);
static guint gtk_rc_parse_im_module_file (GScanner *scanner);
static guint gtk_rc_parse_path_pattern (GtkRcContext *context,
GScanner *scanner);
@@ -179,7 +178,6 @@ static void gtk_rc_clear_hash_node (gpointer key,
gpointer data,
gpointer user_data);
static void gtk_rc_clear_styles (GtkRcContext *context);
-static void gtk_rc_append_default_module_path (void);
static void gtk_rc_add_initial_default_files (void);
static void gtk_rc_style_init (GtkRcStyle *style);
@@ -272,7 +270,6 @@ static const struct
{ "engine", GTK_RC_TOKEN_ENGINE },
{ "module_path", GTK_RC_TOKEN_MODULE_PATH },
{ "stock", GTK_RC_TOKEN_STOCK },
- { "im_module_path", GTK_RC_TOKEN_IM_MODULE_PATH },
{ "im_module_file", GTK_RC_TOKEN_IM_MODULE_FILE },
{ "LTR", GTK_RC_TOKEN_LTR },
{ "RTL", GTK_RC_TOKEN_RTL }
@@ -280,15 +277,11 @@ static const struct
static GHashTable *realized_style_ht = NULL;
-static gchar *im_module_path = NULL;
static gchar *im_module_file = NULL;
#define GTK_RC_MAX_DEFAULT_FILES 128
static gchar *gtk_rc_default_files[GTK_RC_MAX_DEFAULT_FILES];
-#define GTK_RC_MAX_MODULE_PATHS 128
-static gchar *module_path[GTK_RC_MAX_MODULE_PATHS];
-
/* A stack of directories for RC files we are parsing currently.
* these are implicitely added to the end of PIXMAP_PATHS
*/
@@ -317,29 +310,25 @@ gtk_rc_make_default_dir (const gchar *type)
* look for IM modules.
*
* Obtains the path in which to look for IM modules. See the documentation
- * of the <link linkend="im-module-path"><envar>GTK_IM_MODULE_PATH</envar></link>
- * environment variable for more details.
+ * of the <link linkend="im-module-path"><envar>GTK_PATH</envar></link>
+ * 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.
*/
gchar *
gtk_rc_get_im_module_path (void)
{
- const gchar *result = g_getenv ("GTK_IM_MODULE_PATH");
+ gchar **paths = _gtk_get_module_path ("immodules");
+ gchar *result = g_strjoinv (G_SEARCHPATH_SEPARATOR_S, paths);
+ g_strfreev (paths);
- if (!result)
- {
- if (im_module_path)
- result = im_module_path;
- else
- return gtk_rc_make_default_dir ("immodules");
- }
-
- return g_strdup (result);
+ return result;
}
/**
* gtk_rc_get_im_module_file:
* @returns: a newly-allocated string containing the name of the file
- * listing the IM modules to load
+ * listing the IM modules available for loading
*
* Obtains the path to the IM modules file. See the documentation
* of the <link linkend="im-module-file"><envar>GTK_IM_MODULE_FILE</envar></link>
@@ -383,33 +372,6 @@ gtk_rc_get_module_dir (void)
}
static void
-gtk_rc_append_default_module_path (void)
-{
- const gchar *var;
- gchar *path;
- gint n;
-
- for (n = 0; module_path[n]; n++) ;
- if (n >= GTK_RC_MAX_MODULE_PATHS - 1)
- return;
-
- var = g_getenv ("GTK_EXE_PREFIX");
- if (var)
- path = g_build_filename (var, "lib", "gtk-2.0", GTK_VERSION, "engines", NULL);
- else
- path = g_build_filename (GTK_LIBDIR, "gtk-2.0", GTK_VERSION, "engines", NULL);
- module_path[n++] = path;
-
- var = g_get_home_dir ();
- if (var)
- {
- path = g_build_filename (var, ".gtk-2.0", GTK_VERSION, "engines", NULL);
- module_path[n++] = path;
- }
- module_path[n] = NULL;
-}
-
-static void
gtk_rc_add_initial_default_files (void)
{
static gint init = FALSE;
@@ -655,9 +617,6 @@ _gtk_rc_init (void)
{
initialized = TRUE;
- module_path[0] = NULL;
- gtk_rc_append_default_module_path();
-
gtk_rc_add_initial_default_files ();
}
@@ -2265,9 +2224,6 @@ gtk_rc_parse_statement (GtkRcContext *context,
case GTK_RC_TOKEN_MODULE_PATH:
return gtk_rc_parse_module_path (scanner);
- case GTK_RC_TOKEN_IM_MODULE_PATH:
- return gtk_rc_parse_im_module_path (scanner);
-
case GTK_RC_TOKEN_IM_MODULE_FILE:
return gtk_rc_parse_im_module_file (scanner);
@@ -2873,28 +2829,20 @@ gtk_rc_find_pixmap_in_path (GtkSettings *settings,
return NULL;
}
+/**
+ * gtk_rc_find_module_in_path:
+ * @module_file: name of a theme engine
+ *
+ * Searches for a theme engine in the GTK+ search path. This function
+ * is not useful for applications and should not be used.
+ *
+ * Return value: The filename, if found (must be freed with g_free()),
+ * otherwise %NULL.
+ **/
gchar*
gtk_rc_find_module_in_path (const gchar *module_file)
{
- gint i;
- gint fd;
- gchar *buf;
-
- for (i = 0; (i < GTK_RC_MAX_MODULE_PATHS) && (module_path[i] != NULL); i++)
- {
- buf = g_build_filename (module_path[i], module_file, NULL);
-
- fd = open (buf, O_RDONLY);
- if (fd >= 0)
- {
- close (fd);
- return buf;
- }
-
- g_free (buf);
- }
-
- return NULL;
+ return _gtk_find_module (module_file, "engines");
}
static guint
@@ -3328,30 +3276,9 @@ gtk_rc_parse_module_path (GScanner *scanner)
token = g_scanner_get_next_token (scanner);
if (token != G_TOKEN_STRING)
return G_TOKEN_STRING;
-
- gtk_rc_parse_module_path_string (scanner->value.v_string);
-
- return G_TOKEN_NONE;
-}
-static guint
-gtk_rc_parse_im_module_path (GScanner *scanner)
-{
- guint token;
+ g_warning ("module_path directive is now ignored\n");
- token = g_scanner_get_next_token (scanner);
- if (token != GTK_RC_TOKEN_IM_MODULE_FILE)
- return GTK_RC_TOKEN_IM_MODULE_FILE;
-
- token = g_scanner_get_next_token (scanner);
- if (token != G_TOKEN_STRING)
- return G_TOKEN_STRING;
-
- if (im_module_path)
- g_free (im_module_path);
-
- im_module_path = g_strdup (scanner->value.v_string);
-
return G_TOKEN_NONE;
}
@@ -3376,39 +3303,6 @@ gtk_rc_parse_im_module_file (GScanner *scanner)
return G_TOKEN_NONE;
}
-static void
-gtk_rc_parse_module_path_string (const gchar *mod_path)
-{
- gint end_offset;
- gint start_offset = 0;
- gint path_len;
- gint path_num;
-
- /* free the old one, or just add to the old one ? */
- for (path_num=0; module_path[path_num]; path_num++)
- {
- g_free (module_path[path_num]);
- module_path[path_num] = NULL;
- }
-
- path_num = 0;
-
- path_len = strlen (mod_path);
-
- for (end_offset = 0; end_offset <= path_len; end_offset++)
- {
- if ((mod_path[end_offset] == G_SEARCHPATH_SEPARATOR) ||
- (end_offset == path_len))
- {
- module_path[path_num] = g_strndup (mod_path + start_offset, end_offset - start_offset);
- path_num++;
- module_path[path_num] = NULL;
- start_offset = end_offset + 1;
- }
- }
- gtk_rc_append_default_module_path();
-}
-
static guint
gtk_rc_parse_path_pattern (GtkRcContext *context,
GScanner *scanner)