[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:
parent
077f0c56f1
commit
263261cc86
@ -70,6 +70,7 @@ Notification.prototype = {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.source = source;
|
this.source = source;
|
||||||
this._bannerBody = bannerBody;
|
this._bannerBody = bannerBody;
|
||||||
|
this.urgent = false;
|
||||||
|
|
||||||
source.connect('clicked', Lang.bind(this,
|
source.connect('clicked', Lang.bind(this,
|
||||||
function() {
|
function() {
|
||||||
@ -265,6 +266,10 @@ Notification.prototype = {
|
|||||||
button.connect('clicked', Lang.bind(this, function() { this.emit('action-invoked', id); }));
|
button.connect('clicked', Lang.bind(this, function() { this.emit('action-invoked', id); }));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setUrgent: function(urgent) {
|
||||||
|
this.urgent = urgent;
|
||||||
|
},
|
||||||
|
|
||||||
_styleChanged: function() {
|
_styleChanged: function() {
|
||||||
let [has_spacing, spacing] = this.actor.get_theme_node().get_length('spacing-columns', false);
|
let [has_spacing, spacing] = this.actor.get_theme_node().get_length('spacing-columns', false);
|
||||||
this._spacing = has_spacing ? spacing : 0;
|
this._spacing = has_spacing ? spacing : 0;
|
||||||
@ -611,6 +616,10 @@ MessageTray.prototype = {
|
|||||||
if (this._getNotification(notification.id, source) == null) {
|
if (this._getNotification(notification.id, source) == null) {
|
||||||
notification.connect('destroy',
|
notification.connect('destroy',
|
||||||
Lang.bind(this, this.removeNotification));
|
Lang.bind(this, this.removeNotification));
|
||||||
|
|
||||||
|
if (notification.urgent)
|
||||||
|
this._notificationQueue.unshift(notification);
|
||||||
|
else
|
||||||
this._notificationQueue.push(notification);
|
this._notificationQueue.push(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,6 +814,12 @@ MessageTray.prototype = {
|
|||||||
onComplete: this._showNotificationCompleted,
|
onComplete: this._showNotificationCompleted,
|
||||||
onCompleteScope: this
|
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() {
|
_showNotificationCompleted: function() {
|
||||||
|
@ -151,8 +151,11 @@ NotificationDaemon.prototype = {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source may be null if we have never received a notification from
|
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
|
||||||
// this app or if all notifications from this app have been acknowledged.
|
|
||||||
|
// 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) {
|
if (source == null) {
|
||||||
source = new Source(this._sourceId(appName), icon, hints);
|
source = new Source(this._sourceId(appName), icon, hints);
|
||||||
Main.messageTray.add(source);
|
Main.messageTray.add(source);
|
||||||
@ -211,6 +214,8 @@ NotificationDaemon.prototype = {
|
|||||||
notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
|
notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
notification.setUrgent(hints.urgency == Urgency.CRITICAL);
|
||||||
|
|
||||||
source.notify(notification);
|
source.notify(notification);
|
||||||
return id;
|
return id;
|
||||||
},
|
},
|
||||||
@ -290,8 +295,6 @@ Source.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
update: function(icon, hints) {
|
update: function(icon, hints) {
|
||||||
hints = Params.parse(hints, { urgency: Urgency.NORMAL }, true);
|
|
||||||
|
|
||||||
this._icon = icon;
|
this._icon = icon;
|
||||||
this._iconData = hints.icon_data;
|
this._iconData = hints.icon_data;
|
||||||
this._urgency = hints.urgency;
|
this._urgency = hints.urgency;
|
||||||
|
Loading…
Reference in New Issue
Block a user