[gnome-shell] extensionSystem: Add a method to unload an extension



commit 75570b799511bc8e9c8a8f6f76f52afac3b62b44
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jun 5 13:03:42 2012 -0400

    extensionSystem: Add a method to unload an extension
    
    https://bugzilla.gnome.org/show_bug.cgi?id=677586

 js/ui/extensionDownloader.js |   14 +++-----------
 js/ui/extensionSystem.js     |   17 +++++++++++++++++
 2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index eda3872..c19559a 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -41,22 +41,14 @@ function uninstallExtensionFromUUID(uuid) {
     if (!extension)
         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.
-    ExtensionSystem.disableExtension(uuid);
-
     // Don't try to uninstall system extensions
     if (extension.type != ExtensionUtils.ExtensionType.PER_USER)
         return false;
 
-    extension.state = ExtensionSystem.ExtensionState.UNINSTALLED;
-    _signals.emit('extension-state-changed', extension);
-
-    delete ExtensionUtils.extensions[uuid];
-
-    FileUtils.recursivelyDeleteDir(Gio.file_new_for_path(extension.path));
+    if (!ExtensionSystem.unloadExtension(uuid))
+        return false;
 
+    FileUtils.recursivelyDeleteDir(extension.dir);
     return true;
 }
 
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index c33162d..abd219e 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -167,6 +167,23 @@ function loadExtension(extension) {
     _signals.emit('extension-state-changed', extension);
 }
 
+function unloadExtension(uuid) {
+    let extension = ExtensionUtils.extensions[uuid];
+    if (!extension)
+        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);
+
+    extension.state = ExtensionState.UNINSTALLED;
+    _signals.emit('extension-state-changed', extension);
+
+    delete ExtensionUtils.extensions[uuid];
+    return true;
+}
+
 function initExtension(uuid) {
     let extension = ExtensionUtils.extensions[uuid];
     let dir = extension.dir;



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