You can only use GObject as the data inside a store.
If your old GtkListStore used multiple columns, the appropriate way to migrate to GListStore and to the new list view widgets in GTK4, is to create an object that represents the row data, with properties representing the state and data of the row. For instance, something like:
G_DECLARE_FINAL_TYPE (FooPerson, foo_person, FOO, PERSON, G_TYPE_OBJECT)
// ... GObject code to define the following properties:
// - name (string)
// - surname (string)
// - age (uint)
// - address (string
GListStore *people_model = g_list_store_new (FOO_TYPE_PERSON);
Now every row in the model will be an object of the same type, and you can use the type to access the relevant data.
The next step is creating a row widget, a widget that acts as a view to the row object’s model. You can use composite templates to build a composite widget with UI definition files and your custom widget type; and property bindings to bind properties on the row object to properties on the row widget, so that changing the row object in the model will automatically update the row widget in the view.
Currently i’m trying to understand the new way to get it running - however it looks for me totally different and i haven’t found a GTK4-tutorial like the GTK3-treeview-“hello-world”-tutorial , which helped me a lot to get a minimal code example to work.
(1) Which is the correct ParentName in G_DECLARE_FINAL_TYPE?
G_TYPE_OBJECT creates a compiler error, but GObject works: