[Glade-users] interface and looping functions

Byron Ellacott bje@apnic.net
Tue, 11 Sep 2001 10:06:11 +1000 (EST)


On Mon, 10 Sep 2001 f.parzefall@multitest.de wrote:

> How can I call such a function and still keep the interface in a state 
> where I can press buttons etc. to control the looping function?

GTK won't process events preemptively, you must explicitly give it a
chance to do so.  I have a bit of code I used for a splash screen that
keeps the user informed of loading progress, the way I deal with the
problem is:

    while (gtk_events_pending())
        gtk_main_iteration();

each time I update the display.  Be careful to understand reentrancy
issues if you use this from a callback!

The preferred, but trickier to keep portable, method is to use threads.
Perhaps you want to create a lightweight wrapper API around threads for
your specific purpose, and use preprocessor macros to call the appropriate
functions for thread creation.

-- 
bje