messageTray: Don't always open the source when clicking on the notification

Some consumers may not always want to open the app, so make clients that
want to do this explicitly connect to the 'clicked' signal.

https://bugzilla.gnome.org/show_bug.cgi?id=710137
This commit is contained in:
Jasper St. Pierre
2013-10-13 23:20:50 -04:00
parent 43f4682ec4
commit 8ee0ef2cde
4 changed files with 31 additions and 19 deletions

View File

@ -422,15 +422,15 @@ const NotificationDaemon = new Lang.Class({
soundName: hints['sound-name'] });
notification.setImage(image);
let hasDefaultAction = false;
if (actions.length) {
let useActionIcons = (hints['action-icons'] == true);
for (let i = 0; i < actions.length - 1; i += 2) {
let [actionId, label] = [actions[i], actions[i+1]];
if (actionId == 'default') {
notification.connect('clicked', Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, "default");
}));
hasDefaultAction = true;
} else {
notification.addButton(this._makeButton(id, label, useActionIcons), Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, actionId);
@ -438,6 +438,17 @@ const NotificationDaemon = new Lang.Class({
}
}
}
if (hasDefaultAction) {
notification.connect('clicked', Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, 'default');
}));
} else {
notification.connect('clicked', Lang.bind(this, function() {
source.open();
}));
}
switch (hints.urgency) {
case Urgency.LOW:
notification.setUrgency(MessageTray.Urgency.LOW);