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,
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);
}

View File

@ -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) {

View File

@ -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});

View File

@ -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);

View File

@ -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);
}

View File

@ -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));

View File

@ -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;
});

View File

@ -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);