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



commit 8f0a2f8dbf4061fb800032149af0da2fbd6b44ce
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 | 33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/peas-demo/peas-demo.c b/peas-demo/peas-demo.c
index 466a392..c6c0cf3 100644
--- a/peas-demo/peas-demo.c
+++ b/peas-demo/peas-demo.c
@@ -154,9 +154,36 @@ 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;
+      char *demo_pluginlibdir, *demo_plugindatadir;
+
+      peas_engine_add_search_path (engine,
+                                   PEAS_LIBDIR "/peas-demo/plugins/",
+                                   PEAS_PREFIX "/share/peas-demo/plugins");
+
+#ifdef G_OS_WIN32
+      /* this is so that the paths are relocatable on Windows */
+      prefix = g_win32_get_package_installation_directory_of_module (NULL);
+      demo_pluginlibdir = g_build_filename (prefix,
+                                            "lib",
+                                            "peas-demo",
+                                            "plugins",
+                                            NULL);
+      demo_plugindatadir = g_build_filename (prefix,
+                                             "share",
+                                             "peas-demo",
+                                             "plugins",
+                                             NULL);
+      peas_engine_add_search_path (engine,
+                                   demo_pluginlibdir,
+                                   demo_plugindatadir);
+
+      g_free (demo_plugindatadir);
+      g_free (demo_pluginlibdir);
+      g_free (prefix);
+#endif
+    }
 
   n_windows = 0;
   main_window = create_main_window ();


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