messageTray: Only take params in Notification
constructor
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3173>
This commit is contained in:
parent
251a5e9d20
commit
d54219c098
@ -187,10 +187,10 @@ class AutorunDispatcher {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const source = MessageTray.getSystemSource();
|
const source = MessageTray.getSystemSource();
|
||||||
const notification = new MessageTray.Notification(
|
const notification = new MessageTray.Notification({
|
||||||
source,
|
source,
|
||||||
mount.get_name()
|
title: mount.get_name(),
|
||||||
);
|
});
|
||||||
notification.connect('activate', () => {
|
notification.connect('activate', () => {
|
||||||
const app = Gio.app_info_get_default_for_type('inode/directory', false);
|
const app = Gio.app_info_get_default_for_type('inode/directory', false);
|
||||||
startAppForMount(app, mount);
|
startAppForMount(app, mount);
|
||||||
|
@ -782,7 +782,7 @@ class NetworkAgent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const source = MessageTray.getSystemSource();
|
const source = MessageTray.getSystemSource();
|
||||||
const notification = new MessageTray.Notification(source, title, body);
|
const notification = new MessageTray.Notification({source, title, body});
|
||||||
notification.iconName = 'dialog-password-symbolic';
|
notification.iconName = 'dialog-password-symbolic';
|
||||||
|
|
||||||
notification.connect('activated', () => {
|
notification.connect('activated', () => {
|
||||||
|
@ -349,9 +349,11 @@ export class ExtensionManager extends Signals.EventEmitter {
|
|||||||
let source = new ExtensionUpdateSource();
|
let source = new ExtensionUpdateSource();
|
||||||
Main.messageTray.add(source);
|
Main.messageTray.add(source);
|
||||||
|
|
||||||
let notification = new MessageTray.Notification(source,
|
const notification = new MessageTray.Notification({
|
||||||
_('Extension Updates Available'),
|
source,
|
||||||
_('Extension updates are ready to be installed.'));
|
title: _('Extension Updates Available'),
|
||||||
|
body: _('Extension updates are ready to be installed.'),
|
||||||
|
});
|
||||||
notification.connect('activated',
|
notification.connect('activated',
|
||||||
() => source.open());
|
() => source.open());
|
||||||
source.addNotification(notification);
|
source.addNotification(notification);
|
||||||
|
@ -274,9 +274,11 @@ async function _initializeUI() {
|
|||||||
return; // assume user action
|
return; // assume user action
|
||||||
|
|
||||||
const source = MessageTray.getSystemSource();
|
const source = MessageTray.getSystemSource();
|
||||||
const notification = new MessageTray.Notification(source,
|
const notification = new MessageTray.Notification({
|
||||||
_('System was put in unsafe mode'),
|
source,
|
||||||
_('Apps now have unrestricted access'));
|
title: _('System was put in unsafe mode'),
|
||||||
|
body: _('Apps now have unrestricted access'),
|
||||||
|
});
|
||||||
notification.addAction(_('Undo'),
|
notification.addAction(_('Undo'),
|
||||||
() => (global.context.unsafe_mode = false));
|
() => (global.context.unsafe_mode = false));
|
||||||
notification.setTransient(true);
|
notification.setTransient(true);
|
||||||
@ -614,7 +616,11 @@ export function loadTheme() {
|
|||||||
*/
|
*/
|
||||||
export function notify(msg, details) {
|
export function notify(msg, details) {
|
||||||
const source = MessageTray.getSystemSource();
|
const source = MessageTray.getSystemSource();
|
||||||
let notification = new MessageTray.Notification(source, msg, details);
|
const notification = new MessageTray.Notification({
|
||||||
|
source,
|
||||||
|
title: msg,
|
||||||
|
body: details,
|
||||||
|
});
|
||||||
notification.setTransient(true);
|
notification.setTransient(true);
|
||||||
source.addNotification(notification);
|
source.addNotification(notification);
|
||||||
}
|
}
|
||||||
|
@ -351,28 +351,13 @@ class Action extends GObject.Object {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export class Notification extends GObject.Object {
|
export class Notification extends GObject.Object {
|
||||||
_init(source, title, banner, params) {
|
constructor(params) {
|
||||||
super._init({source});
|
super(params);
|
||||||
|
|
||||||
this.title = title;
|
this._actions = [];
|
||||||
this.urgency = Urgency.NORMAL;
|
|
||||||
// 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
|
|
||||||
this.isTransient = false;
|
|
||||||
this.privacyScope = PrivacyScope.USER;
|
|
||||||
this.forFeedback = false;
|
|
||||||
this.body = null;
|
|
||||||
this.useBodyMarkup = false;
|
|
||||||
this.sound = null;
|
|
||||||
this._soundPlayed = false;
|
|
||||||
this.actions = [];
|
|
||||||
this.setResident(false);
|
|
||||||
|
|
||||||
// If called with only one argument we assume the caller
|
if (!this.datetime)
|
||||||
// will call .update() later on. This is the case of
|
this.datetime = GLib.DateTime.new_now_local();
|
||||||
// NotificationDaemon, which wants to use the same code
|
|
||||||
// for new and updated notifications
|
|
||||||
if (arguments.length !== 1)
|
|
||||||
this.update(title, banner, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update:
|
// update:
|
||||||
@ -415,6 +400,10 @@ export class Notification extends GObject.Object {
|
|||||||
this.emit('updated', params.clear);
|
this.emit('updated', params.clear);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get actions() {
|
||||||
|
return this._actions;
|
||||||
|
}
|
||||||
|
|
||||||
get iconName() {
|
get iconName() {
|
||||||
if (this.gicon instanceof Gio.ThemedIcon)
|
if (this.gicon instanceof Gio.ThemedIcon)
|
||||||
return this.gicon.iconName;
|
return this.gicon.iconName;
|
||||||
@ -472,18 +461,18 @@ export class Notification extends GObject.Object {
|
|||||||
|
|
||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
this.actions.push(action);
|
this._actions.push(action);
|
||||||
this.emit('action-added', action);
|
this.emit('action-added', action);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearActions() {
|
clearActions() {
|
||||||
if (this.actions.length === 0)
|
if (this._actions.length === 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.actions.forEach(action => {
|
this._actions.forEach(action => {
|
||||||
this.emit('action-removed', action);
|
this.emit('action-removed', action);
|
||||||
});
|
});
|
||||||
this.actions = [];
|
this._actions = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
setUrgency(urgency) {
|
setUrgency(urgency) {
|
||||||
|
@ -175,7 +175,7 @@ class FdoNotificationDaemon {
|
|||||||
? this._getSourceForApp(sender, app)
|
? this._getSourceForApp(sender, app)
|
||||||
: this._getSourceForPidAndName(sender, pid, appName);
|
: this._getSourceForPidAndName(sender, pid, appName);
|
||||||
|
|
||||||
notification = new MessageTray.Notification(source);
|
notification = new MessageTray.Notification({source});
|
||||||
this._notifications.set(id, notification);
|
this._notifications.set(id, notification);
|
||||||
notification.connect('destroy', (n, reason) => {
|
notification.connect('destroy', (n, reason) => {
|
||||||
this._notifications.delete(id);
|
this._notifications.delete(id);
|
||||||
@ -405,8 +405,8 @@ const PRIORITY_URGENCY_MAP = {
|
|||||||
|
|
||||||
const GtkNotificationDaemonNotification = GObject.registerClass(
|
const GtkNotificationDaemonNotification = GObject.registerClass(
|
||||||
class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
||||||
_init(source, id, notification) {
|
constructor(source, id, notification) {
|
||||||
super._init(source);
|
super({source});
|
||||||
this._serialized = GLib.Variant.new('a{sv}', notification);
|
this._serialized = GLib.Variant.new('a{sv}', notification);
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
|
||||||
|
@ -39,7 +39,10 @@ class ShellInfo {
|
|||||||
let forFeedback = options.forFeedback;
|
let forFeedback = options.forFeedback;
|
||||||
|
|
||||||
if (!this._notification) {
|
if (!this._notification) {
|
||||||
this._notification = new MessageTray.Notification(source, text, null);
|
this._notification = new MessageTray.Notification({
|
||||||
|
source,
|
||||||
|
title: text,
|
||||||
|
});
|
||||||
this._notification.setTransient(true);
|
this._notification.setTransient(true);
|
||||||
this._notification.setForFeedback(forFeedback);
|
this._notification.setForFeedback(forFeedback);
|
||||||
this._notification.connect('destroy', () => delete this._notification);
|
this._notification.connect('destroy', () => delete this._notification);
|
||||||
|
@ -2087,12 +2087,12 @@ export const ScreenshotUI = GObject.registerClass({
|
|||||||
title: _('Screenshot'),
|
title: _('Screenshot'),
|
||||||
iconName: 'screencast-recorded-symbolic',
|
iconName: 'screencast-recorded-symbolic',
|
||||||
});
|
});
|
||||||
const notification = new MessageTray.Notification(
|
const notification = new MessageTray.Notification({
|
||||||
source,
|
source,
|
||||||
title,
|
title,
|
||||||
// Translators: notification body when a screencast was recorded.
|
// Translators: notification body when a screencast was recorded.
|
||||||
this._screencastPath ? _('Click here to view the video.') : ''
|
body: this._screencastPath ? _('Click here to view the video.') : '',
|
||||||
);
|
});
|
||||||
notification.setTransient(true);
|
notification.setTransient(true);
|
||||||
|
|
||||||
if (this._screencastPath) {
|
if (this._screencastPath) {
|
||||||
@ -2329,14 +2329,15 @@ function _storeScreenshot(bytes, pixbuf) {
|
|||||||
title: _('Screenshot'),
|
title: _('Screenshot'),
|
||||||
iconName: 'screenshot-recorded-symbolic',
|
iconName: 'screenshot-recorded-symbolic',
|
||||||
});
|
});
|
||||||
const notification = new MessageTray.Notification(
|
const notification = new MessageTray.Notification({
|
||||||
source,
|
source,
|
||||||
// Translators: notification title.
|
// Translators: notification title.
|
||||||
_('Screenshot captured'),
|
title: _('Screenshot captured'),
|
||||||
// Translators: notification body when a screenshot was captured.
|
// Translators: notification body when a screenshot was captured.
|
||||||
_('You can paste the image from the clipboard.'),
|
body: _('You can paste the image from the clipboard.'),
|
||||||
{datetime: time, gicon: content}
|
datetime: time,
|
||||||
);
|
gicon: content,
|
||||||
|
});
|
||||||
|
|
||||||
if (!disableSaveToDisk) {
|
if (!disableSaveToDisk) {
|
||||||
// Translators: button on the screenshot notification.
|
// Translators: button on the screenshot notification.
|
||||||
|
@ -195,7 +195,7 @@ 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});
|
||||||
|
|
||||||
this._notification.setTransient(true);
|
this._notification.setTransient(true);
|
||||||
this._notification.iconName = 'media-removable-symbolic';
|
this._notification.iconName = 'media-removable-symbolic';
|
||||||
|
@ -2030,9 +2030,11 @@ class Indicator extends SystemIndicator {
|
|||||||
this._notification?.destroy();
|
this._notification?.destroy();
|
||||||
|
|
||||||
const source = MessageTray.getSystemSource();
|
const source = MessageTray.getSystemSource();
|
||||||
this._notification = new MessageTray.Notification(source,
|
this._notification = new MessageTray.Notification({
|
||||||
_('Connection failed'),
|
source,
|
||||||
_('Activation of network connection failed'));
|
title: _('Connection failed'),
|
||||||
|
body: _('Activation of network connection failed'),
|
||||||
|
});
|
||||||
this._notification.iconName = 'network-error-symbolic';
|
this._notification.iconName = 'network-error-symbolic';
|
||||||
this._notification.setUrgency(MessageTray.Urgency.HIGH);
|
this._notification.setUrgency(MessageTray.Urgency.HIGH);
|
||||||
this._notification.setTransient(true);
|
this._notification.setTransient(true);
|
||||||
|
@ -258,7 +258,7 @@ 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({source, title, body});
|
||||||
this._notification.iconName = 'thunderbolt-symbolic';
|
this._notification.iconName = 'thunderbolt-symbolic';
|
||||||
this._notification.setUrgency(MessageTray.Urgency.HIGH);
|
this._notification.setUrgency(MessageTray.Urgency.HIGH);
|
||||||
this._notification.connect('destroy', () => {
|
this._notification.connect('destroy', () => {
|
||||||
|
@ -37,9 +37,9 @@ export class WindowAttentionHandler {
|
|||||||
let source = new WindowAttentionSource(app, window);
|
let source = new WindowAttentionSource(app, window);
|
||||||
Main.messageTray.add(source);
|
Main.messageTray.add(source);
|
||||||
|
|
||||||
let [title, banner] = this._getTitleAndBanner(app, window);
|
let [title, body] = this._getTitleAndBanner(app, window);
|
||||||
|
|
||||||
let notification = new MessageTray.Notification(source, title, banner);
|
let notification = new MessageTray.Notification({source, title, body});
|
||||||
notification.connect('activated', () => {
|
notification.connect('activated', () => {
|
||||||
source.open();
|
source.open();
|
||||||
});
|
});
|
||||||
@ -48,8 +48,8 @@ export class WindowAttentionHandler {
|
|||||||
source.addNotification(notification);
|
source.addNotification(notification);
|
||||||
|
|
||||||
window.connectObject('notify::title', () => {
|
window.connectObject('notify::title', () => {
|
||||||
[title, banner] = this._getTitleAndBanner(app, window);
|
[title, body] = this._getTitleAndBanner(app, window);
|
||||||
notification.update(title, banner);
|
notification.update(title, body);
|
||||||
}, source);
|
}, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,8 +56,10 @@ export async function run() {
|
|||||||
source.connect('notification-request-banner',
|
source.connect('notification-request-banner',
|
||||||
() => Scripting.scriptEvent('notificationShowDone'));
|
() => Scripting.scriptEvent('notificationShowDone'));
|
||||||
|
|
||||||
const notification = new MessageTray.Notification(source,
|
const notification = new MessageTray.Notification({
|
||||||
'A test notification');
|
source,
|
||||||
|
title: 'A test notification',
|
||||||
|
});
|
||||||
source.addNotification(notification);
|
source.addNotification(notification);
|
||||||
await Scripting.sleep(400);
|
await Scripting.sleep(400);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user