From db69ad876a22192645ba29f8184516ba097d72fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 30 Nov 2019 06:06:08 +0100 Subject: [PATCH] extensionPrefs: Support uninstalling user extensions This is functionality currently provided by GNOME Software, and which the new Extensions app should (and easily can) provide. https://gitlab.gnome.org/GNOME/gnome-shell/issues/1968 --- js/extensionPrefs/main.js | 35 ++++++++++++++++++++++++++- js/extensionPrefs/ui/extension-row.ui | 21 ++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js index e2babfe62..bb1e46eaf 100644 --- a/js/extensionPrefs/main.js +++ b/js/extensionPrefs/main.js @@ -12,7 +12,7 @@ const Config = imports.misc.config; const ExtensionUtils = imports.misc.extensionUtils; const { loadInterfaceXML } = imports.misc.fileUtils; -const { ExtensionState } = ExtensionUtils; +const { ExtensionState, ExtensionType } = ExtensionUtils; const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions'); const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface); @@ -119,6 +119,28 @@ var ExtensionsWindow = GObject.registerClass({ return this.application.shellProxy; } + uninstall(uuid) { + let row = this._findExtensionRow(uuid); + + let dialog = new Gtk.MessageDialog({ + transient_for: this, + modal: true, + text: _('Remove “%s”?').format(row.name), + secondary_text: _('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.connect('response', (dlg, response) => { + if (response === Gtk.ResponseType.ACCEPT) + this._shellProxy.UninstallExtensionRemote(uuid); + dialog.destroy(); + }); + dialog.present(); + } + openPrefs(uuid) { if (!this._loaded) this._startupUuid = uuid; @@ -517,6 +539,13 @@ var ExtensionRow = GObject.registerClass({ }); this._actionGroup.add_action(action); + action = new Gio.SimpleAction({ + name: 'uninstall', + enabled: this.type === ExtensionType.PER_USER, + }); + action.connect('activate', () => this.get_toplevel().uninstall(this.uuid)); + this._actionGroup.add_action(action); + action = new Gio.SimpleAction({ name: 'enabled', state: new GLib.Variant('b', false), @@ -574,6 +603,10 @@ var ExtensionRow = GObject.registerClass({ return this._extension.hasPrefs; } + get type() { + return this._extension.type; + } + get creator() { return this._extension.metadata.creator || ''; } diff --git a/js/extensionPrefs/ui/extension-row.ui b/js/extensionPrefs/ui/extension-row.ui index 0ec50802e..c4f4e6050 100644 --- a/js/extensionPrefs/ui/extension-row.ui +++ b/js/extensionPrefs/ui/extension-row.ui @@ -169,6 +169,27 @@ 3 + + + + True + Remove… + row.uninstall + True + end + end + + + + 1 + 3 + +