GtkModule fixes (#56916)
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Cc: timj gtk org
- Subject: GtkModule fixes (#56916)
- Date: 08 Sep 2001 20:29:25 -0400
[ Resend s/gtk-devel-lsit/gtk-devel-list/ ]
Hi Tim,
The following patch I think fixes all issues for #56916.
The search path defaults to
$libdir/gtk-2.0/<type>/major.minor.(micro-binary_age),
but can be augmented with the GTK_MODULE_PATH environment
variable.
If you give it a quick look over to make sure that you
are happy with it, I'd appreciate it.
Regards,
Owen
Sat Sep 8 16:19:02 2001 Owen Taylor <otaylor redhat com>
* gtk/gtkmain.c: Implement a search path for GTK+ modules.
* configure.in gtk/gtkrc.c gtk/Makefile.am: Look for modules
in gtk-2.0/<type>/major.minor.(micro-binary_age) rather
than in gtk-2.0/major.minor.micro/<type>/. This
works better for a search path for modules.
* gtk+-2.0.pc.in gtk+-2.0-uninstalled.pc.in: Add
gtk_binary_version variable holding major.minor.(micro-binary_age).
* modules/input/Makefile.am (moduledir): Fix installation
directory to match change in lookup location.
* gtk/gtkmain.c (gtk_init_check): Remove OS/2 code for dll
suffixes. Needs to be handled in g_module_build_path().
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.2262
diff -u -r1.2262 ChangeLog
--- ChangeLog 2001/09/08 17:55:01 1.2262
+++ ChangeLog 2001/09/09 00:01:06
@@ -1,3 +1,21 @@
+Sat Sep 8 16:19:02 2001 Owen Taylor <otaylor redhat com>
+
+ * gtk/gtkmain.c: Implement a search path for GTK+ modules.
+
+ * configure.in gtk/gtkrc.c gtk/Makefile.am: Look for modules
+ in gtk-2.0/<type>/major.minor.(micro-binary_age) rather
+ than in gtk-2.0/major.minor.micro/<type>/. This
+ works better for a search path for modules.
+
+ * gtk+-2.0.pc.in gtk+-2.0-uninstalled.pc.in: Add
+ gtk_binary_version variable holding major.minor.(micro-binary_age).
+
+ * modules/input/Makefile.am (moduledir): Fix installation
+ directory to match change in lookup location.
+
+ * gtk/gtkmain.c (gtk_init_check): Remove OS/2 code for dll
+ suffixes. Needs to be handled in g_module_build_path().
+
Sat Sep 8 13:53:09 2001 Owen Taylor <otaylor redhat com>
* gtk/gtkrc.[ch] gtk/gtkstyle.[ch]: Replace uses of GBSearchArray
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtk+/configure.in,v
retrieving revision 1.224
diff -u -r1.224 configure.in
--- configure.in 2001/09/04 16:06:54 1.224
+++ configure.in 2001/09/09 00:01:06
@@ -58,6 +58,12 @@
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)
+# Define a string for the earliest version that this release has
+# binary compatibility with. This is used for module locations.
+#
+GTK_BINARY_VERSION=$GTK_MAJOR_VERSION.$GTK_MINOR_VERSION.$LT_CURRENT
+AC_SUBST(GTK_BINARY_VERSION)
+
#
# gdk-pixbuf gets versioned separately, and for now, using standard
# libtool versioning, not GTK+-style versioning
Index: gtk+-2.0-uninstalled.pc.in
===================================================================
RCS file: /cvs/gnome/gtk+/gtk+-2.0-uninstalled.pc.in,v
retrieving revision 1.1
diff -u -r1.1 gtk+-2.0-uninstalled.pc.in
--- gtk+-2.0-uninstalled.pc.in 2001/06/07 16:39:56 1.1
+++ gtk+-2.0-uninstalled.pc.in 2001/09/09 00:01:06
@@ -1,5 +1,7 @@
target= gdktarget@
+gtk_binary_version= GTK_BINARY_VERSION@
+
Name: GTK+ Uninstalled
Description: GIMP Tool Kit (${target} target), Not Installed
Version: @VERSION@
Index: gtk+-2.0.pc.in
===================================================================
RCS file: /cvs/gnome/gtk+/gtk+-2.0.pc.in,v
retrieving revision 1.6
diff -u -r1.6 gtk+-2.0.pc.in
--- gtk+-2.0.pc.in 2001/05/03 20:10:49 1.6
+++ gtk+-2.0.pc.in 2001/09/09 00:01:06
@@ -4,6 +4,8 @@
includedir= includedir@
target= gdktarget@
+gtk_binary_version= GTK_BINARY_VERSION@
+
Name: GTK+
Description: GIMP Tool Kit (${target} target)
Version: @VERSION@
Index: gtk/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/Makefile.am,v
retrieving revision 1.181
diff -u -r1.181 Makefile.am
--- gtk/Makefile.am 2001/09/08 00:56:29 1.181
+++ gtk/Makefile.am 2001/09/09 00:01:08
@@ -9,6 +9,7 @@
-DGTK_SYSCONFDIR=\"$(sysconfdir)\" \
-DGTK_LOCALEDIR=\"$(gtklocaledir)\" \
-DGTK_VERSION=\"@GTK_VERSION \" \
+ -DGTK_BINARY_VERSION=\"@GTK_BINARY_VERSION \" \
-DTESTGTK_RCFILE=\"`pwd`/$(srcdir)/testgtkrc\" \
-DG_DISABLE_CONST_RETURNS \
-I$(top_builddir)/gtk \
Index: gtk/gtkmain.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkmain.c,v
retrieving revision 1.174
diff -u -r1.174 gtkmain.c
--- gtk/gtkmain.c 2001/09/08 04:39:53 1.174
+++ gtk/gtkmain.c 2001/09/09 00:01:09
@@ -39,6 +39,9 @@
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
+
+#include <pango/pango-utils.h> /* For pango_split_file_list */
+
#include "gtkdnd.h"
#include "gtkversion.h"
#include "gtkmain.h"
@@ -174,23 +177,6 @@
return NULL;
}
-#ifdef __EMX__
-static gchar *
-add_dll_suffix (gchar *module_name)
-{
- gchar *suffix = strrchr (module_name, '.');
-
- if (!suffix || stricmp(suffix, ".dll"))
- {
- gchar *old = module_name;
-
- module_name = g_strconcat (module_name, ".dll", NULL);
- g_free (old);
- }
- return (module_name);
-}
-#endif
-
#undef gtk_init_check
/* This checks to see if the process is running suid or sgid
@@ -238,13 +224,145 @@
return TRUE;
}
+static gchar **
+get_module_path (void)
+{
+ gchar *module_path = g_getenv ("GTK_MODULE_PATH");
+ gchar *exe_prefix = g_getenv("GTK_EXE_PREFIX");
+ gchar **result;
+ gchar *default_dir;
+
+ if (exe_prefix)
+ default_dir = g_strconcat (exe_prefix, "/lib/gtk-2.0/modules", NULL);
+ else
+ default_dir = g_strdup (GTK_LIBDIR "/gtk-2.0/modules");
+
+ module_path = g_strconcat (module_path ? module_path : "",
+ module_path ? G_SEARCHPATH_SEPARATOR_S : "",
+ default_dir, NULL);
+
+ 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)
+{
+ GModule *module;
+ gchar *module_name;
+ gint i;
+
+ if (g_path_is_absolute (name))
+ return g_module_open (name, G_MODULE_BIND_LAZY);
+
+ for (i = 0; module_path[i]; i++)
+ {
+ gchar *version_directory;
+
+ version_directory = g_strconcat (module_path[i], G_DIR_SEPARATOR_S 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))
+ {
+ g_free (module_name);
+ return g_module_open (module_name, G_MODULE_BIND_LAZY);
+ }
+
+ g_free (module_name);
+
+ module_name = g_module_build_path (module_path[i], name);
+
+ if (g_file_test (module_name, G_FILE_TEST_EXISTS))
+ {
+ g_free (module_name);
+ return g_module_open (module_name, G_MODULE_BIND_LAZY);
+ }
+
+ g_free (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);
+
+ return module;
+}
+
+static GSList *
+load_module (GSList *gtk_modules,
+ gchar **module_path,
+ const gchar *name)
+{
+ GtkModuleInitFunc modinit_func = NULL;
+ GModule *module = NULL;
+
+ if (g_module_supported ())
+ {
+ module = find_module (module_path, name);
+ if (module &&
+ g_module_symbol (module, "gtk_module_init", (gpointer*) &modinit_func) &&
+ modinit_func)
+ {
+ if (!g_slist_find (gtk_modules, modinit_func))
+ {
+ g_module_make_resident (module);
+ gtk_modules = g_slist_prepend (gtk_modules, modinit_func);
+ }
+ else
+ {
+ g_module_close (module);
+ module = NULL;
+ }
+ }
+ }
+ if (!modinit_func)
+ {
+ g_message ("Failed to load module \"%s\": %s",
+ module ? g_module_name (module) : name,
+ g_module_error ());
+ if (module)
+ g_module_close (module);
+ }
+
+ return gtk_modules;
+}
+
+static GSList *
+load_modules (const char *module_str)
+{
+ gchar **module_path = get_module_path ();
+ gchar **module_names = pango_split_file_list (module_str);
+ GSList *gtk_modules = NULL;
+ gint i;
+
+ for (i = 0; module_names[i]; i++)
+ gtk_modules = load_module (gtk_modules, module_path, module_names[i]);
+
+ gtk_modules = g_slist_reverse (gtk_modules);
+
+ g_strfreev (module_names);
+ g_strfreev (module_path);
+
+ return gtk_modules;
+}
+
gboolean
gtk_init_check (int *argc,
char ***argv)
{
+ GString *gtk_modules_string = NULL;
GSList *gtk_modules = NULL;
GSList *slist;
- gchar *env_string = NULL;
+ gchar *env_string;
if (gtk_initialized)
return TRUE;
@@ -280,24 +398,7 @@
env_string = getenv ("GTK_MODULES");
if (env_string)
- {
- gchar **modules, **as;
-
-#ifndef __EMX__
- modules = g_strsplit (env_string, G_SEARCHPATH_SEPARATOR_S, -1);
-#else
- modules = g_strsplit (env_string, ";", -1);
-#endif
- for (as = modules; *as; as++)
- {
- if (**as)
- gtk_modules = g_slist_prepend (gtk_modules, *as);
- else
- g_free (*as);
- }
- g_free (modules);
- env_string = NULL;
- }
+ gtk_modules_string = g_string_new (env_string);
if (argc && argv)
{
@@ -321,7 +422,14 @@
(*argv)[i] = NULL;
if (module_name && *module_name)
- gtk_modules = g_slist_prepend (gtk_modules, g_strdup (module_name));
+ {
+ if (gtk_modules_string)
+ g_string_append_c (gtk_modules_string, G_SEARCHPATH_SEPARATOR);
+ else
+ gtk_modules_string = g_string_new (NULL);
+
+ g_string_append (gtk_modules_string, module_name);
+ }
}
else if (strcmp ("--g-fatal-warnings", (*argv)[i]) == 0)
{
@@ -397,56 +505,12 @@
if (gtk_debug_flags & GTK_DEBUG_UPDATES)
gdk_window_set_debug_updates (TRUE);
-
+
/* load gtk modules */
- gtk_modules = g_slist_reverse (gtk_modules);
- for (slist = gtk_modules; slist; slist = slist->next)
+ if (gtk_modules_string)
{
- gchar *module_name;
- GModule *module = NULL;
- GtkModuleInitFunc modinit_func = NULL;
-
- module_name = slist->data;
- slist->data = NULL;
-#ifndef __EMX__
- if (!g_path_is_absolute (module_name))
- {
- gchar *old = module_name;
-
- module_name = g_module_build_path (NULL, module_name);
- g_free (old);
- }
-#else
- module_name = add_dll_suffix (module_name);
-#endif
- if (g_module_supported ())
- {
- module = g_module_open (module_name, G_MODULE_BIND_LAZY);
- if (module &&
- g_module_symbol (module, "gtk_module_init", (gpointer*) &modinit_func) &&
- modinit_func)
- {
- if (!g_slist_find (gtk_modules, modinit_func))
- {
- g_module_make_resident (module);
- slist->data = modinit_func;
- }
- else
- {
- g_module_close (module);
- module = NULL;
- }
- }
- }
- if (!modinit_func)
- {
- g_message ("Failed to load module \"%s\": %s",
- module ? g_module_name (module) : module_name,
- g_module_error ());
- if (module)
- g_module_close (module);
- }
- g_free (module_name);
+ gtk_modules = load_modules (gtk_modules_string->str);
+ g_string_free (gtk_modules_string, TRUE);
}
#ifdef ENABLE_NLS
Index: gtk/gtkrc.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkrc.c,v
retrieving revision 1.88
diff -u -r1.88 gtkrc.c
--- gtk/gtkrc.c 2001/09/08 17:55:02 1.88
+++ gtk/gtkrc.c 2001/09/09 00:01:09
@@ -324,9 +324,9 @@
#ifndef G_OS_WIN32
var = getenv("GTK_EXE_PREFIX");
if (var)
- path = g_strconcat (var, "/lib/gtk-2.0/" GTK_VERSION "/", type, NULL);
+ path = g_strconcat (var, "/lib/gtk-2.0/", type, "/" GTK_BINARY_VERSION, NULL);
else
- path = g_strconcat (GTK_LIBDIR "/gtk-2.0/" GTK_VERSION "/", type, NULL);
+ path = g_strconcat (GTK_LIBDIR "/gtk-2.0/", type, "/" GTK_BINARY_VERSION, NULL);
#else
path = g_strconcat ("%s\\%s", get_themes_directory (), type);
#endif
Index: modules/input/Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk+/modules/input/Makefile.am,v
retrieving revision 1.15
diff -u -r1.15 Makefile.am
--- modules/input/Makefile.am 2001/09/04 16:06:59 1.15
+++ modules/input/Makefile.am 2001/09/09 00:01:10
@@ -22,7 +22,7 @@
@GTK_DEP_LIBS@ \
@STRIP_END@
-moduledir = $(libdir)/gtk-2.0/$(GTK_VERSION)/immodules
+moduledir = $(libdir)/gtk-2.0/immodules/$(GTK_BINARY_VERSION)
im_xim_la_LDFLAGS = -rpath $(moduledir) -avoid-version -module
im_xim_la_SOURCES = \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]