[polari/wip/fmuellner/nickserv: 11/29] mainWindow: Track last selected room
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/nickserv: 11/29] mainWindow: Track last selected room
- Date: Thu, 11 Aug 2016 08:43:14 +0000 (UTC)
commit 30ffb1bbc25fb8c37d3323491b0f63c612ce7853
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Jul 31 16:12:53 2016 +0200
mainWindow: Track last selected room
Equally, the tracking of the last selected room is now easier done by
the window. For now, we still rely on the correct room being restored
first, but we will soon handle this in the window as well.
https://bugzilla.gnome.org/show_bug.cgi?id=769655
src/chatroomManager.js | 27 ---------------------------
src/mainWindow.js | 22 ++++++++++++++++++++++
2 files changed, 22 insertions(+), 27 deletions(-)
---
diff --git a/src/chatroomManager.js b/src/chatroomManager.js
index c0151a5..6b7d10e 100644
--- a/src/chatroomManager.js
+++ b/src/chatroomManager.js
@@ -154,16 +154,7 @@ const _ChatroomManager = new Lang.Class({
this._amIsPrepared = false;
this._accountsMonitor.prepare(Lang.bind(this, this._onPrepared));
- this._app.connect('prepare-shutdown',
- Lang.bind(this, this._onPrepareShutdown));
- this._app.connect('window-added', (a, w) => {
- w.connect('notify::active-room',
- Lang.bind(this, this._onActiveRoomChanged));
- });
-
this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
-
- this._lastActiveRoom = null;
},
_onPrepared: function() {
@@ -458,24 +449,6 @@ const _ChatroomManager = new Lang.Class({
this.emit('room-removed', room);
},
- _onPrepareShutdown: function() {
- if (this._lastActiveRoom) {
- let serializedChannel = { account: GLib.Variant.new('s',
this._lastActiveRoom.account.get_object_path()),
- channel: GLib.Variant.new('s', this._lastActiveRoom.channel_name) };
-
- this._settings.set_value('last-selected-channel', GLib.Variant.new('a{sv}', serializedChannel));
- } else {
- this._settings.reset('last-selected-channel');
- }
- },
-
- _onActiveRoomChanged: function(window) {
- let room = window.active_room;
-
- if (room && room.type == Tp.HandleType.ROOM)
- this._lastActiveRoom = room;
- },
-
_setActiveRoom: function(room) {
this._app.active_window.active_room = room;
},
diff --git a/src/mainWindow.js b/src/mainWindow.js
index d396cb0..85b51d0 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -124,6 +124,7 @@ const MainWindow = new Lang.Class({
params.show_menubar = false;
this._room = null;
+ this._lastActiveRoom = null;
this._displayNameChangedId = 0;
this._topicChangedId = 0;
@@ -169,6 +170,8 @@ const MainWindow = new Lang.Class({
this._roomManager = ChatroomManager.getDefault();
this._roomManager.connect('room-added',
Lang.bind(this, this._onRoomAdded));
+ this._roomManager.connect('room-removed',
+ Lang.bind(this, this._onRoomRemoved));
this._updateUserListLabel();
@@ -227,6 +230,18 @@ const MainWindow = new Lang.Class({
this._settings.set_boolean ('window-maximized', this._isMaximized);
this._settings.set_value('window-size',
GLib.Variant.new('ai', this._currentSize));
+
+ let serializedChannel = null;
+ if (this._lastActiveRoom)
+ serializedChannel = new GLib.Variant('a{sv}', {
+ account: new GLib.Variant('s', this._lastActiveRoom.account.object_path),
+ channel: new GLib.Variant('s', this._lastActiveRoom.channel_name)
+ });
+
+ if (serializedChannel)
+ this._settings.set_value('last-selected-channel', serializedChannel);
+ else
+ this._settings.reset('last-selected-channel');
},
_onAccountsChanged: function(am) {
@@ -269,6 +284,8 @@ const MainWindow = new Lang.Class({
this._membersChangedId = 0;
this._channelChangedId = 0;
+ if (room && room.type == Tp.HandleType.ROOM)
+ this._lastActiveRoom = room;
this._room = room;
this._updateTitlebar();
@@ -317,6 +334,11 @@ const MainWindow = new Lang.Class({
this.active_room = room;
},
+ _onRoomRemoved: function(mgr, room) {
+ if (room == this._lastActiveRoom)
+ this._lastActiveRoom = null;
+ },
+
showJoinRoomDialog: function() {
let dialog = new JoinDialog.JoinDialog({ transient_for: this });
dialog.show();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]