From 0c705aefc13595b56146f3bcc494fd7edfa60618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 29 Jan 2024 13:39:57 +0100 Subject: [PATCH] extensions-app: Use new adaptive dialogs We already fulfill all prerequisites of the new adaptive dialogs, so the port is straight-forward and painless. Part-of: --- subprojects/extensions-app/js/extensionRow.js | 2 +- .../extensions-app/js/extensionsWindow.js | 35 ++++++++----------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/subprojects/extensions-app/js/extensionRow.js b/subprojects/extensions-app/js/extensionRow.js index dac3b7f01..85be76e3c 100644 --- a/subprojects/extensions-app/js/extensionRow.js +++ b/subprojects/extensions-app/js/extensionRow.js @@ -50,7 +50,7 @@ export const ExtensionRow = GObject.registerClass({ name: 'uninstall', activate: () => { this._detailsPopover.popdown(); - this.get_root().uninstall(extension); + this.get_root().uninstall(extension).catch(logError); }, enabledProp: 'is-user', }, diff --git a/subprojects/extensions-app/js/extensionsWindow.js b/subprojects/extensions-app/js/extensionsWindow.js index 4d9cf17c9..25b9910ad 100644 --- a/subprojects/extensions-app/js/extensionsWindow.js +++ b/subprojects/extensions-app/js/extensionsWindow.js @@ -11,6 +11,7 @@ import * as Gettext from 'gettext'; import * as Config from './misc/config.js'; import {ExtensionRow} from './extensionRow.js'; +Gio._promisify(Adw.AlertDialog.prototype, 'choose'); Gio._promisify(Gio.DBusConnection.prototype, 'call'); Gio._promisify(Shew.WindowExporter.prototype, 'export'); @@ -108,26 +109,22 @@ export const ExtensionsWindow = GObject.registerClass({ () => this._extensionsLoaded()); } - uninstall(extension) { - const dialog = new Gtk.MessageDialog({ - transient_for: this, - modal: true, - text: _('Remove “%s”?').format(extension.name), - secondary_text: _('If you remove the extension, you need to return to download it if you want to enable it again'), + async uninstall(extension) { + const dialog = new Adw.AlertDialog({ + heading: _('Remove “%s”?').format(extension.name), + body: _('If you remove the extension, you need to return to download it if you want to enable it again'), }); - dialog.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL); - dialog.add_button(_('_Remove'), Gtk.ResponseType.ACCEPT) - .get_style_context().add_class('destructive-action'); + dialog.add_response('cancel', _('_Cancel')); + dialog.add_response('remove', _('_Remove')); - dialog.connect('response', (dlg, response) => { - const {extensionManager} = this.application; + dialog.set_response_appearance('remove', + Adw.ResponseAppearance.DESTRUCTIVE); - if (response === Gtk.ResponseType.ACCEPT) - extensionManager.uninstallExtension(extension.uuid); - dialog.destroy(); - }); - dialog.present(); + const {extensionManager} = this.application; + const response = await dialog.choose(this, null); + if (response === 'remove') + extensionManager.uninstallExtension(extension.uuid); } async openPrefs(extension) { @@ -144,7 +141,7 @@ export const ExtensionsWindow = GObject.registerClass({ } _showAbout() { - const aboutWindow = new Adw.AboutWindow({ + const aboutDialog = new Adw.AboutDialog({ developers: [ 'Florian Müllner ', 'Jasper St. Pierre ', @@ -163,10 +160,8 @@ export const ExtensionsWindow = GObject.registerClass({ developer_name: _('The GNOME Project'), website: 'https://apps.gnome.org/app/org.gnome.Extensions/', issue_url: 'https://gitlab.gnome.org/GNOME/gnome-shell/issues/new', - - transient_for: this, }); - aboutWindow.present(); + aboutDialog.present(this); } _logout() {