[polari] chatView: Simplify tracking of active room
- From: Florian MĂźllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] chatView: Simplify tracking of active room
- Date: Tue, 15 Oct 2013 19:11:46 +0000 (UTC)
commit 2c398b5e012f1cb9fa97d72428e7455b48aa6f78
Author: Florian MĂźllner <fmuellner gnome org>
Date: Tue Oct 15 18:39:55 2013 +0200
chatView: Simplify tracking of active room
We need to jump through way less hoops by just tracking the mapped
state of the chat widget directly ...
src/chatView.js | 23 ++++++-----------------
1 files changed, 6 insertions(+), 17 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 749ebae..34bfe22 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -33,7 +33,6 @@ const ChatView = new Lang.Class({
this._room = room;
this._lastNick = null;
- this._stackNotifyVisibleChildId = 0;
this._active = false;
this._toplevelFocus = false;
this._maxNickChars = MAX_NICK_CHARS;
@@ -161,7 +160,8 @@ const ChatView = new Lang.Class({
this.widget.connect('destroy', Lang.bind(this, this._onDestroy));
this.widget.connect('screen-changed',
Lang.bind(this, this._updateIndent));
- this.widget.connect('parent-set', Lang.bind(this, this._onParentSet));
+ this.widget.connect('map', Lang.bind(this, this._updateActive));
+ this.widget.connect('unmap', Lang.bind(this, this._updateActive));
this.widget.connect('state-flags-changed',
Lang.bind(this, this._updateToplevel));
this.widget.vadjustment.connect('value-changed',
@@ -198,22 +198,11 @@ const ChatView = new Lang.Class({
this._view.left_margin = this._maxNickChars * pixelWidth;
},
- _onParentSet: function(widget, oldParent) {
- if (oldParent)
- oldParent.disconnect(this._stackNotifyVisibleChildId);
-
- let newParent = this.widget.get_parent();
- if (!newParent)
- return;
-
- this._stackNotifyVisibleChildId =
- newParent.connect('notify::visible-child',
- Lang.bind(this, this._updateActive));
- this._updateActive();
- },
-
_updateActive: function() {
- this._active = this.widget.get_parent().get_visible_child() == this.widget;
+ let active = this.widget.get_mapped();
+ if (this._active == active)
+ return;
+ this._active = active;
this._checkMessages();
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]