I'm in the process of converting my app from v2 to v3 and have come across something strange:
Attaching gtk_main_quit() to a button's click callback does not result in the application quitting.
The following minimal program (top window + quit button) demonstrates this strangeness. Could this be platform-specific somehow? (Ubuntu 14.04)
#include <gtk/gtk.h>
static void activate(GtkApplication *app, gpointer nil)
{
GtkWidget *topWindow, *button;
topWindow = gtk_application_window_new(app);
gtk_container_set_border_width(GTK_CONTAINER(topWindow), 2);
g_signal_connect(topWindow, "destroy", G_CALLBACK(gtk_main_quit), NULL);
button = gtk_button_new_with_label("QUIT");
g_signal_connect(button, "clicked", G_CALLBACK(gtk_main_quit), NULL);
gtk_container_add(GTK_CONTAINER(topWindow), button);
gtk_widget_show_all(topWindow);
gtk_window_resize(GTK_WINDOW(topWindow), 300, 350);
gtk_window_set_position(GTK_WINDOW(topWindow), GTK_WIN_POS_CENTER_ALWAYS);
gtk_main();
}
int main(int argc, char **argv)
{
int status = 0;
GtkApplication *app;
app = gtk_application_new("quit.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}