[geary/mjog/sound-plugin-feedback: 1/3] Plugin.PluginBase: Add `is_startup` parameter to `activate`
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/sound-plugin-feedback: 1/3] Plugin.PluginBase: Add `is_startup` parameter to `activate`
- Date: Sun, 16 Aug 2020 04:47:46 +0000 (UTC)
commit 10c7ab197e7e095d4497b3f6fe3b804ba77bcca6
Author: Michael Gratton <mike vee net>
Date: Sun Aug 16 14:40:07 2020 +1000
Plugin.PluginBase: Add `is_startup` parameter to `activate`
This allows plugins to take different actions depending on if they are
being first loaded or not.
src/client/application/application-plugin-manager.vala | 14 +++++++++-----
.../desktop-notifications/desktop-notifications.vala | 2 +-
src/client/plugin/email-templates/email-templates.vala | 2 +-
src/client/plugin/folder-highlight/folder-highlight.vala | 2 +-
src/client/plugin/messaging-menu/messaging-menu.vala | 2 +-
.../plugin/notification-badge/notification-badge.vala | 2 +-
src/client/plugin/plugin-plugin-base.vala | 9 ++++++---
src/client/plugin/special-folders/special-folders.vala | 2 +-
8 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
index d2bad7094..f7e40b2a2 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -33,8 +33,8 @@ public class Application.PluginManager : GLib.Object {
this.plugin = plugin;
}
- public async void activate() throws GLib.Error {
- yield this.plugin.activate();
+ public async void activate(bool is_startup) throws GLib.Error {
+ yield this.plugin.activate(is_startup);
}
public async void deactivate(bool is_shutdown) throws GLib.Error {
@@ -275,6 +275,7 @@ public class Application.PluginManager : GLib.Object {
private Controller controller;
private Configuration config;
private Peas.Engine plugins;
+ private bool is_startup = true;
private bool is_shutdown = false;
private string trusted_path;
@@ -328,6 +329,8 @@ public class Application.PluginManager : GLib.Object {
}
}
+ this.is_startup = false;
+
this.application.window_added.connect(on_window_added);
foreach (MainWindow main in this.application.get_main_windows()) {
this.folders_factory.main_window_added(main);
@@ -499,9 +502,10 @@ public class Application.PluginManager : GLib.Object {
if (do_activate) {
var plugin_context = new PluginContext(info, plugin);
- plugin_context.activate.begin((obj, res) => {
- on_plugin_activated(plugin_context, res);
- });
+ plugin_context.activate.begin(
+ this.is_startup,
+ (obj, res) => { on_plugin_activated(plugin_context, res); }
+ );
}
} else {
warning(
diff --git a/src/client/plugin/desktop-notifications/desktop-notifications.vala
b/src/client/plugin/desktop-notifications/desktop-notifications.vala
index 353c0abee..8d494f3be 100644
--- a/src/client/plugin/desktop-notifications/desktop-notifications.vala
+++ b/src/client/plugin/desktop-notifications/desktop-notifications.vala
@@ -57,7 +57,7 @@ public class Plugin.DesktopNotifications :
private GLib.Cancellable? cancellable = null;
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
this.cancellable = new GLib.Cancellable();
this.email_store = yield this.email.get_email_store();
diff --git a/src/client/plugin/email-templates/email-templates.vala
b/src/client/plugin/email-templates/email-templates.vala
index f007ad8fe..5074fa3dc 100644
--- a/src/client/plugin/email-templates/email-templates.vala
+++ b/src/client/plugin/email-templates/email-templates.vala
@@ -65,7 +65,7 @@ public class Plugin.EmailTemplates :
private GLib.Cancellable cancellable = new GLib.Cancellable();
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
// Add localised first, so if we need to create a folder it
// will be created localised.
Geary.iterate_array(LOC_NAMES.split("|")).map<string>(
diff --git a/src/client/plugin/folder-highlight/folder-highlight.vala
b/src/client/plugin/folder-highlight/folder-highlight.vala
index ff4796adc..5eb3ae667 100644
--- a/src/client/plugin/folder-highlight/folder-highlight.vala
+++ b/src/client/plugin/folder-highlight/folder-highlight.vala
@@ -43,7 +43,7 @@ public class Plugin.FolderHighlight :
get; construct set;
}
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
this.notifications.new_messages_arrived.connect(on_new_messages_arrived);
this.notifications.new_messages_retired.connect(on_new_messages_retired);
diff --git a/src/client/plugin/messaging-menu/messaging-menu.vala
b/src/client/plugin/messaging-menu/messaging-menu.vala
index 46ed8eecf..057347fb2 100644
--- a/src/client/plugin/messaging-menu/messaging-menu.vala
+++ b/src/client/plugin/messaging-menu/messaging-menu.vala
@@ -33,7 +33,7 @@ public class Plugin.MessagingMenu :
private FolderStore? folder_store = null;
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
this.app = new global::MessagingMenu.App(
"%s.desktop".printf(global::Application.Client.APP_ID)
);
diff --git a/src/client/plugin/notification-badge/notification-badge.vala
b/src/client/plugin/notification-badge/notification-badge.vala
index 2230fa486..9a3e3e08f 100644
--- a/src/client/plugin/notification-badge/notification-badge.vala
+++ b/src/client/plugin/notification-badge/notification-badge.vala
@@ -43,7 +43,7 @@ public class Plugin.NotificationBadge :
private UnityLauncherEntry? entry = null;
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
var connection = this.client_application.get_dbus_connection();
var path = this.client_application.get_dbus_object_path();
if (connection == null || path == null) {
diff --git a/src/client/plugin/plugin-plugin-base.vala b/src/client/plugin/plugin-plugin-base.vala
index 0be37b0e1..f0119b3d4 100644
--- a/src/client/plugin/plugin-plugin-base.vala
+++ b/src/client/plugin/plugin-plugin-base.vala
@@ -30,10 +30,13 @@ public abstract class Plugin.PluginBase : Geary.BaseObject {
/**
* Invoked to activate the plugin, after loading.
*
- * If this method raises an error, it will be unloaded without
- * deactivating.
+ * If `is_startup` is true, the plugin is being automatically
+ * loaded as the application is starting up. Otherwise, the plugin
+ * is being loaded after being enabled in the application
+ * preferences. If this method raises an error, it will be
+ * unloaded without deactivating.
*/
- public abstract async void activate() throws GLib.Error;
+ public abstract async void activate(bool is_startup) throws GLib.Error;
/**
* Invoked to deactivate the plugin, prior to unloading.
diff --git a/src/client/plugin/special-folders/special-folders.vala
b/src/client/plugin/special-folders/special-folders.vala
index aa9e120d6..09fc82afa 100644
--- a/src/client/plugin/special-folders/special-folders.vala
+++ b/src/client/plugin/special-folders/special-folders.vala
@@ -49,7 +49,7 @@ public class Plugin.SpecialFolders :
private GLib.Cancellable cancellable = new GLib.Cancellable();
- public override async void activate() throws GLib.Error {
+ public override async void activate(bool is_startup) throws GLib.Error {
this.email_store = yield this.email.get_email_store();
this.email_store.email_displayed.connect(on_email_displayed);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]