Hello,
I was playing with Gtk4 tutorial at Gtk Gnome Develper Documentation trying to rewrite it in Vala, I’m aware that Gtk4 API not final and undergoes constant changes.
I’ve been faced with 2 problems I can’t solve and I could use some help.
Closing the Window don’t exit the process, I’ve to either use the Quit menu or press Ctrl+C in Terminal.
I can’t remove the Widgets (Buttons) from GtkListBox because get_first_child seems not to work. Please see the relevant lines here.
I mean pressing x on the ApplicationWindow hides it but the process still runs, either I have to open system monitor and kill the application, or use the app.quit action.
The code supposed to remove all rows from Listbox and then populate new ones. I can’t remove those rows (I’ve added buttons as rows).
I did intent to create a Nim version of it, but for me the C code does not work really well currently. Examples 1 to 3 seems to be ok, but for example 4 the makefile does not work, I get
~/gtk/examples/application4 $ make -f Makefile.example
make: *** No rule to make target ‘app-menu.ui’, needed by ‘resources.c’. Stop.
For application9 makefile works, but I get a lot of warnings like
(exampleapp:27002): GLib-GObject-WARNING **: 18:26:19.695: invalid cast from ‘GtkListBox’ to ‘GtkBox’
Nim does not really lack OOP style, but it does not enforce it like old style languages like Java do. Nim has methods and inheritance, but no classes. I think other more modern languages like Go and Rust do not enforce OOP that much too, and GTK4 also consider composition over inheritance and subclassing now.
I assume you have solved that issue, can you tell us what the initial problem was? (I have something similar with the Nim version of latest GTK4 tests/simple.c currently, have still to investigate it.)
Yes I have, It turned out that I have a reference to the main window in the application class as a member variable. I’ve deleted that and updated the repository.