mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-17 23:24:51 +00:00
GtkNotificationDaemon: Add display-hint property
The display-hint property can be used by apps to control how a notification should be displayed by GNOME Shell.
This commit is contained in:
parent
2f7c37809a
commit
16f3c47f24
1 changed files with 27 additions and 0 deletions
|
|
@ -415,6 +415,7 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||
buttons,
|
||||
'default-action': defaultAction,
|
||||
'default-action-target': defaultActionTarget,
|
||||
'display-hint': displayHint,
|
||||
timestamp: time,
|
||||
} = notification;
|
||||
|
||||
|
|
@ -441,6 +442,32 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||
});
|
||||
}
|
||||
|
||||
let showOnLockscreen = true;
|
||||
let showContentOnLockscreen = true;
|
||||
if (displayHint) {
|
||||
for (const hint of displayHint.deepUnpack()) {
|
||||
if (hint === 'transient')
|
||||
this.displayHint |= MessageTray.DisplayHint.TRANSIENT;
|
||||
else if (hint === 'tray')
|
||||
this.displayHint |= MessageTray.DisplayHint.NO_BANNER;
|
||||
else if (hint === 'persistent')
|
||||
this.displayHint |= MessageTray.DisplayHint.PERSISTENT;
|
||||
else if (hint === 'resident')
|
||||
this.displayHint |= MessageTray.DisplayHint.RESIDENT;
|
||||
else if (hint === 'hide-on-lockscreen')
|
||||
showOnLockscreen = false;
|
||||
else if (hint === 'hide-content-on-lockscreen')
|
||||
showContentOnLockscreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (showOnLockscreen) {
|
||||
if (showContentOnLockscreen)
|
||||
this.displayHint |= MessageTray.DisplayHint.SHOW_CONTENT_ON_LOCKSCREEN;
|
||||
else
|
||||
this.displayHint |= MessageTray.DisplayHint.SHOW_ON_LOCKSCREEN;
|
||||
}
|
||||
|
||||
this._serialized = GLib.Variant.new('a{sv}', notification);
|
||||
this.id = id;
|
||||
this._defaultAction = defaultAction?.unpack();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue