diff options
author | Marvin W <git@larma.de> | 2017-08-29 21:47:53 +0200 |
---|---|---|
committer | Marvin W <git@larma.de> | 2017-08-29 22:08:31 +0200 |
commit | 7c2023803ebdc83393d6ea56287222a223febc3d (patch) | |
tree | 664eca9da51a87ac5903ee625a2baf90780743a6 /libdino/src/util.vala | |
parent | 82a8f5c38df5abf2848084c8a6743d4d7cd40208 (diff) | |
download | dino-7c2023803ebdc83393d6ea56287222a223febc3d.tar.gz dino-7c2023803ebdc83393d6ea56287222a223febc3d.zip |
libdino: try to load all plugins found in the respective folders
Diffstat (limited to 'libdino/src/util.vala')
-rw-r--r-- | libdino/src/util.vala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libdino/src/util.vala b/libdino/src/util.vala index 85047dd8..cc705c10 100644 --- a/libdino/src/util.vala +++ b/libdino/src/util.vala @@ -1,5 +1,8 @@ namespace Dino { +private extern const string SYSTEM_LIBDIR_NAME; +private extern const string SYSTEM_PLUGIN_DIR; + public class SearchPathGenerator { public string? exec_path { get; private set; } @@ -18,6 +21,28 @@ public class SearchPathGenerator { } return locale_dir ?? locale_install_dir; } + + public string[] get_plugin_paths() { + string[] search_paths = new string[0]; + if (Environment.get_variable("DINO_PLUGIN_DIR") != null) { + search_paths += Environment.get_variable("DINO_PLUGIN_DIR"); + } + search_paths += Path.build_filename(Environment.get_home_dir(), ".local", "lib", "dino", "plugins"); + string? exec_path = this.exec_path; + if (exec_path != null) { + if (!exec_path.contains(Path.DIR_SEPARATOR_S)) { + exec_path = Environment.find_program_in_path(this.exec_path); + } + if (Path.get_dirname(exec_path).contains("dino") || Path.get_dirname(exec_path) == "." || Path.get_dirname(exec_path).contains("build")) { + search_paths += Path.build_filename(Path.get_dirname(exec_path), "plugins"); + } + if (Path.get_basename(Path.get_dirname(exec_path)) == "bin") { + search_paths += Path.build_filename(Path.get_dirname(Path.get_dirname(exec_path)), SYSTEM_LIBDIR_NAME, "dino", "plugins"); + } + } + search_paths += SYSTEM_PLUGIN_DIR; + return search_paths; + } } public static string get_storage_dir() { |