[geary/mjog/python-plugin-support: 1/3] Load plugins from $HOME



commit 86972f46df02280a8e756d526fc0d4a8978dc0d1
Author: Michael Gratton <mike vee net>
Date:   Fri Sep 27 22:43:07 2019 +1000

    Load plugins from $HOME

 src/client/application/application-plugin-manager.vala | 18 +++++++++++++++---
 src/client/application/geary-application.vala          |  7 +++++++
 2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/src/client/application/application-plugin-manager.vala 
b/src/client/application/application-plugin-manager.vala
index 89fa686b..1e799ce5 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -25,9 +25,15 @@ public class Application.PluginManager : GLib.Object {
         this.engine.add_search_path(
             application.get_app_plugins_dir().get_path(), null
         );
+        this.engine.add_search_path(
+            application.get_home_plugins_dir().get_path(), null
+        );
     }
 
     public void load() {
+        string app_prefix = this.application.get_app_plugins_dir().get_path();
+        string local_prefix = this.application.get_home_plugins_dir().get_path();
+
         this.notification_extensions = new Peas.ExtensionSet(
             this.engine,
             typeof(Plugin.Notification),
@@ -41,12 +47,18 @@ public class Application.PluginManager : GLib.Object {
                 (extension as Plugin.Notification).deactivate(this.is_shutdown);
             });
 
-        // Load built-in plugins by default
+        debug("Loading app plugins from: %s", app_prefix);
+        debug("Loading local plugins from: %s", local_prefix);
+
         foreach (Peas.PluginInfo info in this.engine.get_plugin_list()) {
             try {
                 info.is_available();
-                if (info.is_builtin()) {
-                    debug("Loading built-in plugin: %s", info.get_name());
+                if (info.get_module_dir().has_prefix(app_prefix) &&
+                    info.is_builtin()) {
+                    debug("Loading app built-in plugin: %s", info.get_name());
+                    this.engine.load_plugin(info);
+                } else if (info.get_module_dir().has_prefix(local_prefix)) {
+                    debug("Loading local plugin: %s", info.get_name());
                     this.engine.load_plugin(info);
                 } else {
                     debug("Not loading plugin: %s", info.get_name());
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 5746ad0c..83cdf74f 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -633,6 +633,13 @@ public class GearyApplication : Gtk.Application {
                   .get_child("src").get_child("client").get_child("plugin");
     }
 
+    /**
+     * Returns the directory containing the home directory plugins.
+     */
+    public GLib.File get_home_plugins_dir() {
+        return get_user_data_directory().get_child("plugins");
+    }
+
     /** Displays a URI on the current active window, if any. */
     public void show_uri(string uri) throws Error {
         bool success = Gtk.show_uri_on_window(


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