[gnome-shell] messageTray: Add optional datetime parameter to notifications
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] messageTray: Add optional datetime parameter to notifications
- Date: Mon, 27 Feb 2017 19:04:47 +0000 (UTC)
commit 0569bb18f5b4b594777a3af2f5a8271d24467a14
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Feb 27 00:14:09 2017 +0100
messageTray: Add optional datetime parameter to notifications
Since the last notification redesign, we've been showing the time a
notification was received in the calendar drop-down. However as the
time is in fact added by the NotificationSection, it is actually the
time a notification was added to the list. Usually that difference is
not significant, except when previously received notifications are
restored on startup.
In order to be able to address those cases, we need a time that is
associated with the notification itself, so add a datetime property
that defaults to the current time, but may be set from an optional
parameter as well.
https://bugzilla.gnome.org/show_bug.cgi?id=775799
js/ui/calendar.js | 8 ++++----
js/ui/messageTray.js | 6 ++++++
2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 2ed8126..70252e2 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -946,8 +946,8 @@ const NotificationSection = new Lang.Class({
!Main.sessionMode.isGreeter;
},
- _createTimeLabel: function() {
- let label = Util.createTimeLabel(new Date());
+ _createTimeLabel: function(datetime) {
+ let label = Util.createTimeLabel(datetime);
label.style_class = 'event-time',
label.x_align = Clutter.ActorAlign.END;
return label;
@@ -970,13 +970,13 @@ const NotificationSection = new Lang.Class({
_onNotificationAdded: function(source, notification) {
let message = new NotificationMessage(notification);
- message.setSecondaryActor(this._createTimeLabel());
+ message.setSecondaryActor(this._createTimeLabel(notification.datetime));
let isUrgent = notification.urgency == MessageTray.Urgency.CRITICAL;
let updatedId = notification.connect('updated', Lang.bind(this,
function() {
- message.setSecondaryActor(this._createTimeLabel());
+ message.setSecondaryActor(this._createTimeLabel(notification.datetime));
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.actor.mapped);
}));
let destroyId = notification.connect('destroy', Lang.bind(this,
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 4f1ab7f..fe1b4d8 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -368,6 +368,7 @@ const Notification = new Lang.Class({
secondaryGIcon: null,
bannerMarkup: false,
clear: false,
+ datetime: null,
soundName: null,
soundFile: null });
@@ -375,6 +376,11 @@ const Notification = new Lang.Class({
this.bannerBodyText = banner;
this.bannerBodyMarkup = params.bannerMarkup;
+ if (params.datetime)
+ this.datetime = params.datetime;
+ else
+ this.datetime = GLib.DateTime.new_now_local();
+
if (params.gicon || params.clear)
this.gicon = params.gicon;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]