From 1d1d9806f34ac38b3228ad4b5fc0dc645c99e193 Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Wed, 14 Feb 2024 11:35:03 +0100 Subject: [PATCH] notification: Stop using old setter methods of MessageTray.Notification Part-of: --- js/ui/main.js | 4 ++-- js/ui/notificationDaemon.js | 22 +++++++++++----------- js/ui/overview.js | 4 ++-- js/ui/screenshot.js | 4 ++-- js/ui/shellMountOperation.js | 10 +++++++--- js/ui/status/network.js | 6 +++--- js/ui/status/thunderbolt.js | 10 +++++++--- js/ui/windowAttentionHandler.js | 8 ++++++-- 8 files changed, 40 insertions(+), 28 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index 8a3c177d9..eeb83c9b1 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -278,10 +278,10 @@ async function _initializeUI() { source, title: _('System was put in unsafe mode'), body: _('Apps now have unrestricted access'), + isTransient: true, }); notification.addAction(_('Undo'), () => (global.context.unsafe_mode = false)); - notification.setTransient(true); source.addNotification(notification); }); @@ -620,8 +620,8 @@ export function notify(msg, details) { source, title: msg, body: details, + isTransient: true, }); - notification.setTransient(true); source.addNotification(notification); } diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index a3b46b863..65efc0f20 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -237,24 +237,24 @@ class FdoNotificationDaemon { switch (hints.urgency) { case Urgency.LOW: - notification.setUrgency(MessageTray.Urgency.LOW); + notification.urgency = MessageTray.Urgency.LOW; break; case Urgency.NORMAL: - notification.setUrgency(MessageTray.Urgency.NORMAL); + notification.urgency = MessageTray.Urgency.NORMAL; break; case Urgency.CRITICAL: - notification.setUrgency(MessageTray.Urgency.CRITICAL); + notification.urgency = MessageTray.Urgency.CRITICAL; break; } - notification.setResident(!!hints.resident); + notification.resident = !!hints.resident; // 'transient' is a reserved keyword in JS, so we have to retrieve the value // of the 'transient' hint with hints['transient'] rather than hints.transient - notification.setTransient(!!hints['transient']); + notification.isTransient = !!hints['transient']; let privacyScope = hints['x-gnome-privacy-scope'] || 'user'; - notification.setPrivacyScope(privacyScope === 'system' + notification.privacyScope = privacyScope === 'system' ? MessageTray.PrivacyScope.SYSTEM - : MessageTray.PrivacyScope.USER); + : MessageTray.PrivacyScope.USER; // Only fallback to 'app-icon' when the source doesn't have a valid app const sourceGIcon = source.app ? null : this._iconForNotificationData(appIcon); @@ -424,13 +424,13 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification { if (priority) { let urgency = PRIORITY_URGENCY_MAP[priority.unpack()]; - this.setUrgency(urgency !== undefined ? urgency : MessageTray.Urgency.NORMAL); + this.urgency = urgency !== undefined ? urgency : MessageTray.Urgency.NORMAL; } else if (urgent) { - this.setUrgency(urgent.unpack() + this.urgency = urgent.unpack() ? MessageTray.Urgency.CRITICAL - : MessageTray.Urgency.NORMAL); + : MessageTray.Urgency.NORMAL; } else { - this.setUrgency(MessageTray.Urgency.NORMAL); + this.urgency = MessageTray.Urgency.NORMAL; } if (buttons) { diff --git a/js/ui/overview.js b/js/ui/overview.js index b16f5a26b..8d7001ecb 100644 --- a/js/ui/overview.js +++ b/js/ui/overview.js @@ -42,9 +42,9 @@ class ShellInfo { this._notification = new MessageTray.Notification({ source, title: text, + isTransient: true, + forFeedback, }); - this._notification.setTransient(true); - this._notification.setForFeedback(forFeedback); this._notification.connect('destroy', () => delete this._notification); } else { this._notification.update(text, null, {clear: true}); diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index d65dc82f3..5d21b7431 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -2092,8 +2092,8 @@ export const ScreenshotUI = GObject.registerClass({ title, // Translators: notification body when a screencast was recorded. body: this._screencastPath ? _('Click here to view the video.') : '', + isTransient: true, }); - notification.setTransient(true); if (this._screencastPath) { const file = Gio.file_new_for_path(this._screencastPath); @@ -2337,6 +2337,7 @@ function _storeScreenshot(bytes, pixbuf) { body: _('You can paste the image from the clipboard.'), datetime: time, gicon: content, + isTransient: true, }); if (!disableSaveToDisk) { @@ -2363,7 +2364,6 @@ function _storeScreenshot(bytes, pixbuf) { }); } - notification.setTransient(true); Main.messageTray.add(source); source.addNotification(notification); diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js index 24a38c8b6..00e577482 100644 --- a/js/ui/shellMountOperation.js +++ b/js/ui/shellMountOperation.js @@ -195,10 +195,14 @@ export class ShellMountOperation { this._notification?.destroy(); const source = MessageTray.getSystemSource(); - this._notification = new MessageTray.Notification({source, title, body}); + this._notification = new MessageTray.Notification({ + source, + title, + body, + isTransient: true, + iconName: 'media-removable-symbolic', + }); - this._notification.setTransient(true); - this._notification.iconName = 'media-removable-symbolic'; this._notification.connect('destroy', () => delete this._notification); source.addNotification(this._notification); } diff --git a/js/ui/status/network.js b/js/ui/status/network.js index ae25af6f3..404733b74 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -2034,10 +2034,10 @@ class Indicator extends SystemIndicator { source, title: _('Connection failed'), body: _('Activation of network connection failed'), + iconName: 'network-error-symbolic', + urgency: MessageTray.Urgency.HIGH, + isTransient: true, }); - this._notification.iconName = 'network-error-symbolic'; - this._notification.setUrgency(MessageTray.Urgency.HIGH); - this._notification.setTransient(true); this._notification.connect('destroy', () => (this._notification = null)); diff --git a/js/ui/status/thunderbolt.js b/js/ui/status/thunderbolt.js index e70ca2435..383104138 100644 --- a/js/ui/status/thunderbolt.js +++ b/js/ui/status/thunderbolt.js @@ -258,9 +258,13 @@ class Indicator extends SystemIndicator { this._notification.destroy(); const source = MessageTray.getSystemSource(); - this._notification = new MessageTray.Notification({source, title, body}); - this._notification.iconName = 'thunderbolt-symbolic'; - this._notification.setUrgency(MessageTray.Urgency.HIGH); + this._notification = new MessageTray.Notification({ + source, + title, + body, + iconName: 'thunderbolt-symbolic', + urgency: MessageTray.Urgency.HIGH, + }); this._notification.connect('destroy', () => { this._notification = null; }); diff --git a/js/ui/windowAttentionHandler.js b/js/ui/windowAttentionHandler.js index 7c3e53fbf..9ca857a3e 100644 --- a/js/ui/windowAttentionHandler.js +++ b/js/ui/windowAttentionHandler.js @@ -39,11 +39,15 @@ export class WindowAttentionHandler { let [title, body] = this._getTitleAndBanner(app, window); - let notification = new MessageTray.Notification({source, title, body}); + let notification = new MessageTray.Notification({ + source, + title, + body, + forFeedback: true, + }); notification.connect('activated', () => { source.open(); }); - notification.setForFeedback(true); source.addNotification(notification);