[polari/wip/fmuellner/window-experiments: 15/15] roomList: Detach rooms that are shown in their own window



commit 42796e983c60fb13fc7e7c48bf8d5f98b65faaca
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 21 04:54:59 2016 +0200

    roomList: Detach rooms that are shown in their own window

 src/application.js |    7 ++++++-
 src/roomList.js    |   10 +++++++++-
 2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 4082c49..92e5702 100644
--- a/src/application.js
+++ b/src/application.js
@@ -30,7 +30,9 @@ const ConnectionError = {
 const Application = new Lang.Class({
     Name: 'Application',
     Extends: Gtk.Application,
-    Signals: { 'prepare-shutdown': {} },
+    Signals: { 'room-attached': { param_types: [Polari.Room.$gtype] },
+               'room-detached': { param_types: [Polari.Room.$gtype] },
+               'prepare-shutdown': {} },
 
     _init: function() {
         this.parent({ application_id: 'org.gnome.Polari',
@@ -552,6 +554,9 @@ const Application = new Lang.Class({
         let window = new MainWindow.MainWindow({ application: this,
                                                  active_room: room,
                                                  single_room: true });
+        window.connect('destroy', () => { this.emit('room-attached', room); });
+        this.emit('room-detached', room);
+
         window.present();
     },
 
diff --git a/src/roomList.js b/src/roomList.js
index 4e50e16..d8e29c9 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -346,6 +346,12 @@ const RoomList = new Lang.Class({
         this._roomManager.connect('room-removed',
                                   Lang.bind(this, this._roomRemoved));
 
+        this._app = Gio.Application.get_default();
+        this._app.connect('room-attached',
+                          Lang.bind(this, this._roomAdded));
+        this._app.connect('room-detached',
+                          Lang.bind(this, this._roomRemoved));
+
         this._accountsMonitor = AccountsMonitor.getDefault();
         let feature = Tp.AccountManager.get_feature_quark_core();
         let mon = this._accountsMonitor;
@@ -361,7 +367,7 @@ const RoomList = new Lang.Class({
         this._accountsMonitor.connect('account-removed',
                                       Lang.bind(this, this._accountRemoved));
 
-        let action = Gio.Application.get_default().lookup_action('leave-room');
+        let action = this._app.lookup_action('leave-room');
         action.connect('activate', Lang.bind(this, this._onLeaveActivated));
     },
 
@@ -478,6 +484,8 @@ const RoomList = new Lang.Class({
             return;
 
         let toplevel = this.get_toplevel();
+        if (toplevel.single_room)
+            return;
         let current = this._roomRows.get(toplevel.active_room_id);
 
         if (current != row)


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