if you do the
gtk_events_pending thing, the GUI will stay up to date,
however, I'm running into a problem with using
gtk_main_quit in this kind of a loop since
gtk_main hasn't been
called yet when the show signal is emitted.
I've gotten around this by using
exit instead of
gtk_main_quit:
Code:
#include <gtk/gtk.h>
#include <stdlib.h>
void show_cb(GtkWidget *wi, gpointer user_data)
{
while(TRUE)
{
/* ...do whatever you need to do... */
/* these two lines will allow the GUI to be updated */
while(gtk_events_pending())
gtk_main_iteration();
}
}
int main(int argc, char **argv)
{
GtkWidget *win;
gtk_init(&argc, &argv);
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(win, "show", G_CALLBACK(show_cb), NULL);
/* connecting to exit rather than gtk_main_quit isn't ideal, but may work */
g_signal_connect_swapped(win, "delete-event", G_CALLBACK(exit), (gpointer)0);
gtk_widget_show(win);
gtk_main();
return 0;
}