Finding documentation for Extensions libraries

I’m just getting started with authoring an Extension under Gnome 46 (Ubuntu 24.04). Using the Getting Started guide, I created my extension using gnome-extensions create --interactive and the “indicator” template and have it running under a nested GNOME Shell session.

The boilerplate extension is meant to pop up a notification using Main.notify():

let item = new PopupMenu.PopupMenuItem(_('Show Notification'));
item.connect('activate', () => {
    Main.notify(_('Whatʼs up, folks?'));
});
this.menu.addMenuItem(item);

Main is imported like so:

import * as Main from 'resource:///org/gnome/shell/ui/main.js';

This seems to be the wrong way to call Main.notify() for the version of Gnome I have installed:

(gnome-shell:283222): Gjs-CRITICAL **: 20:36:33.577: JS ERROR: Error: Invalid value 'undefined' for property body in object initializer.
Notification@resource:///org/gnome/shell/ui/messageTray.js:354:9
notify@resource:///org/gnome/shell/ui/main.js:676:26
_init/<@file:///home/annika/.local/share/gnome-shell/extensions/todo.txt@sixohthree.com/extension.js:45:14
activate@resource:///org/gnome/shell/ui/popupMenu.js:195:14
_init/<@resource:///org/gnome/shell/ui/popupMenu.js:112:24
@resource:///org/gnome/shell/ui/init.js:21:20

Is that the correct way to read the error I’m getting? I can resolve the error by adding a second argument but that was just a guess. Given an import like resource:///org/gnome/shell/ui/main.js, where do I find its documentation? I assume it’s somewhere in the GJS docs but I can’t find it for the life of me.

Cheers,
Annika

For 46, the second parameter isn’t optional. So, you should send null if you don’t want any values for details:

Main.notify(_('Whatʼs up, folks?'), null);

I highly recommend to update your GNOME Shell. You shouldn’t have that issue in 46.7.

Thanks, are you able to link to the docs for Main.notify()?

I’d have to update off Ubuntu 24.04, but I’ll think about it I guess.

No docs. It’s part of GNOME Shell source code:

1 Like