[polari/wip/fmuellner/combined-gsoc: 46/103] fixed rebase halfway. popover rebased untop of the user tracker, but the usertracker is only trackin
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 46/103] fixed rebase halfway. popover rebased untop of the user tracker, but the usertracker is only trackin
- Date: Fri, 22 Jul 2016 13:37:50 +0000 (UTC)
commit 2b2d260aa2b2994a9d117ad9b7ca0923889c2a2d
Author: raresv <rares visalom gmail com>
Date: Fri Jul 8 19:48:41 2016 +0300
fixed rebase halfway. popover rebased untop of the user tracker, but the usertracker is only tracking
local status changes, since we rebased ontop of only the first (of the two) usertracker patches
src/application.js | 4 ++--
src/chatView.js | 32 +++++---------------------------
src/userList.js | 42 ++++++++++++++++++++++++++++--------------
src/userTracker.js | 32 +++++++++++++++++++++++++++++---
4 files changed, 64 insertions(+), 46 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 0b36431..77fd622 100644
--- a/src/application.js
+++ b/src/application.js
@@ -51,10 +51,10 @@ const Application = new Lang.Class({
this._networksManager = NetworksManager.getDefault();
/*created here as i couldn't make it work if it was created in the chatroomManager
(it didn't receive the room-added signal for the channels restored from the previous session)*/
- this._globalUserTracker = new UserTracker.UserTracker(null);
+ /*this._globalUserTracker = new UserTracker.UserTracker(null);
this._globalUserTracker.connect('status-changed', Lang.bind(this, function(tracker, nick, status){
log("[Application] nick " + nick + " global status changed to " + status );
- }));
+ }));*/
this._accountsMonitor.connect('account-removed', Lang.bind(this,
function(am, account) {
diff --git a/src/chatView.js b/src/chatView.js
index bda79a4..125df89 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -1211,6 +1211,8 @@ const ChatView = new Lang.Class({
if (!nickTag) {
nickTag = this._createNickTag(nickTagName);
buffer.get_tag_table().add(nickTag);
+
+ this._updateNickTag(nickTag, this._userTracker.getNickStatus(message.nick));
}
tags.push(nickTag);
if (needsGap)
@@ -1261,7 +1263,7 @@ 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 });
+ tag._popover = new UserList.UserPopover({ relative_to: this._view, margin: 0, room: this._room,
userTracker: this._userTracker });
tag.connect('clicked', Lang.bind(this, this._onNickTagClicked));
return tag;
},
@@ -1293,33 +1295,9 @@ const ChatView = new Lang.Class({
//TODO: special chars?
let actualNickName = view.get_buffer().get_slice(start, end, false);
- tag._popover.fallbackNick = actualNickName;
+ tag._popover.nickname = actualNickName;
- let contactFound = false;
- for (let i = 0; i < tag._contacts.length; i++) {
- if (actualNickName == tag._contacts[i].alias) {
- if (!tag._popover.user) {
- tag._popover.user = tag._contacts[i];
- contactFound = true;
- break;
- }
- else if (tag._popover.user != tag._contacts[i]) {
- tag._popover.user = tag._contacts[i];
- contactFound = true;
- break;
- }
- else if (tag._popover.user == tag._contacts[i]) {
- contactFound = true;
- break;
- }
- }
- }
-
- if (!contactFound) {
- if (tag._contacts[0]) {
- tag._popover.user = tag._contacts[0];
- }
- }
+ //tag._popover.user = this._userTracker.getBestMatchingContact(actualNickName);
tag._popover.pointing_to = rect1;
tag._popover.show();
diff --git a/src/userList.js b/src/userList.js
index dc57631..12d20df 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -5,6 +5,7 @@ const GObject = imports.gi.GObject;
const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
const Tp = imports.gi.TelepathyGLib;
+const Polari = imports.gi.Polari;
const ChatroomManager = imports.chatroomManager;
const Lang = imports.lang;
@@ -153,8 +154,8 @@ const UserDetails = new Lang.Class({
this._updateButtonVisibility();
},
- set fallbackNick(fallbackNick) {
- this._fallbackNick = fallbackNick;
+ set nickname(nickname) {
+ this._nickname = nickname;
this._updateButtonVisibility();
},
@@ -196,7 +197,7 @@ const UserDetails = new Lang.Class({
Lang.bind(this, this._onContactInfoReady));
//TODO: else use this._falbackNick to query tracker
else
- this._trackFallbackNick(this._fallbackNick);
+ this._trackFallbackNick(this._nickname);
},
_unexpand: function() {
@@ -267,7 +268,7 @@ const UserDetails = new Lang.Class({
this._revealDetails();
},
- _trackFallbackNick: function(fallbackNick) {
+ _trackFallbackNick: function(nickname) {
this._lastHeader.label = '<small>' + _("Last Activity:") + '</small>';
this._lastHeader.show();
@@ -322,6 +323,9 @@ const UserPopover = new Lang.Class({
this._room = params.room;
delete params.room;
+ this._userTracker = params.userTracker;
+ delete params.userTracker;
+
this.parent(params);
this._chatroomManager = ChatroomManager.getDefault();
@@ -370,18 +374,24 @@ const UserPopover = new Lang.Class({
return this._user;
},
- set fallbackNick(fallbackNick) {
- this._fallbackNick = fallbackNick;
+ set nickname(nickname) {
+ this._nickname = nickname;
+
+ let baseNick = Polari.util_get_basenick(nickname);
+
+ this._userTracker.connect("status-changed::" + baseNick, Lang.bind(this, this._onNickStatusChanged));
+
+ this.user = this._userTracker.getBestMatchingContact(this._nickname);
this._updateContents();
},
- get fallbackNick() {
- return this._fallbackNick;
+ get nickname() {
+ return this._nickname;
},
_updateContents: function() {
- this._nickLabel.set_label(this._fallbackNick);
+ this._nickLabel.set_label(this._nickname);
this._statusLabel.set_label(this._user ? "Online" : "Offline");
if (this._user) {
@@ -400,7 +410,7 @@ const UserPopover = new Lang.Class({
this._statusLabel.sensitive = false;
- /*if (!this._chatroomManager.isUserWatched(this._fallbackNick,
this._room.account.get_display_name()))
+ /*if (!this._chatroomManager.isUserWatched(this._nickname,
this._room.account.get_display_name()))
this._notifyButton.visible = true;
else
this._notifyButton.sensitive = false;*/
@@ -409,19 +419,19 @@ const UserPopover = new Lang.Class({
this._updateNotifyButton();
- this._userDetails.fallbackNick = this._fallbackNick;
+ this._userDetails.nickname = this._nickname;
},
_onNotifyButtonClicked: function() {
- if (!this._chatroomManager.isUserWatched(this._fallbackNick, this._room.account.get_display_name()))
{
- this._chatroomManager.addToWatchlist(this._fallbackNick, this._room.account.get_display_name());
+ if (!this._chatroomManager.isUserWatched(this._nickname, this._room.account.get_display_name())) {
+ this._chatroomManager.addToWatchlist(this._nickname, this._room.account.get_display_name());
//this._notifyButton.sensitive = false;
this._updateNotifyButton();
}
},
_updateNotifyButton: function() {
- if (!this._chatroomManager.isUserWatched(this._fallbackNick, this._room.account.get_display_name()))
+ if (!this._chatroomManager.isUserWatched(this._nickname, this._room.account.get_display_name()))
if (this._user) {
this._notifyButton.visible = false;
this._notifyButton.sensitive = true;
@@ -439,6 +449,10 @@ const UserPopover = new Lang.Class({
this._notifyButton.visibile = true;
this._notifyButton.sensitive = false;
}
+ },
+
+ _onNickStatusChanged: function(tracker, nickName, status) { log("da");
+ this.user = this._userTracker.getBestMatchingContact(this._nickname);
}
});
diff --git a/src/userTracker.js b/src/userTracker.js
index 392e46b..d9cac5b 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -2,13 +2,25 @@ const Polari = imports.gi.Polari;
const Lang = imports.lang;
const Tp = imports.gi.TelepathyGLib;
const Signals = imports.signals;
+const GObject = imports.gi.GObject;
+
const ChatroomManager = imports.chatroomManager;
const UserTracker = new Lang.Class({
Name: 'UserTracker',
+ Extends: GObject.Object,
+
+ Signals: {
+ 'status-changed': {
+ flags: GObject.SignalFlags.DETAILED,
+ param_types: [GObject.TYPE_STRING, GObject.TYPE_INT]
+ },
+ },
_init: function(room) {
+ this.parent();
+
this._referenceRoomSignals = [
{ name: 'notify::channel',
handler: Lang.bind(this, this._onChannelChanged) },
@@ -120,7 +132,7 @@ const UserTracker = new Lang.Class({
this._contactMapping.set(baseNick, [member]);
if (this._contactMapping.get(baseNick).length == 1)
- this.emit('status-changed', member.alias, Tp.ConnectionPresenceType.AVAILABLE);
+ this.emit("status-changed::"+baseNick, member.alias, Tp.ConnectionPresenceType.AVAILABLE);
},
_untrackMember: function(member) {
@@ -133,7 +145,7 @@ const UserTracker = new Lang.Class({
contacts.splice(indexToDelete, 1);
if (contacts.length == 0)
- this.emit('status-changed', member.alias, Tp.ConnectionPresenceType.OFFLINE);
+ this.emit("status-changed::"+baseNick, member.alias, Tp.ConnectionPresenceType.OFFLINE);
}
},
@@ -144,5 +156,19 @@ const UserTracker = new Lang.Class({
return contacts.length == 0 ? Tp.ConnectionPresenceType.OFFLINE
: Tp.ConnectionPresenceType.AVAILABLE;
},
+
+ getBestMatchingContact: function(nickName) {
+ let baseNick = Polari.util_get_basenick(nickName);
+ let contacts = this._contactMapping.get(baseNick) || [];
+
+ /*even possible?*/
+ if (contacts.length == 0)
+ return null;
+
+ for (let i = 0; i < contacts.length; i++)
+ if (contacts[i].alias == nickName)
+ return contacts[i];
+
+ return contacts[0];
+ }
});
-Signals.addSignalMethods(UserTracker.prototype);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]