lookingGlass: Recognize new extensions as they are added

https://bugzilla.gnome.org/show_bug.cgi?id=654770
This commit is contained in:
Jasper St. Pierre 2011-06-11 00:21:35 -04:00
parent 67b4f9b3a9
commit ff983432d9
2 changed files with 36 additions and 13 deletions

View File

@ -1,5 +1,8 @@
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
const Lang = imports.lang;
const Signals = imports.signals;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const St = imports.gi.St; const St = imports.gi.St;
@ -29,6 +32,15 @@ var enabledExtensions;
// GFile for user extensions // GFile for user extensions
var userExtensionsDir = null; 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: * versionCheck:
* @required: an array of versions we're compatible with * @required: an array of versions we're compatible with
@ -166,6 +178,8 @@ function loadExtension(dir, enabled, type) {
return; return;
} }
extensionMeta[meta.uuid].state = ExtensionState.ENABLED; extensionMeta[meta.uuid].state = ExtensionState.ENABLED;
_signals.emit('extension-loaded', meta.uuid);
global.log('Loaded extension ' + meta.uuid); global.log('Loaded extension ' + meta.uuid);
} }

View File

@ -638,23 +638,32 @@ Extensions.prototype = {
name: 'lookingGlassExtensions' }); name: 'lookingGlassExtensions' });
this._noExtensions = new St.Label({ style_class: 'lg-extensions-none', this._noExtensions = new St.Label({ style_class: 'lg-extensions-none',
text: _("No extensions installed") }); text: _("No extensions installed") });
this._numExtensions = 0;
this._extensionsList = new St.BoxLayout({ vertical: true, this._extensionsList = new St.BoxLayout({ vertical: true,
style_class: 'lg-extensions-list' }); style_class: 'lg-extensions-list' });
this._extensionsList.add(this._noExtensions);
this.actor.add(this._extensionsList); 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() { _loadExtension: function(o, uuid) {
let extensions = ExtensionSystem.extensionMeta; let extension = ExtensionSystem.extensionMeta[uuid];
let totalExtensions = 0; // There can be cases where we create dummy extension metadata
for (let uuid in extensions) { // that's not really a proper extension. Don't bother with these.
let extensionDisplay = this._createExtensionDisplay(extensions[uuid]); if (!extension.name)
this._extensionsList.add(extensionDisplay); return;
totalExtensions++;
} let extensionDisplay = this._createExtensionDisplay(extension);
if (totalExtensions == 0) { if (this._numExtensions == 0)
this._extensionsList.add(this._noExtensions); this._extensionsList.remove_actor(this._noExtensions);
}
this._numExtensions ++;
this._extensionsList.add(extensionDisplay);
}, },
_onViewSource: function (actor) { _onViewSource: function (actor) {
@ -691,7 +700,7 @@ Extensions.prototype = {
text: meta.name }); text: meta.name });
box.add(name, { expand: true }); box.add(name, { expand: true });
let description = new St.Label({ style_class: 'lg-extension-description', let description = new St.Label({ style_class: 'lg-extension-description',
text: meta.description }); text: meta.description || 'No description' });
box.add(description, { expand: true }); box.add(description, { expand: true });
let metaBox = new St.BoxLayout(); let metaBox = new St.BoxLayout();