On Wed, 2007-05-16 at 21:32 +0100, Chris Vine wrote: > On Wed, 2007-05-16 at 16:44 +0200, Michelle Konzack wrote: > > Am 2007-05-14 22:22:34, schrieb Chris Vine: > > > Pass the callbacks representing the events concerned to the main program > > > loop using g_idle_add(). Make sure the callbacks return FALSE. > > > g_idle_add() is thread safe, provided that you have initialised glib > > > with g_thread_init(). > > > > > > Chris > > ------------------------- END OF REPLIED MESSAGE ------------------------- > > > > Forgive me if I do not understand this... > > Do you have a short exanple? > > > > For the phtreads I have only copied an example-sniplet > > and modified a bit and it was just working... :-) > > The documentation is here: > > http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-idle-add > > The idea is that you call g_idle_add() in your worker thread with a > callback (function pointer and data) which you want to execute in the > main program (GUI) loop. > http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html > A simple example would be to call: > > g_idle_add((GSourceFunc)g_print, "Hello\n");
Actually it occurs to me that this may not work without a wrapper function which returns FALSE. I am not sure what the effect of casting a function with a void return type to a GSourceFunc type (which returns a gboolean/int type) is. Anyway, just put it in a wrapper function to try out the example. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list