[MessageTray] handle "urgent" notifications specially

Urgent notifications jump to the front of the tray's notification
queue, and come up pre-expanded.

https://bugzilla.gnome.org/show_bug.cgi?id=611612
This commit is contained in:
Dan Winship 2010-04-28 15:34:27 -04:00
parent 077f0c56f1
commit 263261cc86
2 changed files with 23 additions and 5 deletions

View File

@ -70,6 +70,7 @@ Notification.prototype = {
this.id = id;
this.source = source;
this._bannerBody = bannerBody;
this.urgent = false;
source.connect('clicked', Lang.bind(this,
function() {
@ -265,6 +266,10 @@ Notification.prototype = {
button.connect('clicked', Lang.bind(this, function() { this.emit('action-invoked', id); }));
},
setUrgent: function(urgent) {
this.urgent = urgent;
},
_styleChanged: function() {
let [has_spacing, spacing] = this.actor.get_theme_node().get_length('spacing-columns', false);
this._spacing = has_spacing ? spacing : 0;
@ -611,7 +616,11 @@ MessageTray.prototype = {
if (this._getNotification(notification.id, source) == null) {
notification.connect('destroy',
Lang.bind(this, this.removeNotification));
this._notificationQueue.push(notification);
if (notification.urgent)
this._notificationQueue.unshift(notification);
else
this._notificationQueue.push(notification);
}
this._updateState();
@ -805,6 +814,12 @@ MessageTray.prototype = {
onComplete: this._showNotificationCompleted,
onCompleteScope: this
});
if (this._notification.urgent) {
// This will overwrite the y tween, but leave the opacity
// tween, and so the onComplete will remain as well.
this._expandNotification();
}
},
_showNotificationCompleted: function() {

View File

@ -151,8 +151,11 @@ NotificationDaemon.prototype = {
return id;
}
// Source may be null if we have never received a notification from
// this app or if all notifications from this app have been acknowledged.
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
// Source may be null if we have never received a notification
// from this app or if all notifications from this app have
// been acknowledged.
if (source == null) {
source = new Source(this._sourceId(appName), icon, hints);
Main.messageTray.add(source);
@ -211,6 +214,8 @@ NotificationDaemon.prototype = {
notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
}
notification.setUrgent(hints.urgency == Urgency.CRITICAL);
source.notify(notification);
return id;
},
@ -290,8 +295,6 @@ Source.prototype = {
},
update: function(icon, hints) {
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
this._icon = icon;
this._iconData = hints.icon_data;
this._urgency = hints.urgency;