[geary/mjog/sound-plugin-feedback: 3/3] Plugin.SentSound: Play a sound on when first activated




commit 492d66239e6fc9c4e0477be758804f677b694a08
Author: Michael Gratton <mike vee net>
Date:   Tue Jul 7 09:57:42 2020 +1000

    Plugin.SentSound: Play a sound on when first activated
    
    This provides feedback that the plugin is working, and displays an
    error if not.

 src/client/plugin/sent-sound/sent-sound.vala | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/client/plugin/sent-sound/sent-sound.vala b/src/client/plugin/sent-sound/sent-sound.vala
index db33964e2..34a05f5a2 100644
--- a/src/client/plugin/sent-sound/sent-sound.vala
+++ b/src/client/plugin/sent-sound/sent-sound.vala
@@ -27,12 +27,16 @@ public class Plugin.SentSound : PluginBase, EmailExtension {
     private EmailStore? store = null;
 
 
-    public override async void activate() throws GLib.Error {
+    public override async void activate(bool is_startup) throws GLib.Error {
         this.context = new GSound.Context();
         this.context.init();
 
         this.store = yield this.email.get_email_store();
         this.store.email_sent.connect(on_sent);
+
+        if (!is_startup) {
+            play_sound();
+        }
     }
 
     public override async void deactivate(bool is_shutdown) throws GLib.Error {
@@ -42,7 +46,7 @@ public class Plugin.SentSound : PluginBase, EmailExtension {
         this.context = null;
     }
 
-    private void on_sent() {
+    private void play_sound() {
         try {
             this.context.play_simple(
                 null, GSound.Attribute.EVENT_ID, "message-sent-email"
@@ -55,4 +59,8 @@ public class Plugin.SentSound : PluginBase, EmailExtension {
         }
     }
 
+    private void on_sent() {
+        play_sound();
+    }
+
 }


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