I have been trying to implement Win32\'s MessageBox
using GTK. The app uses SDL/OpenGL, so this isn\'t a GTK app.
I handle the initialization (gtk_
A few things:
You are creating (and not using) an unnecessary toplevel window, named window
. You can just delete these lines:
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
Also, the flow doesn't seem quite right. gtk_main()
starts the GTK main loop, which blocks until something exits it. gtk_dialog_run()
also starts a main loop, but it exits as soon as one of the buttons is clicked.
I think it might be enough for you to remove the gtk_init_add()
and gtk_main()
calls, and simply deal with the return value. Also the gtk_widget_destroy()
call is unnecessary, as the dialog window is automatically destroyed when gtk_dialog_run() returns.