Commit c50a7358 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

Let g_module_open() be called with NULL so that it looks libraries in defaults directories

Fixes bug #675977 "Don't hard-code library search paths"
parent b0bb77b4
......@@ -40,7 +40,8 @@ common_defines = \
-DGLADE_MODULESDIR="\"$(pkglibdir)/modules\"" \
-DGLADE_PIXMAPSDIR="\"$(pkgdatadir)/pixmaps\"" \
-DGLADE_LOCALEDIR="\"$(datadir)/locale\""\
-DGLADE_BINDIR="\"$(bindir)\""
-DGLADE_BINDIR="\"$(bindir)\""\
-DGLADE_LIBDIR="\"$(libdir)\""
BUILT_SOURCES = glade-marshallers.c glade-marshallers.h
......
......@@ -85,6 +85,7 @@ static gchar *modules_dir = NULL;
static gchar *pixmaps_dir = NULL;
static gchar *locale_dir = NULL;
static gchar *bin_dir = NULL;
static gchar *lib_dir = NULL;
static GladeApp *singleton_app = NULL;
static gboolean check_initialised = FALSE;
......@@ -148,6 +149,7 @@ glade_app_finalize (GObject * app)
g_free (pixmaps_dir);
g_free (locale_dir);
g_free (bin_dir);
g_free (lib_dir);
singleton_app = NULL;
check_initialised = FALSE;
......@@ -175,6 +177,7 @@ build_package_paths (void)
modules_dir = g_build_filename (prefix, "lib", PACKAGE, "modules", NULL);
locale_dir = g_build_filename (prefix, "share", "locale", NULL);
bin_dir = g_build_filename (prefix, "bin", NULL);
lib_dir = g_build_filename (prefix, "lib", NULL);
g_free (prefix);
#else
......@@ -183,6 +186,7 @@ build_package_paths (void)
pixmaps_dir = g_strdup (GLADE_PIXMAPSDIR);
locale_dir = g_strdup (GLADE_LOCALEDIR);
bin_dir = g_strdup (GLADE_BINDIR);
lib_dir = g_strdup (GLADE_LIBDIR);
#endif
}
......@@ -247,6 +251,14 @@ glade_app_get_bin_dir (void)
return bin_dir;
}
const gchar *
glade_app_get_lib_dir (void)
{
glade_init_check ();
return lib_dir;
}
static void
pointer_mode_register_icon (GtkIconFactory *factory,
const gchar *icon_name,
......
......@@ -102,6 +102,7 @@ const gchar *glade_app_get_plugins_dir (void) G_GNUC_CONST;
const gchar *glade_app_get_pixmaps_dir (void) G_GNUC_CONST;
const gchar *glade_app_get_locale_dir (void) G_GNUC_CONST;
const gchar *glade_app_get_bin_dir (void) G_GNUC_CONST;
const gchar *glade_app_get_lib_dir (void) G_GNUC_CONST;
G_END_DECLS
......
......@@ -869,8 +869,8 @@ try_load_library (const gchar *library_path, const gchar *library_name)
* glade_util_load_library:
* @library_name: name of the library
*
* Loads the named library from the Glade modules directory, or failing that
* from the standard platform specific directories.
* Loads the named library from the Glade modules and lib directory or failing that
* from the standard platform specific directories. (Including /usr/local/lib for unices)
*
* The @library_name should not include any platform specifix prefix or suffix,
* those are automatically added, if needed, by g_module_build_path()
......@@ -880,23 +880,23 @@ try_load_library (const gchar *library_path, const gchar *library_name)
GModule *
glade_util_load_library (const gchar *library_name)
{
gchar *default_paths[] = { (gchar *) glade_app_get_modules_dir (),
NULL, /* <-- dynamically allocated */
"/lib",
"/usr/lib",
"/usr/local/lib",
NULL
};
const gchar *paths[] =
{
glade_app_get_modules_dir (),
glade_app_get_lib_dir (),
#ifndef G_OS_WIN32
"/usr/local/lib", /* Try local lib dir on Unices */
#endif
NULL /* Use default system paths */
};
GModule *module = NULL;
const gchar *search_path;
gchar **split;
gint i;
if ((search_path = g_getenv (GLADE_ENV_MODULE_PATH)) != NULL)
{
gchar **split;
if ((split = g_strsplit (search_path, ":", 0)) != NULL)
{
for (i = 0; split[i] != NULL; i++)
......@@ -909,22 +909,11 @@ glade_util_load_library (const gchar *library_name)
if (!module)
{
/* Search ${prefix}/lib after searching ${prefix}/lib/glade3/modules... */
default_paths[1] =
g_build_filename (glade_app_get_modules_dir (), "..", "..", NULL);
for (i = 0; default_paths[i] != NULL; i++)
if ((module =
try_load_library (default_paths[i], library_name)) != NULL)
for (i = 0; i < G_N_ELEMENTS (paths); i++)
if ((module = try_load_library (paths[i], library_name)) != NULL)
break;
g_free (default_paths[1]);
}
if (!module)
g_critical ("Unable to load module '%s' from any search paths",
library_name);
return module;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment