calendar: Update notification timestamps/positions on updates

Currently both the timestamp and the position in the notification list
are static once a notification has been added; however notifications may
be updated later, in which case those properties should be reevaluated.

https://bugzilla.gnome.org/show_bug.cgi?id=745132
This commit is contained in:
Florian Müllner 2015-02-26 00:26:13 +01:00
parent d8505934e8
commit 39a57eea4d

View File

@ -1327,6 +1327,28 @@ const MessageListSection = new Lang.Class({
transition: 'easeOutQuad' }); transition: 'easeOutQuad' });
}, },
moveMessage: function(message, index, animate) {
let obj = this._messages.get(message);
if (!animate) {
this._list.set_child_at_index(obj.container, index);
return;
}
let onComplete = Lang.bind(this, function() {
this._list.set_child_at_index(obj.container, index);
Tweener.addTween(obj.container, { scale_x: 1,
scale_y: 1,
time: MESSAGE_ANIMATION_TIME,
transition: 'easeOutQuad' });
});
Tweener.addTween(obj.container, { scale_x: 0,
scale_y: 0,
time: MESSAGE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: onComplete });
},
removeMessage: function(message, animate) { removeMessage: function(message, animate) {
let obj = this._messages.get(message); let obj = this._messages.get(message);
@ -1556,6 +1578,13 @@ const NotificationSection = new Lang.Class({
!Main.sessionMode.isGreeter; !Main.sessionMode.isGreeter;
}, },
_createTimeLabel: function() {
let label = Util.createTimeLabel(new Date());
label.style_class = 'event-time',
label.x_align = Clutter.ActorAlign.END;
return label;
},
_sourceAdded: function(tray, source) { _sourceAdded: function(tray, source) {
let obj = { let obj = {
destroyId: 0, destroyId: 0,
@ -1573,22 +1602,26 @@ const NotificationSection = new Lang.Class({
_onNotificationAdded: function(source, notification) { _onNotificationAdded: function(source, notification) {
let message = new NotificationMessage(notification); let message = new NotificationMessage(notification);
message.setSecondaryActor(this._createTimeLabel());
let timeLabel = Util.createTimeLabel(new Date());
timeLabel.style_class = 'event-time',
timeLabel.x_align = Clutter.ActorAlign.END;
message.setSecondaryActor(timeLabel);
let isUrgent = notification.urgency == MessageTray.Urgency.CRITICAL; let isUrgent = notification.urgency == MessageTray.Urgency.CRITICAL;
let updatedId = notification.connect('updated', Lang.bind(this,
function() {
message.setSecondaryActor(this._createTimeLabel());
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.actor.mapped);
}));
let destroyId = notification.connect('destroy', Lang.bind(this,
function() {
notification.disconnect(destroyId);
notification.disconnect(updatedId);
if (isUrgent)
this._nUrgent--;
}));
if (isUrgent) { if (isUrgent) {
// Keep track of urgent notifications to keep them on top // Keep track of urgent notifications to keep them on top
this._nUrgent++; this._nUrgent++;
let id = notification.connect('destroy', Lang.bind(this,
function() {
notification.disconnect(id);
this._nUrgent--;
}));
} else if (this.mapped) { } else if (this.mapped) {
// Only acknowledge non-urgent notifications in case it // Only acknowledge non-urgent notifications in case it
// has important actions that are inaccessible when not // has important actions that are inaccessible when not