[gnome-documents] application: don't use Signals.addSignalMethods



commit bf55d86a6b56ca31711d5913b46c89a171a8b24e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Oct 30 12:39:06 2012 -0400

    application: don't use Signals.addSignalMethods
    
    It doesn't work properly when used together with a GObject subclass that
    emits its own signals.
    As a workaround, add a addJSSignalMethods() utility that adds methods
    with different names explicitly for JS signals, and use it for JS
    signals installed on the Application prototype.
    
    This fixes application actions not being activated anymore after the
    last commit.

 src/application.js   |    6 +++---
 src/notifications.js |    2 +-
 src/utils.js         |    8 ++++++++
 3 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 2ace4d8..fa058bb 100644
--- a/src/application.js
+++ b/src/application.js
@@ -228,7 +228,7 @@ const Application = new Lang.Class({
             return false;
 
         this.minersRunning.push(miner);
-        this.emit('miners-changed', this.minersRunning);
+        this.emitJS('miners-changed', this.minersRunning);
 
         miner.RefreshDBRemote(Lang.bind(this,
             function(res, error) {
@@ -236,7 +236,7 @@ const Application = new Lang.Class({
                     function(element) {
                         return element != miner;
                     });
-                this.emit('miners-changed', this.minersRunning);
+                this.emitJS('miners-changed', this.minersRunning);
 
                 if (error) {
                     log('Error updating the cache: ' + error.toString());
@@ -355,4 +355,4 @@ const Application = new Lang.Class({
         return 0;
     }
 });
-Signals.addSignalMethods(Application.prototype);
+Utils.addJSSignalMethods(Application.prototype);
diff --git a/src/notifications.js b/src/notifications.js
index 79b7f9e..b001b07 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -114,7 +114,7 @@ const IndexingNotification = new Lang.Class({
             return;
         }
 
-        Global.application.connect('miners-changed', Lang.bind(this, this._checkNotification));
+        Global.application.connectJS('miners-changed', Lang.bind(this, this._checkNotification));
         Mainloop.idle_add(Lang.bind(this,
             function() {
                 this._checkNotification();
diff --git a/src/utils.js b/src/utils.js
index 496fd61..8d3e8ef 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -30,6 +30,7 @@ const Documents = imports.documents;
 const Global = imports.global;
 
 const Lang = imports.lang;
+const Signals = imports.signals;
 
 const _ICON_VIEW_SIZE = 128;
 const _LIST_VIEW_SIZE = 48;
@@ -117,3 +118,10 @@ function debug(str) {
     if (debugEnabled)
         log('DEBUG: ' + str);
 }
+
+function addJSSignalMethods(proto) {
+    proto.connectJS = Signals._connect;
+    proto.disconnectJS = Signals._disconnect;
+    proto.emitJS = Signals._emit;
+    proto.disconnectAllJS = Signals._disconnectAll;
+}



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