[polari] app: Split out undo-remove-connection action
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] app: Split out undo-remove-connection action
- Date: Sat, 19 Mar 2022 15:19:36 +0000 (UTC)
commit d7605ed29ba3b3fbdccd919e9e802f38b5f45389
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 16 17:35:15 2022 +0100
app: Split out undo-remove-connection action
libadwaita includes support for in-app notifications. It is action-based
like GNotifications, so in preparation to adopting it, delegate the undo
action to an action.
Part-of: <https://gitlab.gnome.org/GNOME/polari/-/merge_requests/250>
src/application.js | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index b4941adb..db2ee31a 100644
--- a/src/application.js
+++ b/src/application.js
@@ -58,6 +58,8 @@ class Application extends Adw.Application {
if (GLib.log_writer_is_journald(2))
GLib.setenv('G_MESSAGES_DEBUG', logDomain, false);
+ this._removedAccounts = new Set();
+
this._retryData = new Map();
this._nickTrackData = new Map();
this._demons = [];
@@ -270,6 +272,10 @@ class Application extends Adw.Application {
name: 'remove-connection',
activate: this._onRemoveConnection.bind(this),
parameter_type: GLib.VariantType.new('o'),
+ }, {
+ name: 'undo-remove-connection',
+ activate: this._onUndoRemoveConnection.bind(this),
+ parameter_type: GLib.VariantType.new('o'),
}, {
name: 'edit-connection',
activate: this._onEditConnection.bind(this),
@@ -760,6 +766,7 @@ class Application extends Adw.Application {
let account = this._accountsMonitor.lookupAccount(accountPath);
await account.set_enabled_async(false);
+ this._removedAccounts.add(account);
account.visible = false;
const label = vprintf(_('%s removed.'), account.display_name);
@@ -767,15 +774,25 @@ class Application extends Adw.Application {
this?.active_window.queueNotification(n);
n.connect('closed', async () => {
+ if (!this._removedAccounts.delete(account))
+ return;
+
await account.remove_async(); // TODO: Check for errors
Utils.clearAccountPassword(account);
Utils.clearIdentifyPassword(account);
});
- n.connect('undo', async () => {
- await account.set_enabled_async(true);
- account.visible = true;
- });
+ n.connect('undo',
+ () => this.activate_action('undo-remove-connection', parameter));
+ }
+
+ async _onUndoRemoveConnection(action, parameter) {
+ const accountPath = parameter.deep_unpack();
+ const account = this._accountsMonitor.lookupAccount(accountPath);
+
+ this._removedAccounts.delete(account);
+ await account.set_enabled_async(true);
+ account.visible = true;
}
_onEditConnection(action, parameter) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]