[gnome-shell] MessageTray: untangle click notifications
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] MessageTray: untangle click notifications
- Date: Tue, 12 Oct 2010 21:22:09 +0000 (UTC)
commit de16108dff4dce105d1194d8a5cd18e8af29f9aa
Author: Dan Winship <danw gnome org>
Date: Thu Sep 30 16:41:38 2010 -0400
MessageTray: untangle click notifications
Previously, when you clicked on a notification, it would call
this.source.clicked(), which would emit a 'clicked' signal on the
source, and then various other stuff would happen from there. This
used to make a little bit of sense, when clicking on a notification
was supposed to do the same thing as clicking on its source, but makes
less sense now, when clicking on the source itself *doesn't* call
source.clicked()...
Change it so that when you click on a notification, the notification
emits 'clicked' itself, and the source notices that and calls its
notificationClicked() method, and the various source subclasses do
what they need to do with that, and Source no longer has a clicked
method/signal.
https://bugzilla.gnome.org/show_bug.cgi?id=631042
js/ui/messageTray.js | 21 ++++++++++-----------
js/ui/notificationDaemon.js | 10 +++-------
js/ui/telepathyClient.js | 4 +---
js/ui/windowAttentionHandler.js | 6 ++----
4 files changed, 16 insertions(+), 25 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index d2eb30e..a028d32 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 bb37bfd..3e0bd6b 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 9a4aaf9..d2269f6 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 d990454..b740d8d 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();
}
-
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]