[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
This commit is contained in:
Dan Winship 2010-08-11 09:43:40 -04:00
parent d3031b406a
commit 8f6a7f393d
4 changed files with 16 additions and 24 deletions

View File

@ -40,7 +40,6 @@ function _cleanMarkup(text) {
} }
// Notification: // Notification:
// @id: the notification's id
// @source: the notification's Source // @source: the notification's Source
// @title: the title // @title: the title
// @banner: the banner text // @banner: the banner text
@ -64,13 +63,12 @@ function _cleanMarkup(text) {
// of the notification (as with addBody()) when the banner is expanded. // 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, // In this case, if @banner is too long to fit in the single-line mode,
// the notification will be made expandable automatically. // the notification will be made expandable automatically.
function Notification(id, source, title, banner, bannerBody) { function Notification(source, title, banner, bannerBody) {
this._init(id, source, title, banner, bannerBody); this._init(source, title, banner, bannerBody);
} }
Notification.prototype = { Notification.prototype = {
_init: function(id, source, title, banner, bannerBody) { _init: function(source, title, banner, bannerBody) {
this.id = id;
this.source = source; this.source = source;
this._bannerBody = bannerBody; this._bannerBody = bannerBody;
this.urgent = false; this.urgent = false;
@ -949,16 +947,10 @@ MessageTray.prototype = {
this._notificationQueue.splice(index, 1); this._notificationQueue.splice(index, 1);
}, },
_getNotification: function(id, source) { _hasNotification: function(notification) {
if (this._notification && this._notification.id == id) if (this._notification == notification)
return this._notification; return true;
return this._notificationQueue.indexOf(notification) != -1;
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;
}, },
lock: function() { lock: function() {
@ -977,7 +969,7 @@ MessageTray.prototype = {
if (notification == this._summaryNotification) if (notification == this._summaryNotification)
return; return;
if (this._getNotification(notification.id, source) == null) { if (!this._hasNotification(notification)) {
notification.connect('destroy', notification.connect('destroy',
Lang.bind(this, this.removeNotification)); Lang.bind(this, this.removeNotification));

View File

@ -207,11 +207,11 @@ NotificationDaemon.prototype = {
if (notification == null) { if (notification == null) {
id = nextNotificationId++; id = nextNotificationId++;
notification = new MessageTray.Notification(id, source, summary, body, true); notification = new MessageTray.Notification(source, summary, body, true);
this._currentNotifications[id] = notification; this._currentNotifications[id] = notification;
notification.connect('dismissed', Lang.bind(this, notification.connect('dismissed', Lang.bind(this,
function(n) { function(n) {
this._emitNotificationClosed(n.id, NotificationClosedReason.DISMISSED); this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
})); }));
notification.connect('destroy', Lang.bind(this, notification.connect('destroy', Lang.bind(this,
function(n) { function(n) {

View File

@ -522,7 +522,7 @@ Source.prototype = {
Main.messageTray.add(this); Main.messageTray.add(this);
if (!this._notification) if (!this._notification)
this._notification = new Notification(this._targetId, this); this._notification = new Notification(this);
}, },
_messageReceived: function(channel, id, timestamp, sender, _messageReceived: function(channel, id, timestamp, sender,
@ -568,15 +568,15 @@ Source.prototype = {
} }
}; };
function Notification(id, source) { function Notification(source) {
this._init(id, source); this._init(source);
} }
Notification.prototype = { Notification.prototype = {
__proto__: MessageTray.Notification.prototype, __proto__: MessageTray.Notification.prototype,
_init: function(id, source) { _init: function(source) {
MessageTray.Notification.prototype._init.call(this, id, source, source.title); MessageTray.Notification.prototype._init.call(this, source, source.title);
this._responseEntry = new St.Entry({ style_class: 'chat-response' }); this._responseEntry = new St.Entry({ style_class: 'chat-response' });
this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated)); this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated));

View File

@ -70,7 +70,7 @@ WindowAttentionHandler.prototype = {
source.connect('destroy', Lang.bind(this, function() { delete this._sources[appId]; })); 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); source.notify(notification);
window.connect('notify::title', Lang.bind(this, function(win) { window.connect('notify::title', Lang.bind(this, function(win) {