[gnome-shell] [MessageTray] remove Notification IDs
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] [MessageTray] remove Notification IDs
- Date: Thu, 26 Aug 2010 15:01:13 +0000 (UTC)
commit 8f6a7f393dff22666193cda1b76b40df22348712
Author: Dan Winship <danw gnome org>
Date: Wed Aug 11 09:43:40 2010 -0400
[MessageTray] remove Notification IDs
Notification daemon notifications have IDs, but other kinds don't
necessarily, and the generic code doesn't need to bother with it.
https://bugzilla.gnome.org/show_bug.cgi?id=627303
js/ui/messageTray.js | 24 ++++++++----------------
js/ui/notificationDaemon.js | 4 ++--
js/ui/telepathyClient.js | 10 +++++-----
js/ui/windowAttentionHandler.js | 2 +-
4 files changed, 16 insertions(+), 24 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index 6bbd644..990320f 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -40,7 +40,6 @@ function _cleanMarkup(text) {
}
// Notification:
-// @id: the notification's id
// @source: the notification's Source
// @title: the title
// @banner: the banner text
@@ -64,13 +63,12 @@ function _cleanMarkup(text) {
// of the notification (as with addBody()) when the banner is expanded.
// In this case, if @banner is too long to fit in the single-line mode,
// the notification will be made expandable automatically.
-function Notification(id, source, title, banner, bannerBody) {
- this._init(id, source, title, banner, bannerBody);
+function Notification(source, title, banner, bannerBody) {
+ this._init(source, title, banner, bannerBody);
}
Notification.prototype = {
- _init: function(id, source, title, banner, bannerBody) {
- this.id = id;
+ _init: function(source, title, banner, bannerBody) {
this.source = source;
this._bannerBody = bannerBody;
this.urgent = false;
@@ -949,16 +947,10 @@ MessageTray.prototype = {
this._notificationQueue.splice(index, 1);
},
- _getNotification: function(id, source) {
- if (this._notification && this._notification.id == id)
- return this._notification;
-
- for (let i = 0; i < this._notificationQueue.length; i++) {
- if (this._notificationQueue[i].id == id && this._notificationQueue[i].source == source)
- return this._notificationQueue[i];
- }
-
- return null;
+ _hasNotification: function(notification) {
+ if (this._notification == notification)
+ return true;
+ return this._notificationQueue.indexOf(notification) != -1;
},
lock: function() {
@@ -977,7 +969,7 @@ MessageTray.prototype = {
if (notification == this._summaryNotification)
return;
- if (this._getNotification(notification.id, source) == null) {
+ if (!this._hasNotification(notification)) {
notification.connect('destroy',
Lang.bind(this, this.removeNotification));
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index 4e78022..86cfab6 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -207,11 +207,11 @@ NotificationDaemon.prototype = {
if (notification == null) {
id = nextNotificationId++;
- notification = new MessageTray.Notification(id, source, summary, body, true);
+ notification = new MessageTray.Notification(source, summary, body, true);
this._currentNotifications[id] = notification;
notification.connect('dismissed', Lang.bind(this,
function(n) {
- this._emitNotificationClosed(n.id, NotificationClosedReason.DISMISSED);
+ this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
}));
notification.connect('destroy', Lang.bind(this,
function(n) {
diff --git a/js/ui/telepathyClient.js b/js/ui/telepathyClient.js
index 722dffc..49504fa 100644
--- a/js/ui/telepathyClient.js
+++ b/js/ui/telepathyClient.js
@@ -522,7 +522,7 @@ Source.prototype = {
Main.messageTray.add(this);
if (!this._notification)
- this._notification = new Notification(this._targetId, this);
+ this._notification = new Notification(this);
},
_messageReceived: function(channel, id, timestamp, sender,
@@ -568,15 +568,15 @@ Source.prototype = {
}
};
-function Notification(id, source) {
- this._init(id, source);
+function Notification(source) {
+ this._init(source);
}
Notification.prototype = {
__proto__: MessageTray.Notification.prototype,
- _init: function(id, source) {
- MessageTray.Notification.prototype._init.call(this, id, source, source.title);
+ _init: function(source) {
+ MessageTray.Notification.prototype._init.call(this, source, source.title);
this._responseEntry = new St.Entry({ style_class: 'chat-response' });
this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated));
diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js
index fa8aefa..f020ce5 100644
--- a/js/ui/windowAttentionHandler.js
+++ b/js/ui/windowAttentionHandler.js
@@ -70,7 +70,7 @@ WindowAttentionHandler.prototype = {
source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; }));
}
- let notification = new MessageTray.Notification(window.get_startup_id(), source, this._getTitle(app, window), this._getBanner(app, window), true);
+ let notification = new MessageTray.Notification(source, this._getTitle(app, window), this._getBanner(app, window), true);
source.notify(notification);
window.connect('notify::title', Lang.bind(this, function(win) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]