messageTray: Split out the notification's destroy handler

This is complex enough to split out.

https://bugzilla.gnome.org/show_bug.cgi?id=710115
This commit is contained in:
Jasper St. Pierre 2013-10-13 21:52:44 -04:00
parent 99cf4e5787
commit 25fd23e703

View File

@ -1406,23 +1406,24 @@ const Source = new Lang.Class({
return this._mainIcon.actor; return this._mainIcon.actor;
}, },
_onNotificationDestroy: function(notification) {
let index = this.notifications.indexOf(notification);
if (index < 0)
return;
this.notifications.splice(index, 1);
if (this.notifications.length == 0)
this._lastNotificationRemoved();
this.countUpdated();
},
pushNotification: function(notification) { pushNotification: function(notification) {
if (this.notifications.indexOf(notification) >= 0) if (this.notifications.indexOf(notification) >= 0)
return; return;
notification.connect('clicked', Lang.bind(this, this.open)); notification.connect('clicked', Lang.bind(this, this.open));
notification.connect('destroy', Lang.bind(this, notification.connect('destroy', Lang.bind(this, this._onNotificationDestroy));
function () {
let index = this.notifications.indexOf(notification);
if (index < 0)
return;
this.notifications.splice(index, 1);
if (this.notifications.length == 0)
this._lastNotificationRemoved();
this.countUpdated();
}));
this.notifications.push(notification); this.notifications.push(notification);
this.emit('notification-added', notification); this.emit('notification-added', notification);