Re: glib main loop without gtk



First thanks to Alexander Semenov, and Emmanuele Bassi for your responses. It took some poking around, but I think get it now. Here is a concept demo for any future searches that find this thread. I'm not sure how to get out of the infinite loop though, since _iteration() returns both TRUE and FALSE on normal execution. I can see how the approach glib is using for events would allow for all sorts of stuff like mixing main loops with other libraries and delegating events to helper threads. Good stuff.


#include <glib-2.0/glib.h>

gboolean timeout_callback(gpointer opaq)
{
g_print("got here\n");
}

int main(int argc, char **argv)
{
g_timeout_add(3000, timeout_callback, NULL);

while(1)
{
 g_main_context_iteration(NULL, TRUE);
}

return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]