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
This commit is contained in:
parent
c6f297e4e5
commit
db69ad876a
@ -12,7 +12,7 @@ const Config = imports.misc.config;
|
|||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const { loadInterfaceXML } = imports.misc.fileUtils;
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
||||||
|
|
||||||
const { ExtensionState } = ExtensionUtils;
|
const { ExtensionState, ExtensionType } = ExtensionUtils;
|
||||||
|
|
||||||
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
||||||
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface);
|
||||||
@ -119,6 +119,28 @@ var ExtensionsWindow = GObject.registerClass({
|
|||||||
return this.application.shellProxy;
|
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) {
|
openPrefs(uuid) {
|
||||||
if (!this._loaded)
|
if (!this._loaded)
|
||||||
this._startupUuid = uuid;
|
this._startupUuid = uuid;
|
||||||
@ -517,6 +539,13 @@ var ExtensionRow = GObject.registerClass({
|
|||||||
});
|
});
|
||||||
this._actionGroup.add_action(action);
|
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({
|
action = new Gio.SimpleAction({
|
||||||
name: 'enabled',
|
name: 'enabled',
|
||||||
state: new GLib.Variant('b', false),
|
state: new GLib.Variant('b', false),
|
||||||
@ -574,6 +603,10 @@ var ExtensionRow = GObject.registerClass({
|
|||||||
return this._extension.hasPrefs;
|
return this._extension.hasPrefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get type() {
|
||||||
|
return this._extension.type;
|
||||||
|
}
|
||||||
|
|
||||||
get creator() {
|
get creator() {
|
||||||
return this._extension.metadata.creator || '';
|
return this._extension.metadata.creator || '';
|
||||||
}
|
}
|
||||||
|
@ -169,6 +169,27 @@
|
|||||||
<property name="top_attach">3</property>
|
<property name="top_attach">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</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>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user