messageTray: Add removeAction() method and allow references to actions
Internally in gnome-shell it may be useful to modify the actions available on a notification while it’s still visible, but without clearing them all and re-creating them. Allow that by returning the action object when adding it, and adding a `removeAction()` method which takes that object and removes it. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3251>
This commit is contained in:
parent
e9ca27c663
commit
03e3d9f435
@ -439,6 +439,16 @@ export class Notification extends GObject.Object {
|
|||||||
});
|
});
|
||||||
this._actions.push(action);
|
this._actions.push(action);
|
||||||
this.emit('action-added', action);
|
this.emit('action-added', action);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeAction(action) {
|
||||||
|
const index = this._actions.indexOf(action);
|
||||||
|
if (index < 0)
|
||||||
|
throw new Error('Action was already removed previously');
|
||||||
|
|
||||||
|
this._actions.splice(index, 1);
|
||||||
|
this.emit('action-removed', action);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearActions() {
|
clearActions() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user