If you're working on a Javascript application for GNOME, you'll be interested to know that you can now write GTK+ widget templates in gjs.
Many thanks to Giovanni for writing the original patches. And now to a small example:
const MyComplexGtkSubclass = new Lang.Class({
Name: 'MyComplexGtkSubclass',
Extends: Gtk.Grid,
Template: 'resource:///org/gnome/myapp/widget.xml',
Children: ['label-child'],
_init: function(params) {
this.parent(params);
this._internalLabel = this.get_template_child(MyComplexGtkSubclass,
'label-child');
}
});
And now you just need to create your widget:
let content = new MyComplexGtkSubclass();
content._internalLabel.set_label("My updated label");
You'll need gjs from git master to use this feature. And if you see anything that breaks, don't hesitate to file a bug against gjs in the GNOME Bugzilla.
"GTK+ widget templates now in Javascript"
No comments yet. -