[polari] roomStack: Track entry area sensitivity
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomStack: Track entry area sensitivity
- Date: Tue, 4 Mar 2014 23:28:12 +0000 (UTC)
commit 0dd1ce05cdf009d8c9fda5e82e4b968840d39cec
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Feb 28 19:42:49 2014 +0100
roomStack: Track entry area sensitivity
Rather than letting each entry area do its own tracking, do it
centrally in one place.
src/entryArea.js | 25 ++-----------------------
src/roomStack.js | 20 ++++++++++++++++++++
2 files changed, 22 insertions(+), 23 deletions(-)
---
diff --git a/src/entryArea.js b/src/entryArea.js
index 9e1e40b..c572668 100644
--- a/src/entryArea.js
+++ b/src/entryArea.js
@@ -1,8 +1,6 @@
const Gdk = imports.gi.Gdk;
-const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
-const ChatroomManager = imports.chatroomManager;
const ChatView = imports.chatView;
const IrcParser = imports.ircParser;
const Lang = imports.lang;
@@ -23,16 +21,6 @@ const EntryArea = new Lang.Class({
this._room = room;
- this._roomManager = new ChatroomManager.getDefault();
- this._activeRoomChangedId =
- this._roomManager.connect('active-changed',
- Lang.bind(this, this._updateSensitivity));
-
- let app = Gio.Application.get_default();
- this._selectionModeAction = app.lookup_action('selection-mode');
- this._selectionModeAction.connect('notify::state',
- Lang.bind(this, this._updateSensitivity));
-
if (!room)
return;
@@ -53,6 +41,7 @@ const EntryArea = new Lang.Class({
this.widget.get_style_context().add_class('linked');
this.widget.connect('destroy', Lang.bind(this, this._onDestroy));
+ this.widget.connect('notify::sensitive', Lang.bind(this, this._onSensitiveChanged));
this._nickEntry = new Gtk.Entry();
this._nickEntry.width_chars = ChatView.MAX_NICK_CHARS
@@ -119,13 +108,7 @@ const EntryArea = new Lang.Class({
this._completion.setCompletions(nicks);
},
- _updateSensitivity: function() {
- let room = this._roomManager.getActiveRoom();
- this.widget.sensitive = this._room &&
- this._room == room &&
- room.channel &&
- !this._selectionModeAction.state.get_boolean();
-
+ _onSensitiveChanged: function() {
if (!this.widget.sensitive)
return;
@@ -138,7 +121,6 @@ const EntryArea = new Lang.Class({
_onChannelChanged: function(room) {
this._updateCompletions();
- this._updateSensitivity();
if (room.channel)
this._nicknameChangedId =
@@ -192,9 +174,6 @@ const EntryArea = new Lang.Class({
},
_onDestroy: function() {
- this._roomManager.disconnect(this._activeRoomChangedId);
- this._activeRoomChangedId = 0;
-
if (this._membersChangedId)
this._room.disconnect(this._membersChangedId);
this._membersChangedId = 0;
diff --git a/src/roomStack.js b/src/roomStack.js
index 1f7629c..2f006df 100644
--- a/src/roomStack.js
+++ b/src/roomStack.js
@@ -1,3 +1,4 @@
+const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const ChatroomManager = imports.chatroomManager;
@@ -21,6 +22,13 @@ const RoomStack = new Lang.Class({
Lang.bind(this, this._roomRemoved));
this._roomManager.connect('active-changed',
Lang.bind(this, this._activeRoomChanged));
+ this._roomManager.connect('active-state-changed',
+ Lang.bind(this, this._updateSensitivity));
+
+ let app = Gio.Application.get_default();
+ this._selectionModeAction = app.lookup_action('selection-mode');
+ this._selectionModeAction.connect('notify::state',
+ Lang.bind(this, this._updateSensitivity));
this._rooms = {};
@@ -49,6 +57,14 @@ const RoomStack = new Lang.Class({
: Gtk.StackTransitionType.NONE;
},
+ _updateSensitivity: function() {
+ let room = this._roomManager.getActiveRoom();
+ let id = room ? room.id : 'placeholder';
+ let sensitive = room && room.channel &&
+ !this._selectionModeAction.state.get_boolean();
+ this._rooms[id].inputSensitive = sensitive;
+ },
+
_createWidget: function() {
this.widget = new Gtk.Frame();
this.widget.get_style_context().add_class('polari-chat-stack');
@@ -87,5 +103,9 @@ const RoomView = new Lang.Class({
this.inputWidget.add(this._entryArea.widget);
this.widget.show_all();
+ },
+
+ set inputSensitive(sensitive) {
+ this._entryArea.widget.sensitive = sensitive;
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]