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.
This commit is contained in:
parent
2acd7d659a
commit
5f3a162e2e
1 changed files with 34 additions and 0 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue