shellDBus: Add a DBus method to load a single extension

This allows e.g. gnome-tweak-tool to install an extension from a zip
file and load it into the running shell.
This commit is contained in:
Rui Matos 2013-11-08 11:36:04 +01:00 committed by Ray Strode
parent b474ea0b7c
commit 7d9a39c72c

View File

@ -322,6 +322,10 @@ const GnomeShellExtensionsIface = '<node> \
</method> \
<method name="CheckForUpdates"> \
</method> \
<method name="LoadUserExtension"> \
<arg type="s" direction="in" name="uuid"/> \
<arg type="b" direction="out" name="success"/> \
</method> \
<property name="ShellVersion" type="s" access="read" /> \
</interface> \
</node>';
@ -424,6 +428,22 @@ var GnomeShellExtensions = new Lang.Class({
ExtensionDownloader.checkForUpdates();
},
LoadUserExtension(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (extension)
return true;
let dir = Gio.File.new_for_path(GLib.build_filenamev([global.userdatadir, 'extensions', uuid]));
try {
extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
ExtensionSystem.loadExtension(extension);
} catch (e) {
log('Could not load user extension from %s'.format(dir.get_path()));
return false;
}
return true;
},
ShellVersion: Config.PACKAGE_VERSION,
_extensionStateChanged(_, newState) {