[libpeas/msvc: 12/12] peas-demo: Don't hardcode installed paths on Windows



commit 8fbc721d895640c469988559fa93d708d3bba3cd
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Oct 15 17:39:40 2018 +0800

    peas-demo: Don't hardcode installed paths on Windows
    
    Construct the paths dynamically, since things tend to be relocated on
    Windows regularly.

 peas-demo/peas-demo.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c
index 2a996f8..ecbd8ca 100644
--- a/peas-demo/peas-demo.c
+++ b/peas-demo/peas-demo.c
@@ -143,9 +143,29 @@ main (int    argc,
   if (run_from_build_dir)
     peas_engine_add_search_path (engine, PEAS_BUILDDIR "/peas-demo/plugins", NULL);
   else
-    peas_engine_add_search_path (engine,
-                                 PEAS_LIBDIR "/peas-demo/plugins/",
-                                 PEAS_PREFIX "/share/peas-demo/plugins");
+    {
+      char *prefix, *libdir;
+      char *demo_pluginlibdir, *demo_plugindatadir;
+
+#ifdef G_OS_WIN32
+      prefix = g_win32_get_package_installation_directory_of_module (NULL);
+      libdir = g_build_filename (prefix, "lib", "libpeas-1.0", NULL);
+#else
+      prefix = g_strdup (PEAS_PREFIX);
+      libdir = g_strdup (PEAS_LIBDIR);
+#endif
+      demo_pluginlibdir = g_build_filename (libdir, "peas-demo", "plugins", NULL);
+      demo_plugindatadir = g_build_filename (prefix, "share", "libpeas-1.0", "peas-demo", "plugins", NULL);
+
+      peas_engine_add_search_path (engine,
+                                   demo_pluginlibdir,
+                                   demo_plugindatadir);
+
+      g_free (demo_plugindatadir);
+      g_free (demo_pluginlibdir);
+      g_free (libdir);
+      g_free (prefix);
+    }
 
   n_windows = 0;
   main_window = create_main_window ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]