[polari/wip/raresv/userTrackerAndPopoversRebase: 24/24] chatView: create popover with a width request of 280px. chatView: Add HoverFilterTag and insert a Ho
- From: Rares Visalom <raresvisalom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/raresv/userTrackerAndPopoversRebase: 24/24] chatView: create popover with a width request of 280px. chatView: Add HoverFilterTag and insert a Ho
- Date: Fri, 5 Aug 2016 23:42:12 +0000 (UTC)
commit 64c3a833e8f9efcdbcc2598e3920d320908c7202
Author: raresv <rares visalom gmail com>
Date: Fri Aug 5 16:54:35 2016 +0300
chatView: create popover with a width request of 280px.
chatView: Add HoverFilterTag and insert a HoverFilterTag with each nick.
chatView: Clean up a bit
chatView: Rename a handler
I know I'm usually asking for shortening names, but here it makes
sense to specify which status it is we're talking about (there's
a lot of different stuff in chatView, so it's not exactly clear
from context).
chatView: Use some bits into the UserPopover template
Margin and width-request aren't really specific to the chat view,
so let's just include those in the .ui file ...
chatView: delete duplicate _onNickStatusChanged() method and fix the typo near the call to
getNickStatus().
userPopover: only define used internal children.
userTracker: remove unused parts, replace _contactMapping with _handlerMapping, guard the nick while
setting the handler and fix return variable.
chatView: replace watchUser() with watchRoomStatus().
chatView: check if the signal id is greater than 0 before disconnecting it and initialize it to 0 after
disconecting. This helps to preserve consistency.
chatView: remove the check for signal id before disconnecting the signal.
chatView: popovers are now created on demand, not right after the tag is created.
chatView: replace nick with baseNick.
chatView: comment out duplicated _createNickTag()
src/chatView.js | 118 +++++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 92 insertions(+), 26 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 06ffc1c..ecc1462 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -227,6 +227,71 @@ const ButtonTag = new Lang.Class({
}
});
+const HoverFilterTag = new Lang.Class({
+ Name: 'HoverFilterTag',
+ Extends: ButtonTag,
+ Properties: {
+ 'filtered-tag': GObject.ParamSpec.object('filtered-tag',
+ 'filtered-tag',
+ 'filtered-tag',
+ GObject.ParamFlags.READWRITE |
+ GObject.ParamFlags.CONSTRUCT_ONLY,
+ Gtk.TextTag.$gtype),
+ 'hover-opacity': GObject.ParamSpec.double('hover-opacity',
+ 'hover-opacity',
+ 'hover-opacity',
+ GObject.ParamFlags.READWRITE,
+ 0.0, 1.0, 1.0)
+ },
+
+ _init: function(params) {
+ this._filteredTag = null;
+ this._hoverOpacity = 1.;
+
+ this.parent(params);
+
+ this.connect('notify::hover', () => { this._updateColor(); });
+ },
+
+ _updateColor: function() {
+ if (!this._filteredTag)
+ return;
+
+ let color = this._filteredTag.foreground_rgba;
+ if (this.hover)
+ color.alpha *= this._hoverOpacity;
+ this.foreground_rgba = color;
+ },
+
+ set filtered_tag(value) {
+ this._filteredTag = value;
+ this.notify('filtered-tag');
+
+ this._filteredTag.connect('notify::foreground-rgba', () => {
+ this._updateColor();
+ });
+ this._updateColor();
+ },
+
+ get filtered_tag() {
+ return this._filteredTag;
+ },
+
+ set hover_opacity(value) {
+ if (this._hoverOpacity == value)
+ return;
+ this._hoverOpacity = value;
+ this.notify('hover-opacity');
+
+ if (this.hover)
+ this._updateColor();
+ },
+
+ get hover_opacity() {
+ return this._hoverOpacity;
+ }
+});
+
const ChatView = new Lang.Class({
Name: 'ChatView',
Extends: Gtk.ScrolledWindow,
@@ -298,7 +363,9 @@ const ChatView = new Lang.Class({
this._pending = {};
this._pendingLogs = [];
this._statusCount = { left: 0, joined: 0, total: 0 };
- this._userStatusMonitor = UserTracker.getUserStatusMonitor();
+
+ let statusMonitor = UserTracker.getUserStatusMonitor();
+ this._userTracker = statusMonitor.getUserTrackerForAccount(room.account);
this._room.account.connect('notify::nickname', Lang.bind(this,
function() {
@@ -352,8 +419,14 @@ const ChatView = new Lang.Class({
}));
this._onChannelChanged();
- /*where should we unwatch? int onChannelChanged when we don't have a channel?*/
- this._roomWatchHandler =
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).watchUser(this._room, null,
Lang.bind(this, this._onStatusChangedCallback));
+ this._nickStatusChangedId =
+ this._userTracker.watchRoomStatus(this._room, null,
+ Lang.bind(this, this._onNickStatusChanged));
+
+ this.connect('destroy', () => {
+ this._userTracker.unwatchRoomStatus(this._room, this._nickStatusChangedId);
+ this._userTracker = null;
+ });
},
_createTags: function() {
@@ -768,15 +841,6 @@ const ChatView = new Lang.Class({
return NICKTAG_PREFIX + Polari.util_get_basenick(nick);
},
- _onNickStatusChanged: function(tracker, nickName, status) {
- let nickTag = this._lookupTag(this._getNickTagName(nickName));
-
- if (!nickTag)
- return;
-
- this._updateNickTag(nickTag, status);
- },
-
_onChannelChanged: function() {
if (this._channel == this._room.channel)
return;
@@ -1177,9 +1241,17 @@ const ChatView = new Lang.Class({
nickTag = this._createNickTag(nickTagName);
buffer.get_tag_table().add(nickTag);
- this._updateNickTag(nickTag,
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).getNickStatus(message.nick));
+ let status = this._userTracker.getNickStatus(message.nick);
+ this._updateNickTag(nickTag, status);
}
tags.push(nickTag);
+
+ let hoverTag = new HoverFilterTag({ filtered_tag: nickTag,
+ hover_opacity: 0.8 });
+ buffer.get_tag_table().add(hoverTag);
+
+ tags.push(hoverTag);
+
if (needsGap)
tags.push(this._lookupTag('gap'));
this._insertWithTags(iter, message.nick, tags);
@@ -1215,18 +1287,8 @@ const ChatView = new Lang.Class({
this._insertWithTags(iter, text.substr(pos), tags);
},
- _createNickTag: function(nickName) {
- let nickTagName = this._getNickTagName(nickName);
-
- let tag = new Gtk.TextTag({ name: nickTagName });
- //this._updateNickTag(tag,
this._userStatusMonitor.getUserTrackerForAccount(this._room.account).getNickRoomStatus(nickName, this._room));
- this._updateNickTag(tag, Tp.ConnectionPresenceType.OFFLINE);
-
- return tag;
- },
-
- _onStatusChangedCallback: function(nick, status) {
- let nickTagName = this._getNickTagName(nick);
+ _onNickStatusChanged: function(baseNick, status) {
+ let nickTagName = this._getNickTagName(baseNick);
let nickTag = this._lookupTag(nickTagName);
if (!nickTag)
@@ -1244,7 +1306,6 @@ const ChatView = new Lang.Class({
_createNickTag: function(name) {
let tag = new ButtonTag({ name: name });
- tag._popover = new UserList.UserPopover({ relative_to: this._view, margin: 0, room: this._room,
userTracker: this._userStatusMonitor.getUserTrackerForAccount(this._room.account) });
tag.connect('clicked', Lang.bind(this, this._onNickTagClicked));
return tag;
},
@@ -1276,6 +1337,11 @@ const ChatView = new Lang.Class({
//TODO: special chars?
let actualNickName = view.get_buffer().get_slice(start, end, false);
+ if (!tag._popover)
+ tag._popover = new UserList.UserPopover({ relative_to: this._view,
+ userTracker: this._userTracker,
+ room: this._room });
+
tag._popover.nickname = actualNickName;
tag._popover.pointing_to = rect1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]