Skip to content

Commit

Permalink
Notification: Update for GNOME 46
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseExposito committed Mar 26, 2024
1 parent 539b812 commit b2154de
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/utils/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
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);

Expand All @@ -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);
Expand Down

0 comments on commit b2154de

Please sign in to comment.