From b2154decef0468cee067feeb93554c3f147e921c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Date: Tue, 26 Mar 2024 14:06:03 +0100 Subject: [PATCH] Notification: Update for GNOME 46 --- src/utils/Notification.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/utils/Notification.js b/src/utils/Notification.js index 14dbf54..8170c24 100644 --- a/src/utils/Notification.js +++ b/src/utils/Notification.js @@ -17,11 +17,24 @@ * this program. If not, see . */ import GObject from 'gi://GObject'; +import * as Config from 'resource:///org/gnome/shell/misc/config.js'; import * as Main from 'resource:///org/gnome/shell/ui/main.js'; import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js'; class NotificationClass extends GObject.Object { static send(title, text) { + const ShellVersion = Config.PACKAGE_VERSION; + + if (ShellVersion.startsWith('40') || ShellVersion.startsWith('41') + || ShellVersion.startsWith('42') || ShellVersion.startsWith('43') + || ShellVersion.startsWith('44') || ShellVersion.startsWith('45')) { + NotificationClass.send40to45(title, text); + } else { + NotificationClass.send46(title, text); + } + } + + static send40to45(title, text) { const source = new MessageTray.Source('X11Gestures', 'dialog-information-symbolic'); Main.messageTray.add(source); @@ -30,6 +43,23 @@ class NotificationClass extends GObject.Object { source.showNotification(notification); } + + static send46(title, body) { + const source = new MessageTray.Source({ + title: 'X11Gestures', + iconName: 'dialog-information-symbolic', + }); + + const notification = new MessageTray.Notification({ + source, + title, + body, + isTransient: false, + }); + + Main.messageTray.add(source); + source.addNotification(notification); + } } const Notification = GObject.registerClass(NotificationClass);