diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index d2eb30e3b..a028d3206 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -116,11 +116,6 @@ Notification.prototype = { this._capturedEventId = 0; this._keyPressId = 0; - source.connect('clicked', Lang.bind(this, - function() { - this.emit('dismissed'); - })); - source.connect('destroy', Lang.bind(this, this.destroy)); this.actor = new St.Table({ name: 'notification', @@ -130,7 +125,7 @@ Notification.prototype = { function (actor, event) { if (!this._actionArea || !this._actionArea.contains(event.get_source())) - this.source.clicked(); + this.emit('clicked'); })); // The first line should have the title, followed by the @@ -665,26 +660,26 @@ Source.prototype = { }, notify: function(notification) { - if (this.notification) + if (this.notification) { + this.notification.disconnect(this._notificationClickedId); this.notification.disconnect(this._notificationDestroyedId); + } this.notification = notification; + this._notificationClickedId = notification.connect('clicked', Lang.bind(this, this._notificationClicked)); this._notificationDestroyedId = notification.connect('destroy', Lang.bind(this, function () { if (this.notification == notification) { this.notification = null; this._notificationDestroyedId = 0; + this._notificationClickedId = 0; } })); this.emit('notify', notification); }, - clicked: function() { - this.emit('clicked'); - }, - destroy: function() { this.emit('destroy'); }, @@ -696,6 +691,10 @@ Source.prototype = { if (this._iconBin.child) this._iconBin.child.destroy(); this._iconBin.child = icon; + }, + + // Default implementation is to do nothing, but subclass can override + _notificationClicked: function(notification) { } }; Signals.addSignalMethods(Source.prototype); diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index bb37bfd6c..3e0bd6b46 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -173,10 +173,6 @@ NotificationDaemon.prototype = { let source = new Source(title, pid); this._sources[pid] = source; - source.connect('clicked', Lang.bind(this, - function() { - source.destroy(); - })); source.connect('destroy', Lang.bind(this, function() { delete this._sources[pid]; @@ -281,7 +277,7 @@ NotificationDaemon.prototype = { if (notification == null) { notification = new MessageTray.Notification(source, summary, body, { icon: iconActor }); ndata.notification = notification; - notification.connect('dismissed', Lang.bind(this, + notification.connect('clicked', Lang.bind(this, function(n) { this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED); })); @@ -433,9 +429,9 @@ Source.prototype = { this.useNotificationIcon = false; }, - clicked: function() { + _notificationClicked: function() { this.openApp(); - MessageTray.Source.prototype.clicked.call(this); + this.destroy(); }, openApp: function() { diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js index 9a4aaf9a9..d2269f6c2 100644 --- a/js/ui/telepathyClient.js +++ b/js/ui/telepathyClient.js @@ -484,7 +484,7 @@ Source.prototype = { this.ICON_SIZE); }, - clicked: function() { + _notificationClicked: function(notification) { channelDispatcher.EnsureChannelRemote(this._accountPath, { 'org.freedesktop.Telepathy.Channel.ChannelType': Telepathy.CHANNEL_TEXT_NAME, 'org.freedesktop.Telepathy.Channel.TargetHandle': this._targetHandle, @@ -492,8 +492,6 @@ Source.prototype = { global.get_current_time(), '', Lang.bind(this, this._gotChannelRequest)); - - MessageTray.Source.prototype.clicked.call(this); }, _gotChannelRequest: function (chanReqPath, ex) { diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js index d99045423..b740d8def 100644 --- a/js/ui/windowAttentionHandler.js +++ b/js/ui/windowAttentionHandler.js @@ -66,7 +66,6 @@ WindowAttentionHandler.prototype = { source = new Source(app, window); this._sources[appId] = source; Main.messageTray.add(source); - source.connect('clicked', Lang.bind(this, function() { source.destroy(); })); source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; })); } @@ -101,9 +100,8 @@ Source.prototype = { return this._app.create_icon_texture(this.ICON_SIZE); }, - clicked : function() { + _notificationClicked : function(notification) { Main.activateWindow(this._window); - MessageTray.Source.prototype.clicked.call(this); + this.destroy(); } - };