[polari] chatroomManager: Add 'active-state-changed' signal



commit 3377ca0422daa88b17c38536df45f312351c453a
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 21 15:53:02 2014 +0100

    chatroomManager: Add 'active-state-changed' signal
    
    In some places we care about the active room's status more than
    about the room itself (e.g. whether the active room currently
    has an associated channel or not). To track this, we'd have to
    first listen for room changes and then track the room's channel
    property - this is fairly cumbersome in most places, while trivial
    from ChatroomManager where we are already tracking all rooms
    anywhere, so add a new signal there.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724902

 src/chatroomManager.js |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index 9a9f420..9239338 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -215,6 +215,13 @@ const _ChatroomManager = new Lang.Class({
     _addRoom: function(room) {
         if (this._rooms[room.id])
             return;
+
+        room._channelChangedId = room.connect('notify::channel', Lang.bind(this,
+            function(room) {
+                if (room == this._activeRoom)
+                    this.emit('active-state-changed');
+            }));
+
         this._rooms[room.id] = room;
         this.emit('room-added', room);
 
@@ -225,6 +232,8 @@ const _ChatroomManager = new Lang.Class({
     _removeRoom: function(room) {
         if (!this._rooms[room.id])
             return;
+        room.disconnect(room._channelChangedId);
+        delete room._channelChangedId;
         delete this._rooms[room.id];
         this.emit('room-removed', room);
     },
@@ -235,6 +244,7 @@ const _ChatroomManager = new Lang.Class({
 
         this._activeRoom = room;
         this.emit('active-changed', room);
+        this.emit('active-state-changed');
     },
 
     getActiveRoom: function(room) {


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