[gnome-shell] lookingGlass: Recognize new extensions as they are added



commit ff983432d92f84665bbc53453906be5ef1f8c039
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sat Jun 11 00:21:35 2011 -0400

    lookingGlass: Recognize new extensions as they are added
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654770

 js/ui/extensionSystem.js |   14 ++++++++++++++
 js/ui/lookingGlass.js    |   35 ++++++++++++++++++++++-------------
 2 files changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index f722007..0d7b199 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -1,5 +1,8 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
+const Lang = imports.lang;
+const Signals = imports.signals;
+
 const GLib = imports.gi.GLib;
 const Gio = imports.gi.Gio;
 const St = imports.gi.St;
@@ -29,6 +32,15 @@ var enabledExtensions;
 // GFile for user extensions
 var userExtensionsDir = null;
 
+// We don't really have a class to add signals on. So, create
+// a simple dummy object, add the signal methods, and export those
+// publically.
+var _signals = {};
+Signals.addSignalMethods(_signals);
+
+const connect = Lang.bind(_signals, _signals.connect);
+const disconnect = Lang.bind(_signals, _signals.disconnect);
+
 /**
  * versionCheck:
  * @required: an array of versions we're compatible with
@@ -166,6 +178,8 @@ function loadExtension(dir, enabled, type) {
         return;
     }
     extensionMeta[meta.uuid].state = ExtensionState.ENABLED;
+
+    _signals.emit('extension-loaded', meta.uuid);
     global.log('Loaded extension ' + meta.uuid);
 }
 
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index 65ca7ad..bafcb37 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -638,23 +638,32 @@ Extensions.prototype = {
                                         name: 'lookingGlassExtensions' });
         this._noExtensions = new St.Label({ style_class: 'lg-extensions-none',
                                              text: _("No extensions installed") });
+        this._numExtensions = 0;
         this._extensionsList = new St.BoxLayout({ vertical: true,
                                                   style_class: 'lg-extensions-list' });
+        this._extensionsList.add(this._noExtensions);
         this.actor.add(this._extensionsList);
-        this._loadExtensionList();
+
+        for (let uuid in ExtensionSystem.extensionMeta)
+            this._loadExtension(null, uuid);
+
+        ExtensionSystem.connect('extension-loaded',
+                                Lang.bind(this, this._loadExtension));
     },
 
-    _loadExtensionList: function() {
-        let extensions = ExtensionSystem.extensionMeta;
-        let totalExtensions = 0;
-        for (let uuid in extensions) {
-            let extensionDisplay = this._createExtensionDisplay(extensions[uuid]);
-            this._extensionsList.add(extensionDisplay);
-            totalExtensions++;
-        }
-        if (totalExtensions == 0) {
-            this._extensionsList.add(this._noExtensions);
-        }
+    _loadExtension: function(o, uuid) {
+        let extension = ExtensionSystem.extensionMeta[uuid];
+        // There can be cases where we create dummy extension metadata
+        // that's not really a proper extension. Don't bother with these.
+        if (!extension.name)
+            return;
+
+        let extensionDisplay = this._createExtensionDisplay(extension);
+        if (this._numExtensions == 0)
+            this._extensionsList.remove_actor(this._noExtensions);
+
+        this._numExtensions ++;
+        this._extensionsList.add(extensionDisplay);
     },
 
     _onViewSource: function (actor) {
@@ -691,7 +700,7 @@ Extensions.prototype = {
                                    text: meta.name });
         box.add(name, { expand: true });
         let description = new St.Label({ style_class: 'lg-extension-description',
-                                         text: meta.description });
+                                         text: meta.description || 'No description' });
         box.add(description, { expand: true });
 
         let metaBox = new St.BoxLayout();



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