Plugin: Add new Composer object and Application.new_composer method
This allows plugins to create and show new composers for a specific account.
This commit is contained in:
parent
1dfd5a1855
commit
5f2d40bed9
5 changed files with 68 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
24
src/client/plugin/plugin-composer.vala
Normal file
24
src/client/plugin/plugin-composer.vala
Normal file
|
|
@ -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();
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue