romgrk / node-gtk

GTK+ bindings for NodeJS (via GObject introspection)
MIT License
494 stars 42 forks source link

Missing custom widgets with a template #316

Open GeoffreyCoulaud opened 2 years ago

GeoffreyCoulaud commented 2 years ago

Hello,

In GJS it's possible to add a XML template to a custom widget, as explained in the documentation.

Luckily, in GJS it is quite simple to load a user interface template

/* imports */
GObject.registerClass({
Template: 'url://templateurl',
InternalChildren: ['button'] // Array of IDs
}, class X extends GObject.Object {
/* implementation */
});

Now you can access the button like this :

this._button.do_something();

This is really useful and lacks in node-gtk, Would it be possible to have a different gi.registerClass, which behave as now when 1 parameter is passed, and behave like described above when 2 are ?

binyamin commented 2 years ago

Noting for posterity: this is coming from the discord chat.