Best practice to quit a GtkApplication?

If I want to have a “Quit” button in a GtkApplication (especially GTK 4), are those kinds of code a good practice :

    call g_signal_connect_swapped(my_button, "clicked"//c_null_char, &
                                & c_funloc(gtk_window_destroy),  window)
    call g_signal_connect_swapped(my_button, "clicked"//c_null_char, &
                                & c_funloc(g_application_quit),  app)

And which is best ?

Calling g_application_quit() will immediately terminate the application.

You may want to have your own “quit” action and destroy all the windows bound to the GtkApplication instance. Once the last window is destroyed, the application will automatically terminate.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.