It’s surprisingly hard to find this, and the generated documentation is actually misleaingly wrong1, so here’s how to create ListStores and ListModels in Javascript with gjs.
let store = new Gtk.ListStore(); store.set_column_types([GObject.TYPE_STRING, GObject.TYPE_INT]); store.insert_with_valuesv(-1, [ 0, 1 ], [ "test", 42 ]); |
let model = Clutter.ListModel.newv( [ GObject.TYPE_STRING, GObject.TYPE_STRING ], [ 'Column Name 1', 'Column Name 2' ]); model.appendv([ 0, 1 ], [ "String 1", "String 2" ]); |
The first array is the column numbers you wish to assign, the second array is the values for those columns.
Fundamental GTypes are available as GObject.TYPE_*. You can specify non-basic types using the class, e.g. Clutter.Text.
There are other variations possible, but this should provide the basics required to figure out the rest.2

in theory, this should also work:
but I got an error from my system gjs — which may have already been fixed in GNOME 3.4, though.