[geary/gnumdk/mail-merge-action-enabled: 1/2] plugin: Only enable mail merge action for templates




commit 1c769ddebaa242051834b0910ea445686f0337cb
Author: Cédric Bellegarde <cedric bellegarde adishatz org>
Date:   Sat Aug 27 14:53:09 2022 +0200

    plugin: Only enable mail merge action for templates
    
    Fix #1410

 src/client/application/application-plugin-manager.vala | 11 +++++++----
 src/client/plugin/mail-merge/mail-merge.vala           |  6 ++++++
 2 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/client/application/application-plugin-manager.vala 
b/src/client/application/application-plugin-manager.vala
index 1d736222e..794e16919 100644
--- a/src/client/application/application-plugin-manager.vala
+++ b/src/client/application/application-plugin-manager.vala
@@ -349,10 +349,7 @@ public class Application.PluginManager : GLib.Object {
     internal class ComposerImpl : Geary.BaseObject, Plugin.Composer {
 
 
-        public bool can_send {
-            get { return this.backing.can_send; }
-            set { this.backing.can_send = value; }
-        }
+        public bool can_send { get; set; default = false; }
 
         public Plugin.Account? sender_context {
             get {
@@ -397,6 +394,12 @@ public class Application.PluginManager : GLib.Object {
             this.backing = backing;
             this.application = application;
             this._action_group_name = application.plugin.action_group_name + "-cmp";
+            backing.bind_property(
+                "can-send",
+                this,
+                "can-send",
+                BindingFlags.SYNC_CREATE |
+                BindingFlags.BIDIRECTIONAL);
         }
 
         public void save_to_folder(Plugin.Folder? location) {
diff --git a/src/client/plugin/mail-merge/mail-merge.vala b/src/client/plugin/mail-merge/mail-merge.vala
index 1fa7c7c1d..91d4b8800 100644
--- a/src/client/plugin/mail-merge/mail-merge.vala
+++ b/src/client/plugin/mail-merge/mail-merge.vala
@@ -287,6 +287,12 @@ public class Plugin.MailMerge :
                 /// merge in composer
                 new Actionable(_("Mail Merge"), load_action)
             );
+            composer.bind_property(
+                "can-send",
+                load_action,
+                "enabled",
+                BindingFlags.SYNC_CREATE |
+                BindingFlags.INVERT_BOOLEAN);
         }
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]