Add PluginManager class for client plugin support
This commit is contained in:
parent
a872fc34bb
commit
c89766c7e8
6 changed files with 53 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
29
src/client/application/application-plugin-manager.vala
Normal file
29
src/client/application/application-plugin-manager.vala
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue