[gnome-shell] extensionPrefs: Support uninstalling user extensions



commit db69ad876a22192645ba29f8184516ba097d72fa
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Nov 30 06:06:08 2019 +0100

    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 e2babfe62f..bb1e46eaf3 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 0ec50802ea..c4f4e60507 100644
--- a/js/extensionPrefs/ui/extension-row.ui
+++ b/js/extensionPrefs/ui/extension-row.ui
@@ -169,6 +169,27 @@
                     <property name="top_attach">3</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkButton" id="removeButton">
+                    <property name="visible"
+                              bind-source="removeButton"
+                              bind-property="sensitive"
+                              bind-flags="sync-create"/>
+                    <property name="no_show_all">True</property>
+                    <property name="label" translatable="yes">Remove…</property>
+                    <property name="action_name">row.uninstall</property>
+                    <property name="hexpand">True</property>
+                    <property name="halign">end</property>
+                    <property name="valign">end</property>
+                    <style>
+                      <class name="destructive-action"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">3</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]