[gnome-shell] extensionSystem: Add 'extension-status-changed' signal



commit a56cd3c3d68b3eb3f5df528ab5738d20cc2a4bc7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Jun 27 22:21:02 2011 -0400

    extensionSystem: Add 'extension-status-changed' signal
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654770

 js/ui/extensionSystem.js |    7 +++++++
 js/ui/shellDBus.js       |   15 +++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 8907a8e..3bd0cbe 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -182,6 +182,7 @@ function disableExtension(uuid) {
     }
 
     meta.state = ExtensionState.DISABLED;
+    _signals.emit('extension-state-changed', meta);
 }
 
 function enableExtension(uuid) {
@@ -202,12 +203,16 @@ function enableExtension(uuid) {
     }
 
     meta.state = ExtensionState.ENABLED;
+    _signals.emit('extension-state-changed', meta);
 }
 
 function logExtensionError(uuid, message) {
     if (!errors[uuid]) errors[uuid] = [];
     errors[uuid].push(message);
     global.logError('Extension "%s" had error: %s'.format(uuid, message));
+    _signals.emit('extension-state-changed', { uuid: uuid,
+                                               error: message,
+                                               state: ExtensionState.ERROR });
 }
 
 function loadExtension(dir, enabled, type) {
@@ -268,6 +273,7 @@ function loadExtension(dir, enabled, type) {
     extensionMeta[uuid] = meta;
     meta.type = type;
     meta.path = dir.get_path();
+    meta.error = '';
 
     // Default to error, we set success as the last step
     meta.state = ExtensionState.ERROR;
@@ -335,6 +341,7 @@ function loadExtension(dir, enabled, type) {
         enableExtension(uuid);
 
     _signals.emit('extension-loaded', meta.uuid);
+    _signals.emit('extension-state-changed', meta);
     global.log('Loaded extension ' + meta.uuid);
 }
 
diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js
index 07f2881..cf39034 100644
--- a/js/ui/shellDBus.js
+++ b/js/ui/shellDBus.js
@@ -1,6 +1,7 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
 const DBus = imports.dbus;
+const Lang = imports.lang;
 
 const Config = imports.misc.config;
 const ExtensionSystem = imports.ui.extensionSystem;
@@ -49,7 +50,8 @@ const GnomeShellIface = {
                 outSignature: ''
               }
              ],
-    signals: [],
+    signals: [{ name: 'ExtensionStatusChanged',
+                inSignature: 'sis' }],
     properties: [{ name: 'OverviewActive',
                    signature: 'b',
                    access: 'readwrite' },
@@ -68,6 +70,8 @@ function GnomeShell() {
 GnomeShell.prototype = {
     _init: function() {
         DBus.session.exportObject('/org/gnome/Shell', this);
+        ExtensionSystem.connect('extension-state-changed',
+                                Lang.bind(this, this._extensionStateChanged));
     },
 
     /**
@@ -187,7 +191,14 @@ GnomeShell.prototype = {
 
     ApiVersion: 1,
 
-    ShellVersion: Config.PACKAGE_VERSION
+    ShellVersion: Config.PACKAGE_VERSION,
+
+    _extensionStateChanged: function(_, newState) {
+        DBus.session.emit_signal('/org/gnome/Shell',
+                                 'org.gnome.Shell',
+                                 'ExtensionStatusChanged', 'sis',
+                                 [newState.uuid, newState.state, newState.error]);
+    }
 };
 
 DBus.conformExport(GnomeShell.prototype, GnomeShellIface);



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