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



commit e293bbbd62c9359e3cb084cced2dbbadafc7168f
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 7699946..fb3bce0 100644
--- a/src/application.js
+++ b/src/application.js
@@ -28,7 +28,9 @@ const AUTOSTART_FILE = '/org.gnome.Polari.Autostart.desktop';
 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': {},
                'room-focus-changed': {} },
 
     _init: function() {
@@ -553,6 +555,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 97d4b55..6f388c6 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -362,6 +362,12 @@ const RoomList = new Lang.Class({
         this._placeholders = new Map();
         this._roomRows = new Map();
 
+        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();
         this._accountsMonitor.connect('account-added',
                                       Lang.bind(this, this._accountAdded));
@@ -386,7 +392,7 @@ const RoomList = new Lang.Class({
                                   Lang.bind(this, this._roomRemoved));
         this._roomManager.rooms.forEach(r => { this._roomAdded(this._roomManager, r); });
 
-        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));
     },
 
@@ -483,6 +489,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]