[geary/mjog/email-templates: 14/15] Plugin.Composer: Support disabling sending a composer
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/email-templates: 14/15] Plugin.Composer: Support disabling sending a composer
- Date: Tue, 21 Apr 2020 06:24:37 +0000 (UTC)
commit 216f0d870cd3d38945f8cbf7b85fe6e917b1814e
Author: Michael Gratton <mike vee net>
Date: Tue Apr 21 16:21:23 2020 +1000
Plugin.Composer: Support disabling sending a composer
Allow disabling send in the composer for editing templates.
.../application/application-plugin-manager.vala | 4 +++-
src/client/composer/composer-headerbar.vala | 7 +++++++
src/client/composer/composer-widget.vala | 19 +++++++++++++++++--
src/client/plugin/plugin-composer.vala | 5 +++++
4 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/client/application/application-plugin-manager.vala
b/src/client/application/application-plugin-manager.vala
index 4db5fa5b..7809861e 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -178,6 +178,8 @@ public class Application.PluginManager : GLib.Object {
private class ComposerImpl : Geary.BaseObject, Plugin.Composer {
+ public override bool can_send { get; set; default = true; }
+
private Client application;
private AccountContext account;
private FolderStoreFactory folders;
@@ -241,7 +243,7 @@ public class Application.PluginManager : GLib.Object {
this.save_location
);
}
- //composer.can_send = this.can_send;
+ composer.can_send = this.can_send;
}
}
diff --git a/src/client/composer/composer-headerbar.vala b/src/client/composer/composer-headerbar.vala
index 33cb3652..6fb21386 100644
--- a/src/client/composer/composer-headerbar.vala
+++ b/src/client/composer/composer-headerbar.vala
@@ -13,6 +13,11 @@ public class Composer.Headerbar : Gtk.HeaderBar {
set { this.save_and_close_button.visible = value; }
}
+ public bool show_send {
+ get { return this.send_button.visible; }
+ set { this.send_button.visible = value; }
+ }
+
private Application.Configuration config;
private bool is_attached = true;
@@ -28,6 +33,8 @@ public class Composer.Headerbar : Gtk.HeaderBar {
[GtkChild]
private Gtk.Button save_and_close_button;
+ [GtkChild]
+ private Gtk.Button send_button;
/** Fired when the user wants to expand a compact composer. */
public signal void expand_composer();
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index c340218b..a2186d7c 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -283,7 +283,19 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
}
}
- public WebView editor { get; private set; }
+ /** Determines if the composer can send the message. */
+ public bool can_send {
+ get {
+ return this._can_send;
+ }
+ set {
+ this._can_send = value;
+ validate_send_button();
+ }
+ }
+ private bool _can_send = true;
+
+ internal WebView editor { get; private set; }
internal Headerbar header { get; private set; }
@@ -1636,7 +1648,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
Geary.Folder? target = this.save_to;
if (target == null) {
- this.sender_context.account.get_required_special_folder_async(
+ target = yield this.sender_context.account.get_required_special_folder_async(
DRAFTS, internal_cancellable
);
}
@@ -2037,11 +2049,14 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
// To must be valid (and hence non-empty), the other email
// fields must be either empty or valid.
get_action(ACTION_SEND).set_enabled(
+ this.can_send &&
this.to_entry.is_valid &&
(this.cc_entry.is_empty || this.cc_entry.is_valid) &&
(this.bcc_entry.is_empty || this.bcc_entry.is_valid) &&
(this.reply_to_entry.is_empty || this.reply_to_entry.is_valid)
);
+
+ this.header.show_send = this.can_send;
}
private void set_compact_header_recipients() {
diff --git a/src/client/plugin/plugin-composer.vala b/src/client/plugin/plugin-composer.vala
index 9635f39b..146721dd 100644
--- a/src/client/plugin/plugin-composer.vala
+++ b/src/client/plugin/plugin-composer.vala
@@ -11,6 +11,11 @@
public interface Plugin.Composer : Geary.BaseObject {
+ /**
+ * Determines if the email in the composer can be sent.
+ */
+ public abstract bool can_send { get; set; }
+
/**
* Causes the composer to be made visible.
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]