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 -*- */
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);
}

View File

@ -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();