Description: Don't hard-code library search paths
 Instead skip the directory when calling g_module_build_path () and let
 g_module_open () search the default system directories which includes the
 multiarch location.
Author: Julien Cristau <jcristau@debian.org>
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666241
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=675977
diff --git a/gladeui/glade-utils.c b/gladeui/glade-utils.c
index bf9542e..b764a93 100644
--- a/gladeui/glade-utils.c
+++ b/gladeui/glade-utils.c
@@ -854,12 +854,12 @@ try_load_library (const gchar *library_path, const gchar *library_name)
   GModule *module = NULL;
   gchar *path;
 
-  path = g_module_build_path (library_path, library_name);
-  if (g_file_test (path, G_FILE_TEST_EXISTS))
-    {
-      if (!(module = g_module_open (path, G_MODULE_BIND_LAZY)))
-        g_warning ("Failed to load %s: %s", path, g_module_error ());
-    }
+  if (library_path)
+    path = g_module_build_path (library_path, library_name);
+  else
+    path = g_module_build_path (NULL, library_name);
+  if (!(module = g_module_open (path, G_MODULE_BIND_LAZY)))
+    g_debug ("Failed to load %s: %s", path, g_module_error ());
   g_free (path);
 
   return module;
@@ -882,8 +882,6 @@ 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
   };
@@ -909,7 +907,7 @@ glade_util_load_library (const gchar *library_name)
 
   if (!module)
     {
-      /* Search ${prefix}/lib after searching ${prefix}/lib/glade3/modules... */
+      /* Search ${prefix}/lib after searching ${prefix}/lib/glade/modules... */
       default_paths[1] =
           g_build_filename (glade_app_get_modules_dir (), "..", "..", NULL);
 
@@ -921,6 +919,10 @@ glade_util_load_library (const gchar *library_name)
       g_free (default_paths[1]);
     }
 
+  /* Use default system paths */
+  if (!module)
+    module = try_load_library (NULL, library_name);
+
   if (!module)
     g_critical ("Unable to load module '%s' from any search paths",
                 library_name);
