Gio.ListStore only one object?

I have been looking at replacing my Gtk.TreeView and Gtk.ListStore with the new Gtk+4 Gtk.ListView and Gio.ListStore. I used to store several strings and a few GObjects in the Gtk.ListStore, some for the CellRenderers some for convenience.

As far as I can see, Gio.ListStore can not store multiple columns like the Gtk.ListStore can. Is this correct?

If not, how would I for example store 2 strings and a Gtk.Image?

If so, is there another store that I can use? I could not find any listed in the docs.

Yes, a GListModel can only list one object type per row; but an object type can have many properties. The expected use of a GListModel is to map a single object to a row widget, and make every component of the row a “view” of a property on the “model” object.

You should create a custom GObject type that contains your strings and a GFile with the path to the image; then bind the string properties to the “label” property of a GtkLabel, and the GFile property to the file property of GtkPicture, whenever you create a widget that represents your object inside a view, like GtkListView.

For more information:

Ah, hadn’t considered binding properties. That should work, thx

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.