[gnome-shell] Fix invoking actions on notifications
- From: Marina Zhurakhinskaya <marinaz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Fix invoking actions on notifications
- Date: Wed, 14 Jul 2010 21:16:39 +0000 (UTC)
commit 5695c8b0aaf4caebe6059b58d8f80828f23bfcb8
Author: Marina Zhurakhinskaya <marinaz redhat com>
Date: Wed Jul 14 17:07:06 2010 -0400
Fix invoking actions on notifications
We need to only connect to 'action-invoked' on notification once
when the notification is created. We were accumulating callbacks
otherwise, which resulted, for example, in the Rhythmbox skipping
through multiple tracks when the 'Next' button was hit.
Always be sure to destroy the notification when its source is
destroyed, which is the case when an action is invoked.
Note that in the future, we might not want to destroy the source
for some notifications when an action is invoked. For example,
it makes sense to keep Rhythmbox in the tray while the music is
playing and allow the user to use the controls from the summary
notification too.
js/ui/messageTray.js | 2 ++
js/ui/notificationDaemon.js | 10 ++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 7141501..5fb8332 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -80,6 +80,8 @@ Notification.prototype = {
this.emit('dismissed');
}));
+ source.connect('destroy', Lang.bind(this, this.destroy));
+
this.actor = new St.Table({ name: 'notification',
reactive: true });
this.actor.connect('style-changed', Lang.bind(this, this._styleChanged));
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 026fb04..a6a55c5 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -209,9 +209,13 @@ NotificationDaemon.prototype = {
this._currentNotifications[id] = notification;
notification.connect('dismissed', Lang.bind(this,
function(n) {
- n.destroy();
this._emitNotificationClosed(n.id, NotificationClosedReason.DISMISSED);
}));
+ notification.connect('destroy', Lang.bind(this,
+ function(n) {
+ delete this._currentNotifications[id];
+ }));
+ notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
} else {
// passing in true as the last parameter will clear out extra actors,
// such as actions
@@ -221,7 +225,6 @@ NotificationDaemon.prototype = {
if (actions.length) {
for (let i = 0; i < actions.length - 1; i += 2)
notification.addButton(actions[i], actions[i + 1]);
- notification.connect('action-invoked', Lang.bind(this, this._actionInvoked, source, id));
}
notification.setUrgent(hints.urgency == Urgency.CRITICAL);
@@ -267,12 +270,11 @@ NotificationDaemon.prototype = {
},
_actionInvoked: function(notification, action, source, id) {
- this._emitActionInvoked(id, action);
source.destroy();
+ this._emitActionInvoked(id, action);
},
_emitNotificationClosed: function(id, reason) {
- delete this._currentNotifications[id];
DBus.session.emit_signal('/org/freedesktop/Notifications',
'org.freedesktop.Notifications',
'NotificationClosed', 'uu',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]