[polari/wip/fmuellner/window-experiments: 30/32] allow setting room at construction time



commit 3ba2366784fab185e970a1cb86c82735728e321d
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Jul 19 12:40:18 2016 +0200

    allow setting room at construction time

 src/application.js     |    6 +++++-
 src/chatroomManager.js |    1 -
 src/mainWindow.js      |   20 +++++++++++---------
 src/roomList.js        |    1 +
 4 files changed, 17 insertions(+), 11 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index e9dea77..46fbde8 100644
--- a/src/application.js
+++ b/src/application.js
@@ -521,7 +521,11 @@ const Application = new Lang.Class({
 
     _onNewWindow: function() {
         this.get_windows().reverse().forEach(w => { w.show(); });
-        let window = new MainWindow.MainWindow({ application: this });
+
+        let activeRoom = this.active_window.active_room;
+        let window = new MainWindow.MainWindow({ application: this,
+                                                 active_room: activeRoom });
+
         window.present();
     },
 
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index 54a0ecc..dbc6109 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -161,7 +161,6 @@ const _ChatroomManager = new Lang.Class({
         this._app.connect('window-added', (a, w) => {
             w.connect('notify::active-room',
                       Lang.bind(this, this._onActiveRoomChanged));
-            w.connect('realize', w => { w.active_room = this._activeRoom; });
         });
 
         this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 7117530..799d8af 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -127,16 +127,10 @@ const MainWindow = new Lang.Class({
         this._subtitle = '';
         params.show_menubar = false;
 
-        this.parent(params);
-
-        this._addApplicationStyle();
-
         this._rooms = {};
         this._entries = {};
 
         this._room = null;
-        this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
-        this._gtkSettings = Gtk.Settings.get_default();
 
         this._displayNameChangedId = 0;
         this._topicChangedId = 0;
@@ -146,6 +140,13 @@ const MainWindow = new Lang.Class({
         this._isMaximized = false;
         this._isFullscreen = false;
 
+        this.parent(params);
+
+        this._addApplicationStyle();
+
+        this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
+        this._gtkSettings = Gtk.Settings.get_default();
+
         this.notificationQueue = new AppNotifications.NotificationQueue();
         this._overlay.add_overlay(this.notificationQueue);
 
@@ -225,6 +226,10 @@ const MainWindow = new Lang.Class({
                             Lang.bind(this, this._onSizeAllocate));
         this.connect('delete-event',
                             Lang.bind(this, this._onDelete));
+        this.connect('notify::active-room', () => {
+            this._updateTitlebar();
+            this._updateUserListLabel();
+        });
 
         let size = this._settings.get_value('window-size').deep_unpack();
         if (size.length == 2)
@@ -302,9 +307,6 @@ const MainWindow = new Lang.Class({
 
         this._room = room;
 
-        this._updateTitlebar();
-        this._updateUserListLabel();
-
         this.notify('active-room');
         this.notify('active-room-id');
         this.emit('active-room-state-changed');
diff --git a/src/roomList.js b/src/roomList.js
index 72994c0..7a17b66 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -378,6 +378,7 @@ const RoomList = new Lang.Class({
        this._roomManager.forEachRoom(room => {
            this._roomAdded(this._roommanager, room);
        });
+       this._activeRoomIdChanged();
     },
 
     vfunc_realize: function() {


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