[geary/mjog/plugin-support: 3/6] Add PluginManager class for client plugin support
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/plugin-support: 3/6] Add PluginManager class for client plugin support
- Date: Fri, 27 Sep 2019 01:00:36 +0000 (UTC)
commit 3c80a876e96c6621d20e927b5fb000386cf633a0
Author: Michael Gratton <mike vee net>
Date: Thu Sep 26 23:25:19 2019 +1000
Add PluginManager class for client plugin support
meson.build | 2 ++
po/POTFILES.in | 1 +
src/client/application/application-controller.vala | 6 +++++
.../application/application-plugin-manager.vala | 29 ++++++++++++++++++++++
src/client/application/geary-application.vala | 14 +++++++++++
src/client/meson.build | 1 +
6 files changed, 53 insertions(+)
---
diff --git a/meson.build b/meson.build
index befc23ce..acd5c36b 100644
--- a/meson.build
+++ b/meson.build
@@ -46,6 +46,7 @@ vapi_dir = join_paths(meson.source_root(), 'bindings', 'vapi')
metadata_dir = join_paths(meson.source_root(), 'bindings', 'metadata')
dbus_services_dir = join_paths(datadir, 'dbus-1', 'services')
web_extensions_dir = join_paths(libdir, 'geary', 'web-extensions')
+plugins_dir = join_paths(libdir, 'geary', 'plugins')
# Make sure Meson can find our custom VAPI's
add_project_arguments([
@@ -201,6 +202,7 @@ conf.set_quoted('_SOURCE_ROOT_DIR', meson.source_root())
conf.set_quoted('_GSETTINGS_DIR', join_paths(meson.build_root(), 'desktop'))
conf.set_quoted('_INSTALL_PREFIX', geary_prefix)
conf.set_quoted('_WEB_EXTENSIONS_DIR', web_extensions_dir)
+conf.set_quoted('_PLUGINS_DIR', plugins_dir)
conf.set_quoted('LANGUAGE_SUPPORT_DIRECTORY', locale_dir)
conf.set_quoted('ISO_CODE_639_XML', iso_639_xml)
conf.set_quoted('ISO_CODE_3166_XML', iso_3166_xml)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2556078e..5ca2387f 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -20,6 +20,7 @@ src/client/application/application-command.vala
src/client/application/application-contact-store.vala
src/client/application/application-contact.vala
src/client/application/application-controller.vala
+src/client/application/application-plugin-manager.vala
src/client/application/application-startup-manager.vala
src/client/application/geary-application.vala
src/client/application/goa-mediator.vala
diff --git a/src/client/application/application-controller.vala
b/src/client/application/application-controller.vala
index ea70af67..da6c7b2e 100644
--- a/src/client/application/application-controller.vala
+++ b/src/client/application/application-controller.vala
@@ -152,6 +152,8 @@ public class Application.Controller : Geary.BaseObject {
private NewMessagesIndicator new_messages_indicator;
private UnityLauncher unity_launcher;
+ private PluginManager plugin_manager;
+
// Null if none selected
private Geary.Folder? current_folder = null;
@@ -271,6 +273,10 @@ public class Application.Controller : Geary.BaseObject {
}
+ this.plugin_manager = new PluginManager(
+ application.get_app_plugins_dir()
+ );
+
// Create the main window (must be done after creating actions.)
main_window = new MainWindow(this.application);
main_window.retry_service_problem.connect(on_retry_service_problem);
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
new file mode 100644
index 00000000..8582fead
--- /dev/null
+++ b/src/client/application/application-plugin-manager.vala
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 Michael Gratton <mike vee net>
+ *
+ * This software is licensed under the GNU Lesser General Public License
+ * (version 2.1 or later). See the COPYING file in this distribution.
+ */
+
+/*
+ * Finds and manages application plugins.
+ */
+public class Application.PluginManager : GLib.Object {
+
+
+ private Peas.Engine engine;
+
+
+ public PluginManager(GLib.File app_plugin_dir) {
+ this.engine = Peas.Engine.get_default();
+ this.engine.add_search_path(app_plugin_dir.get_path(), null);
+
+ // Load built-in plugins
+ foreach (Peas.PluginInfo info in this.engine.get_plugin_list()) {
+ if (info.is_builtin()) {
+ this.engine.load_plugin(info);
+ }
+ }
+ }
+
+}
diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala
index 834ea088..f09da89d 100644
--- a/src/client/application/geary-application.vala
+++ b/src/client/application/geary-application.vala
@@ -10,6 +10,7 @@
extern const string _INSTALL_PREFIX;
extern const string _GSETTINGS_DIR;
extern const string _WEB_EXTENSIONS_DIR;
+extern const string _PLUGINS_DIR;
extern const string _SOURCE_ROOT_DIR;
extern const string _BUILD_ROOT_DIR;
extern const string GETTEXT_PACKAGE;
@@ -614,6 +615,19 @@ public class GearyApplication : Gtk.Application {
: GLib.File.new_for_path(BUILD_ROOT_DIR).get_child("src");
}
+ /**
+ * Returns the directory containing the application's plugins.
+ *
+ * When running from the installation prefix, this will be based
+ * on the Meson `libdir` option, and can be set by invoking `meson
+ * configure` as appropriate.
+ */
+ public GLib.File get_app_plugins_dir() {
+ return (is_installed)
+ ? GLib.File.new_for_path(_PLUGINS_DIR)
+ : GLib.File.new_for_path(BUILD_ROOT_DIR).get_child("src");
+ }
+
/** 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(
diff --git a/src/client/meson.build b/src/client/meson.build
index a58d67df..dc2cdf93 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -6,6 +6,7 @@ geary_client_vala_sources = files(
'application/application-contact-store.vala',
'application/application-contact.vala',
'application/application-controller.vala',
+ 'application/application-plugin-manager.vala',
'application/application-startup-manager.vala',
'application/geary-application.vala',
'application/geary-config.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]