[MessageTray] add support for notification actions

https://bugzilla.gnome.org/show_bug.cgi?id=606979
This commit is contained in:
Dan Winship
2010-02-01 15:41:22 -05:00
parent d20d815b45
commit e40063fc34
3 changed files with 61 additions and 1 deletions

View File

@ -124,6 +124,12 @@ NotificationDaemon.prototype = {
summary = GLib.markup_escape_text(summary, -1);
let notification = new MessageTray.Notification(source, summary, body);
if (actions.length) {
for (let i = 0; i < actions.length - 1; i += 2)
notification.addAction(actions[i], actions[i + 1]);
notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
}
source.notify(notification);
return id;
},
@ -137,7 +143,7 @@ NotificationDaemon.prototype = {
GetCapabilities: function() {
return [
// 'actions',
'actions',
'body',
// 'body-hyperlinks',
// 'body-images',
@ -157,11 +163,23 @@ NotificationDaemon.prototype = {
];
},
_actionInvoked: function(notification, action, source, id) {
this._emitActionInvoked(id, action);
source.destroy();
},
_emitNotificationClosed: function(id, reason) {
DBus.session.emit_signal('/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'NotificationClosed', 'uu',
[id, reason]);
},
_emitActionInvoked: function(id, action) {
DBus.session.emit_signal('/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'ActionInvoked', 'us',
[id, action]);
}
};