notification: Stop using old setter methods of MessageTray.Notification

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3173>
This commit is contained in:
Julian Sparber 2024-02-14 11:35:03 +01:00 committed by Florian Müllner
parent 9ac4c7da53
commit 1d1d9806f3
8 changed files with 40 additions and 28 deletions

View File

@ -278,10 +278,10 @@ async function _initializeUI() {
source, source,
title: _('System was put in unsafe mode'), title: _('System was put in unsafe mode'),
body: _('Apps now have unrestricted access'), body: _('Apps now have unrestricted access'),
isTransient: true,
}); });
notification.addAction(_('Undo'), notification.addAction(_('Undo'),
() => (global.context.unsafe_mode = false)); () => (global.context.unsafe_mode = false));
notification.setTransient(true);
source.addNotification(notification); source.addNotification(notification);
}); });
@ -620,8 +620,8 @@ export function notify(msg, details) {
source, source,
title: msg, title: msg,
body: details, body: details,
isTransient: true,
}); });
notification.setTransient(true);
source.addNotification(notification); source.addNotification(notification);
} }

View File

@ -237,24 +237,24 @@ class FdoNotificationDaemon {
switch (hints.urgency) { switch (hints.urgency) {
case Urgency.LOW: case Urgency.LOW:
notification.setUrgency(MessageTray.Urgency.LOW); notification.urgency = MessageTray.Urgency.LOW;
break; break;
case Urgency.NORMAL: case Urgency.NORMAL:
notification.setUrgency(MessageTray.Urgency.NORMAL); notification.urgency = MessageTray.Urgency.NORMAL;
break; break;
case Urgency.CRITICAL: case Urgency.CRITICAL:
notification.setUrgency(MessageTray.Urgency.CRITICAL); notification.urgency = MessageTray.Urgency.CRITICAL;
break; break;
} }
notification.setResident(!!hints.resident); notification.resident = !!hints.resident;
// 'transient' is a reserved keyword in JS, so we have to retrieve the value // '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 // 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'; let privacyScope = hints['x-gnome-privacy-scope'] || 'user';
notification.setPrivacyScope(privacyScope === 'system' notification.privacyScope = privacyScope === 'system'
? MessageTray.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 // Only fallback to 'app-icon' when the source doesn't have a valid app
const sourceGIcon = source.app ? null : this._iconForNotificationData(appIcon); const sourceGIcon = source.app ? null : this._iconForNotificationData(appIcon);
@ -424,13 +424,13 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
if (priority) { if (priority) {
let urgency = PRIORITY_URGENCY_MAP[priority.unpack()]; 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) { } else if (urgent) {
this.setUrgency(urgent.unpack() this.urgency = urgent.unpack()
? MessageTray.Urgency.CRITICAL ? MessageTray.Urgency.CRITICAL
: MessageTray.Urgency.NORMAL); : MessageTray.Urgency.NORMAL;
} else { } else {
this.setUrgency(MessageTray.Urgency.NORMAL); this.urgency = MessageTray.Urgency.NORMAL;
} }
if (buttons) { if (buttons) {

View File

@ -42,9 +42,9 @@ class ShellInfo {
this._notification = new MessageTray.Notification({ this._notification = new MessageTray.Notification({
source, source,
title: text, title: text,
isTransient: true,
forFeedback,
}); });
this._notification.setTransient(true);
this._notification.setForFeedback(forFeedback);
this._notification.connect('destroy', () => delete this._notification); this._notification.connect('destroy', () => delete this._notification);
} else { } else {
this._notification.update(text, null, {clear: true}); this._notification.update(text, null, {clear: true});

View File

@ -2092,8 +2092,8 @@ export const ScreenshotUI = GObject.registerClass({
title, title,
// Translators: notification body when a screencast was recorded. // Translators: notification body when a screencast was recorded.
body: this._screencastPath ? _('Click here to view the video.') : '', body: this._screencastPath ? _('Click here to view the video.') : '',
isTransient: true,
}); });
notification.setTransient(true);
if (this._screencastPath) { if (this._screencastPath) {
const file = Gio.file_new_for_path(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.'), body: _('You can paste the image from the clipboard.'),
datetime: time, datetime: time,
gicon: content, gicon: content,
isTransient: true,
}); });
if (!disableSaveToDisk) { if (!disableSaveToDisk) {
@ -2363,7 +2364,6 @@ function _storeScreenshot(bytes, pixbuf) {
}); });
} }
notification.setTransient(true);
Main.messageTray.add(source); Main.messageTray.add(source);
source.addNotification(notification); source.addNotification(notification);

View File

@ -195,10 +195,14 @@ export class ShellMountOperation {
this._notification?.destroy(); this._notification?.destroy();
const source = MessageTray.getSystemSource(); 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); this._notification.connect('destroy', () => delete this._notification);
source.addNotification(this._notification); source.addNotification(this._notification);
} }

View File

@ -2034,10 +2034,10 @@ class Indicator extends SystemIndicator {
source, source,
title: _('Connection failed'), title: _('Connection failed'),
body: _('Activation of network 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.connect('destroy',
() => (this._notification = null)); () => (this._notification = null));

View File

@ -258,9 +258,13 @@ class Indicator extends SystemIndicator {
this._notification.destroy(); this._notification.destroy();
const source = MessageTray.getSystemSource(); const source = MessageTray.getSystemSource();
this._notification = new MessageTray.Notification({source, title, body}); this._notification = new MessageTray.Notification({
this._notification.iconName = 'thunderbolt-symbolic'; source,
this._notification.setUrgency(MessageTray.Urgency.HIGH); title,
body,
iconName: 'thunderbolt-symbolic',
urgency: MessageTray.Urgency.HIGH,
});
this._notification.connect('destroy', () => { this._notification.connect('destroy', () => {
this._notification = null; this._notification = null;
}); });

View File

@ -39,11 +39,15 @@ export class WindowAttentionHandler {
let [title, body] = this._getTitleAndBanner(app, window); 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', () => { notification.connect('activated', () => {
source.open(); source.open();
}); });
notification.setForFeedback(true);
source.addNotification(notification); source.addNotification(notification);