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. A simple example would be to call: g_idle_add((GSourceFunc)g_print, "Hello\n"); If you call this in the worker thread, it will print "Hello" in the GTK+ main program thread (you must have called g_thread_init(NULL) first). It is the standard way of passing events to the GUI thread. Incidentally, instead of using pthreads, you can use the platform independent GThread implementation. See: http://developer.gnome.org/doc/API/2.0/glib/glib-Threads.html Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list