Someone tried to make a Nim version based on the first example from
Gtk4-tutorial/sec24.md at main · ToshioCP/Gtk4-tutorial · GitHub
and got some trouble, see
Unfortunately I do know not much about the listview/treeview stuff currently, I read about it in 2007 in the Krause book, but forget most.
My current idea is that the function
GtkNoSelection: GTK 4 Reference Manual
<constructor name="new" c:identifier="gtk_no_selection_new">
<doc xml:space="preserve"
filename="../gtk/gtknoselection.c"
line="214">Creates a new selection to handle @model.</doc>
<source-position filename="../gtk/gtknoselection.h" line="33"/>
<return-value transfer-ownership="full">
<doc xml:space="preserve"
filename="../gtk/gtknoselection.c"
line="220">a new `GtkNoSelection`</doc>
<type name="NoSelection" c:type="GtkNoSelection*"/>
</return-value>
<parameters>
<parameter name="model"
transfer-ownership="full"
nullable="1"
allow-none="1">
<doc xml:space="preserve"
filename="../gtk/gtknoselection.c"
line="216">the `GListModel` to manage, or %NULL</doc>
<type name="Gio.ListModel" c:type="GListModel*"/>
</parameter>
</parameters>
</constructor>
does not increase the reference count on the passed model parameter?
The parameter is an in parameter with transfer-ownership=“full” and is an gobject. I guess not too many functions have that signature.
From Projects/GObjectIntrospection/Annotations - GNOME Wiki! we have for transfer mode full: “the recipient owns a ref on the value.”
But I think my understanding was wrong, I assumed a behavior as for gtk containers like windows with functions like gtk_window_set_child() where the function increases the ref count with g_object_ref_sink() call.
When gtk_no_selection_new() really is not assumed to increase the ref count of the passed gobject, then I have to take care that my Nim proxy object does not call g_object_unref() on the gobject when the proxy object goes out of scope. Well the Nim bindings could ref the gobject, or we could detach the proxy object from the gobject, so that the proxy object is freed when it goes out of scope, but does not unref the gobject.
PS: I think I just found a way how I can use links and avoid that the forum software inserts that page, I can put a few spaces in front of the link.