[geary/mjog/account-command-stacks: 53/77] Add status signals to Application.Command



commit 5f3a162e2e93df40c5b90b1ee0d77e5b58454c50
Author: Michael Gratton <mike vee net>
Date:   Wed Oct 23 11:55:14 2019 +1100

    Add status signals to Application.Command
    
    Add executed, undone and redone signals to commands so that the code
    that executed them can be informed of their individial statuses.

 src/client/application/application-command.vala | 34 +++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/src/client/application/application-command.vala b/src/client/application/application-command.vala
index a28a7cc1..5a781a21 100644
--- a/src/client/application/application-command.vala
+++ b/src/client/application/application-command.vala
@@ -67,6 +67,37 @@ public abstract class Application.Command : GLib.Object {
     public string? undone_label { get; protected set; default = null; }
 
 
+    /**
+     * Emitted when the command was successfully executed.
+     *
+     * Command implementations must not manage this signal, it will be
+     * emitted by {@link CommandStack} as needed.
+     */
+    public virtual signal void executed() {
+        // no-op
+    }
+
+    /**
+     * Emitted when the command was successfully undone.
+     *
+     * Command implementations must not manage this signal, it will be
+     * emitted by {@link CommandStack} as needed.
+     */
+    public virtual signal void undone() {
+        // no-op
+    }
+
+    /**
+     * Emitted when the command was successfully redone.
+     *
+     * Command implementations must not manage this signal, it will be
+     * emitted by {@link CommandStack} as needed.
+     */
+    public virtual signal void redone() {
+        // no-op
+    }
+
+
     /**
      * Called by {@link CommandStack} to execute the command.
      *
@@ -303,6 +334,7 @@ public class Application.CommandStack : GLib.Object {
         this.can_redo = false;
 
         executed(target);
+        target.executed();
     }
 
     /**
@@ -335,6 +367,7 @@ public class Application.CommandStack : GLib.Object {
             this.can_redo = true;
 
             undone(target);
+            target.undone();
         }
     }
 
@@ -368,6 +401,7 @@ public class Application.CommandStack : GLib.Object {
             this.can_undo = !this.undo_stack.is_empty;
 
             redone(target);
+            target.redone();
         }
     }
 


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