After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 639931 - gtk_application_add_window() docs should mention window destruction
gtk_application_add_window() docs should mention window destruction
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkApplication
2.99.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-01-19 10:41 UTC by Murray Cumming
Modified: 2017-09-18 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test_gtkapplication.c (1.69 KB, text/x-csrc)
2011-01-19 10:41 UTC, Murray Cumming
Details

Description Murray Cumming 2011-01-19 10:41:04 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.
Comment 1 Christian Dywan 2011-01-19 13:00:29 UTC
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.
Comment 2 Murray Cumming 2011-01-19 14:13:37 UTC
(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.
Comment 3 Matthias Clasen 2011-01-21 04:46:11 UTC
There is a well-established way to keep an application running: call
g_application_hold()
Comment 4 Matthias Clasen 2011-01-25 03:21:21 UTC
I have clarified the documentation now.