extensionSystem: Add "UninstallExtension" DBus method
For those who like their system pure, this provides the ability to purge a pesky extension and its precious place on your disk space, and in your "Local Extension" list. https://bugzilla.gnome.org/show_bug.cgi?id=658612 Conflicts: js/ui/extensionSystem.js
This commit is contained in:
parent
d5e6ea6ebd
commit
7928f90cf6
@ -20,3 +20,25 @@ function listDirAsync(file, callback) {
|
|||||||
enumerator.next_files_async(100, GLib.PRIORITY_LOW, null, onNextFileComplete);
|
enumerator.next_files_async(100, GLib.PRIORITY_LOW, null, onNextFileComplete);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deleteGFile(file) {
|
||||||
|
// Work around 'delete' being a keyword in JS.
|
||||||
|
return file['delete'](null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function recursivelyDeleteDir(dir) {
|
||||||
|
let children = dir.enumerate_children('standard::name,standard::type',
|
||||||
|
Gio.FileQueryInfoFlags.NONE, null);
|
||||||
|
|
||||||
|
let info, child;
|
||||||
|
while ((info = children.next_file(null)) != null) {
|
||||||
|
let type = info.get_file_type();
|
||||||
|
let child = dir.get_child(info.get_name());
|
||||||
|
if (type == Gio.FileType.REGULAR)
|
||||||
|
deleteGFile(child);
|
||||||
|
else if (type == Gio.TypeType.DIRECTORY)
|
||||||
|
recursivelyDeleteDir(child);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteGFile(dir);
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ const Shell = imports.gi.Shell;
|
|||||||
const Soup = imports.gi.Soup;
|
const Soup = imports.gi.Soup;
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
const Config = imports.misc.config;
|
||||||
|
const FileUtils = imports.misc.fileUtils;
|
||||||
|
|
||||||
const API_VERSION = 1;
|
const API_VERSION = 1;
|
||||||
|
|
||||||
@ -120,6 +121,37 @@ function installExtensionFromUUID(uuid, version_tag) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uninstallExtensionFromUUID(uuid) {
|
||||||
|
let meta = extensionMeta[uuid];
|
||||||
|
if (!meta)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Try to disable it -- if it's ERROR'd, we can't guarantee that,
|
||||||
|
// but it will be removed on next reboot, and hopefully nothing
|
||||||
|
// broke too much.
|
||||||
|
disableExtension(uuid);
|
||||||
|
|
||||||
|
// Don't try to uninstall system extensions
|
||||||
|
if (meta.type != ExtensionType.PER_USER)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
meta.state = ExtensionState.UNINSTALLED;
|
||||||
|
_signals.emit('extension-state-changed', meta);
|
||||||
|
|
||||||
|
delete extensionMeta[uuid];
|
||||||
|
|
||||||
|
// Importers are marked as PERMANENT, so we can't do this.
|
||||||
|
// delete extensions[uuid];
|
||||||
|
extensions[uuid] = undefined;
|
||||||
|
|
||||||
|
delete extensionStateObjs[uuid];
|
||||||
|
delete errors[uuid];
|
||||||
|
|
||||||
|
FileUtils.recursivelyDeleteDir(Gio.file_new_for_path(meta.path));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
function gotExtensionZipFile(session, message, uuid) {
|
function gotExtensionZipFile(session, message, uuid) {
|
||||||
if (message.status_code != Soup.KnownStatusCode.OK) {
|
if (message.status_code != Soup.KnownStatusCode.OK) {
|
||||||
logExtensionError(uuid, 'downloading extension: ' + message.status_code);
|
logExtensionError(uuid, 'downloading extension: ' + message.status_code);
|
||||||
|
@ -48,6 +48,10 @@ const GnomeShellIface = {
|
|||||||
{ name: 'InstallRemoteExtension',
|
{ name: 'InstallRemoteExtension',
|
||||||
inSignature: 'ss',
|
inSignature: 'ss',
|
||||||
outSignature: ''
|
outSignature: ''
|
||||||
|
},
|
||||||
|
{ name: 'UninstallExtension',
|
||||||
|
inSignature: 's',
|
||||||
|
outSignature: 'b'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
signals: [{ name: 'ExtensionStatusChanged',
|
signals: [{ name: 'ExtensionStatusChanged',
|
||||||
@ -178,6 +182,10 @@ GnomeShell.prototype = {
|
|||||||
ExtensionSystem.installExtensionFromUUID(uuid, version_tag);
|
ExtensionSystem.installExtensionFromUUID(uuid, version_tag);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
UninstallExtension: function(uuid) {
|
||||||
|
return ExtensionSystem.uninstallExtensionFromUUID(uuid);
|
||||||
|
},
|
||||||
|
|
||||||
get OverviewActive() {
|
get OverviewActive() {
|
||||||
return Main.overview.visible;
|
return Main.overview.visible;
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user