messageTray: Make addButton/addAction take a callback

This is a much simpler API for consumers to manage.

https://bugzilla.gnome.org/show_bug.cgi?id=710137
This commit is contained in:
Jasper St. Pierre
2013-10-13 23:06:09 -04:00
parent 5f081b8f8d
commit 43f4682ec4
5 changed files with 99 additions and 137 deletions

View File

@ -389,10 +389,6 @@ const NotificationDaemon = new Lang.Class({
}
this._emitNotificationClosed(ndata.id, notificationClosedReason);
}));
notification.connect('action-invoked', Lang.bind(this,
function(n, actionId) {
this._emitActionInvoked(ndata.id, actionId);
}));
}
// Mark music notifications so they can be shown in the screen shield
@ -432,12 +428,13 @@ const NotificationDaemon = new Lang.Class({
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");
}));
notification.connect('clicked', Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, "default");
}));
} else {
notification.addButton(actionId, this._makeButton(id, label, useActionIcons));
notification.addButton(this._makeButton(id, label, useActionIcons), Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, actionId);
}));
}
}
}
@ -659,7 +656,7 @@ const Source = new Lang.Class({
this.parent(title);
},
open: function(notification) {
open: function() {
this.openApp();
this.destroyNonResidentNotifications();
},