[geary/mjog/email-templates: 49/72] Plugin: Add new Composer object and Application.new_composer method
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-templates: 49/72] Plugin: Add new Composer object and Application.new_composer method
- Date: Mon, 20 Apr 2020 13:54:17 +0000 (UTC)
commit 5f2d40bed97e6dab078a2caf77184adcf0ee68d8
Author: Michael Gratton <mike vee net>
Date: Mon Apr 6 18:41:26 2020 +1000
Plugin: Add new Composer object and Application.new_composer method
This allows plugins to create and show new composers for a specific
account.
po/POTFILES.in | 1 +
.../application/application-plugin-manager.vala | 33 ++++++++++++++++++++++
src/client/meson.build | 1 +
src/client/plugin/plugin-application.vala | 9 ++++++
src/client/plugin/plugin-composer.vala | 24 ++++++++++++++++
5 files changed, 68 insertions(+)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index fafe20ba..25a51cc5 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -94,6 +94,7 @@ src/client/folder-list/folder-list-tree.vala
src/client/plugin/plugin-account.vala
src/client/plugin/plugin-application.vala
src/client/plugin/plugin-button.vala
+src/client/plugin/plugin-composer.vala
src/client/plugin/plugin-contact-store.vala
src/client/plugin/plugin-email-extension.vala
src/client/plugin/plugin-email-store.vala
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
index beae448e..b52473fc 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -64,6 +64,15 @@ public class Application.PluginManager : GLib.Object {
this.action_group_name = plugin.get_module_name().replace(".", "_");
}
+ public Plugin.Composer new_composer(Plugin.Account source)
+ throws Plugin.Error {
+ AccountContext? account = this.folders.get_account_context(source);
+ if (account == null) {
+ throw new Plugin.Error.NOT_SUPPORTED("No such account");
+ }
+ return new ComposerImpl(this.backing, account);
+ }
+
public void register_action(GLib.Action action) {
if (this.action_group == null) {
this.action_group = new GLib.SimpleActionGroup();
@@ -141,6 +150,30 @@ public class Application.PluginManager : GLib.Object {
}
+ private class ComposerImpl : Geary.BaseObject, Plugin.Composer {
+
+
+ private Client application;
+ private AccountContext account;
+
+
+ public ComposerImpl(Client application, AccountContext account) {
+ this.application = application;
+ this.account = account;
+ }
+
+ public void show() {
+ var composer = new Composer.Widget(
+ this.application, this.account.account, NEW_MESSAGE
+ );
+ var main_window = this.application.get_active_main_window();
+ main_window.show_composer(composer, null);
+ composer.load.begin(null, false, null, null);
+ }
+
+ }
+
+
/** Emitted when a plugin is successfully loaded and activated. */
public signal void plugin_activated(Peas.PluginInfo info);
diff --git a/src/client/meson.build b/src/client/meson.build
index 7fcb3a43..20eb6fc7 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -113,6 +113,7 @@ geary_client_vala_sources = files(
'plugin/plugin-account.vala',
'plugin/plugin-application.vala',
'plugin/plugin-button.vala',
+ 'plugin/plugin-composer.vala',
'plugin/plugin-contact-store.vala',
'plugin/plugin-email-extension.vala',
'plugin/plugin-email-store.vala',
diff --git a/src/client/plugin/plugin-application.vala b/src/client/plugin/plugin-application.vala
index af49e5eb..19bb837c 100644
--- a/src/client/plugin/plugin-application.vala
+++ b/src/client/plugin/plugin-application.vala
@@ -14,6 +14,15 @@
public interface Plugin.Application : Geary.BaseObject {
+ /**
+ * Constructs a new, blank composer for the given account.
+ *
+ * The composer will be initialised to send an email from the
+ * given account. This may be changed by people before they send
+ * the email, however.
+ */
+ public abstract Composer new_composer(Account source) throws Error;
+
/**
* Registers a plugin action with the application.
*
diff --git a/src/client/plugin/plugin-composer.vala b/src/client/plugin/plugin-composer.vala
new file mode 100644
index 00000000..b399530c
--- /dev/null
+++ b/src/client/plugin/plugin-composer.vala
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2020 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.
+ */
+
+/**
+ * An object representing a composer for use by plugins.
+ */
+public interface Plugin.Composer : Geary.BaseObject {
+
+ /**
+ * Causes the composer to be made visible.
+ *
+ * The composer will be shown as either full-pane and in-window if
+ * not a reply to a currently displayed conversation, inline and
+ * in-window if a reply to an existing conversation being
+ * displayed, or detached if there is already an in-window
+ * composer being displayed.
+ */
+ public abstract void show();
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]