From 6376360bd33778c751d878a1c722fcaedbe69512 Mon Sep 17 00:00:00 2001
From: Lionel Le Folgoc <lionel@lefolgoc.net>
Date: Tue, 11 Oct 2011 21:30:17 +0200
Subject: Look for plugins in {non-,}multiarch THUNARX_DIRECTORY

This will let a multiarch enabled libthunarx find plugins built against a
non-multiarch thunar (load plugins from both /usr/lib/$triplet and /usr/lib).

Forwarded: not-needed
---
 thunarx/thunarx-provider-factory.c |   12 +++++++++++-
 thunarx/thunarx-provider-module.c  |    6 ++++++
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/thunarx/thunarx-provider-factory.c b/thunarx/thunarx-provider-factory.c
index f2588eb..cbcf642 100644
--- a/thunarx/thunarx-provider-factory.c
+++ b/thunarx/thunarx-provider-factory.c
@@ -145,8 +145,17 @@ thunarx_provider_factory_load_modules (ThunarxProviderFactory *factory)
   GList                 *modules = NULL;
   GList                 *lp;
   GDir                  *dp;
+  gsize                  i;
+  const gchar           *thunarx_dirs[] =
+                          {
+                            THUNARX_DIRECTORY,
+                            "/usr/lib/thunarx-2"
+                          };
 
-  dp = g_dir_open (THUNARX_DIRECTORY, 0, NULL);
+  /* Search both multiarch and non-multiarch THUNARX_DIRECTORYs */
+  for (i = 0; i < G_N_ELEMENTS (thunarx_dirs); ++i)
+  {
+  dp = g_dir_open (thunarx_dirs[i], 0, NULL);
   if (G_LIKELY (dp != NULL))
     {
       /* determine the types for all existing plugins */
@@ -192,6 +201,7 @@ thunarx_provider_factory_load_modules (ThunarxProviderFactory *factory)
 
       g_dir_close (dp);
     }
+  }
 
   return modules;
 }
diff --git a/thunarx/thunarx-provider-module.c b/thunarx/thunarx-provider-module.c
index 4f96ffd..dbb693b 100644
--- a/thunarx/thunarx-provider-module.c
+++ b/thunarx/thunarx-provider-module.c
@@ -178,6 +178,12 @@ thunarx_provider_module_load (GTypeModule *type_module)
 
   /* load the module using the runtime link editor */
   path = g_build_filename (THUNARX_DIRECTORY, type_module->name, NULL);
+  if (!g_file_test (path, G_FILE_TEST_EXISTS))
+    {
+      /* if it doesn't exist in the default dir, try non-multiarch THUNARX_DIRECTORY */
+      g_free (path);
+      path = g_build_filename ("/usr/lib/thunarx-2", type_module->name, NULL);
+    }
   module->library = g_module_open (path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
   g_free (path);
 
-- 
1.7.7

