I am using C with GTK to create a dialog box to confirm an exit.
My main window has a quit button -> Dialog box with Yes and No
Yes should quit the program entirely
No should close the dialog box.
I have tried
dialog = gtk_dialog_new();
...
button = gtk_button_new_with_label("Yes");
g_signal_connect(button, "clicked", G_CALLBACK(close), NULL);
My callback function close is
static void close(GtkWidget* widget, gpointer data)
{
gtk_main_quit();
}
However, my Yes button does not quit anything. Is there a reason for this?
gtk_main_quit()
only leaves the current nested main loop.gtk_dialog_run()
creates its own nested main loop, so yourgtk_main_quit()
only breaks out ofgtk_dialog_run()
, not out ofgtk_main()
.