Blob Blame History Raw
From 193ac75919f663122fd3a9ef3bd5342fffe79dde Mon Sep 17 00:00:00 2001
From: Rui Matos <tiagomatos@gmail.com>
Date: Fri, 8 Nov 2013 11:36:04 +0100
Subject: [PATCH 1/2] 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.
---
 js/ui/shellDBus.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 84597fd..d3a3a05 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -266,6 +266,10 @@ const GnomeShellExtensionsIface = <interface name="org.gnome.Shell.Extensions">
 </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>;
 
@@ -365,6 +369,22 @@ const GnomeShellExtensions = new Lang.Class({
         ExtensionDownloader.checkForUpdates();
     },
 
+    LoadUserExtension: function(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: function(_, newState) {
-- 
1.8.3.1