[polari/wip/fmuellner/combined-gsoc: 77/137] Some cleaning up and minor fix to the notification part (the label was not hidden if a notification
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 77/137] Some cleaning up and minor fix to the notification part (the label was not hidden if a notification
- Date: Thu, 28 Jul 2016 16:21:54 +0000 (UTC)
commit 57aed4e3302dd85be552561a4c3b1d46be7ff549
Author: raresv <rares visalom gmail com>
Date: Sun Jul 17 00:42:29 2016 +0300
Some cleaning up and minor fix to the notification part (the label was not hidden if a notification was
emitted)
data/resources/user-details.ui | 1 +
src/userList.js | 25 +++++++++++--------------
src/userTracker.js | 21 +++++++++++----------
3 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/data/resources/user-details.ui b/data/resources/user-details.ui
index c6e1f08..1b2a888 100644
--- a/data/resources/user-details.ui
+++ b/data/resources/user-details.ui
@@ -144,6 +144,7 @@
<property name="margin-start">20</property>
<property name="hexpand">True</property>
<property name="use-markup">True</property>
+ <property name="label" translatable="yes">Will notify if user appears online.</property>
<style>
<class name="dim-label" />
</style>
diff --git a/src/userList.js b/src/userList.js
index ace17d0..4f918f0 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -138,8 +138,6 @@ const UserDetails = new Lang.Class({
this._updateButtonVisibility();
this._detailsGrid.hide();
- this._notificationLabel.set_text("Will notify if user appears online.");
-
this._notificationIcon.no_show_all = true;
this._notificationLabel.no_show_all = true;
@@ -354,9 +352,9 @@ const UserPopover = new Lang.Class({
this._app = Gio.Application.get_default();
- this._notifyButton.bind_property('sensitive', this._notifyButton, 'visible', 0);
-
this.bind_property('visible', this._userDetails, 'expanded', 0);
+
+ this._notifyButton.bind_property('sensitive', this._notifyButton, 'visible', 0);
this._notifyButton.bind_property('active', this._userDetails, 'notifications-enabled',
GObject.BindingFlags.SYNC_CREATE);
this.show_all();
@@ -372,17 +370,20 @@ const UserPopover = new Lang.Class({
this._notifyButton.action_name = 'app.' + notifyActionName;
- /*TODO: these need to be disconnected when not used anymore*/
- this._userTracker.watchUser(this._room, this._nickname, Lang.bind(this, this._onNickStatusChanged));
- this._userTracker.connect("status-changed::"+this._nickname, Lang.bind(this, this._updateContents));
- this._userTracker.connect("notification-emitted::" + baseNick, Lang.bind(this,
this._onNotificationEmitted))
+ /*these need to be disconnected when not used anymore*/
+ if (this._localStatusChangedSignal)
+ this._userTracker.unwatchUser(this._room, this._localStatusChangedSignal);
+ this._localStatusChangedSignal = this._userTracker.watchUser(this._room, this._nickname,
Lang.bind(this, this._onNickStatusChanged));
+
+ if (this._globalStatusChangedSignal)
+ this._userTracker.disconnect(this._globalStatusChangedSignal);
+ this._globalStatusChangedSignal = this._userTracker.connect("status-changed::"+this._nickname,
Lang.bind(this, this._updateContents));
this._updateContents();
- /*TODO: disconnect when not needed anymore*/
+ /*disconnect when not needed anymore*/
if (this._contactsChangedSignal)
this._userTracker.disconnect(this._contactsChangedSignal);
-
this._contactsChangedSignal = this._userTracker.connect("contacts-changed::" + baseNick, () => {
this._userDetails.user = this._userTracker.lookupContact(this._nickname);
});
@@ -428,10 +429,6 @@ const UserPopover = new Lang.Class({
_onNickStatusChanged: function(nickName, status) {
this._updateContents();
- },
-
- _onNotificationEmitted: function() {
- this._notifyButton.set_active(false);
}
});
diff --git a/src/userTracker.js b/src/userTracker.js
index 14cf7c7..ce49194 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -70,9 +70,6 @@ const UserTracker = new Lang.Class({
},
'contacts-changed': {
flags: GObject.SignalFlags.DETAILED
- },
- 'notification-emitted': {
- flags: GObject.SignalFlags.DETAILED,
}
},
@@ -273,10 +270,14 @@ const UserTracker = new Lang.Class({
let notifyActionName = this.getNotifyActionName(member.alias);
let notifyAction = this._app.lookup_action(notifyActionName);
+
if (notifyAction.get_state().get_boolean()) {
this.emitWatchedUserNotification(room, member);
- notifyAction.enabled = false;
+ /*change state so that the button is not pressed if it reappears again*/
+ notifyAction.change_state(GLib.Variant.new('b', false));
}
+
+ notifyAction.enabled = false;
}
else
//log("[Local UserTracker] User " + member.alias + " is now available in room " +
member._room.channelName + " on " + this._account.get_display_name());
@@ -295,7 +296,7 @@ const UserTracker = new Lang.Class({
let baseNick = Polari.util_get_basenick(member.alias);
let contacts = map.get(baseNick) || [];
- /*TODO: i really don't like this search. maybe use a for loop?*/
+ /*TODO: maybe use a for loop?*/
let indexToDelete = contacts.map(c => c.alias + "|" + c._room.channelName).indexOf(member.alias +
"|" + member._room.channelName);
if (indexToDelete > -1) {
@@ -313,9 +314,8 @@ const UserTracker = new Lang.Class({
let notifyActionName = this.getNotifyActionName(member.alias);
let notifyAction = this._app.lookup_action(notifyActionName);
- if (!notifyAction.get_state().get_boolean()) {
- notifyAction.enabled = true;
- }
+
+ notifyAction.enabled = true;
}
if (this._globalContactMapping == map)
@@ -370,7 +370,7 @@ const UserTracker = new Lang.Class({
return this._handlerCounter - 1;
},
- unwatchUser: function(room, nick, handlerID) {
+ unwatchUser: function(room, handlerID) {
/*TODO: it wouldn't make sense to call _ensure() here, right?*/
/*TODO: rewrite into a single conditional?*/
@@ -400,12 +400,13 @@ const UserTracker = new Lang.Class({
this._app.send_notification('watched-user-notification', notification);
let baseNick = Polari.util_get_basenick(member.alias);
- this.emit("notification-emitted::" + baseNick);
},
getNotifyActionName: function(nickName) {
let notifyActionName = 'notify-user-' + this._account.get_path_suffix() + '-' +
Polari.util_get_basenick(nickName);
+ let isUserGloballyOnline = this.getNickStatus(nickName) == Tp.ConnectionPresenceType.AVAILABLE;
+
if (!this._app.lookup_action(notifyActionName)) {
let newNotifyActionProps = {
name: notifyActionName,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]