Document `static` GObject Class features
Since gjs-1.72 (?), GObject has supported static declarations of particular class attributes such as:
import GObject from 'gi://GObject';
import Gio from 'gi://Gio';
class MyObject extends GObject.Object {
static [GObject.GTypeName] = 'MyObject';
static [GObject.GTypeFlags] = GObject.TypeFlags.ABSTRACT;
static [GObject.interfaces] = [Gio.ListModel];
static [GObject.properties] = {
'example-property': GObject.ParamSpec.string(
'example-property',
'Example Property',
'An example property',
GObject.ParamFlags.READWRITE,
'default value'
),
};
static [GObject.requires] = [GObject.Object];
static [GObject.signals] = {
'example-signal': {},
};
static {
GObject.registerClass(this);
}
}
Additionally, GTK supports the following class attributes:
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk?version=4.0';
class MyBox extends Gtk.Box {
static [Gtk.children] = ['public_child'];
static [Gtk.cssName] = 'my-box';
static [Gtk.internalChildren] = ['private_child'];
static [Gtk.template] = '';
static {
GObject.registerClass(this);
}
}