GNOME Bugzilla – Bug 639931
gtk_application_add_window() docs should mention window destruction
Last modified: 2017-09-18 23:28:13 UTC
Created attachment 178701 [details] test_gtkapplication.c The gtk_application_add_window() documentation says only " Adds a window from application. This call is equivalent to setting the application" property of window to application. http://library.gnome.org/devel//gtk/unstable/GtkApplication.html#gtk-application-add-window " which leads us to " The application will be kept alive for at least as long as the window is open. " http://library.gnome.org/devel//gtk/unstable/GtkWindow.html#GtkWindow--application This suggests that g_application_run() will return when the GtkWindow is closed/hidden, though that's not explicitly stated. However, that isn't what happens. GtkApplication/GApplication really seems to wait for teh GtkWindow to be destroyed. Just closing it isn't enough to make g_application_run() return, as seen in this test case. Note that this behavior, even if documented, is really annoying. I'd much prefer it to wait for the window to close. The time of a gtkmm object's destruction is really no business of GtkApplication and developers would be annoyed to be forced to delete their objects just to stop the application. I guess it feels arbitrary even to many C coders who don't use GtkWindow's (also annoying and disabled in gtkmm) default destroy-on-delete_event behaviour.
How do you define 'close' exactly? What do you do if the application needs close to hide the window and keep running? I second that this should be documented clearly.
(In reply to comment #1) > How do you define 'close' exactly? I define "closed" as "the hide signal has been emitted". That's what we handle in Gtk::Main::run(window), which has been working well for us for years. > What do you do if the application needs [to] > hide the window and keep running? I guess that should be allowed. The window-closing-means-app-finishing API should just be a convenience. It was always optional with Gtk::Main::run(), though that was simpler.
There is a well-established way to keep an application running: call g_application_hold()
I have clarified the documentation now.