Re: Non-Blocking GUI developement



On 1/24/07, Melvin Newman <zexelon gmail com> wrote:
The problem that I am running into is that I cant get the gui to update in a
timely manner (a problem that allot of us GTK noobs seem to have, but one
which no one answers clearly).

I've written a large (>100,000) line threaded GTK application. After
experimenting with various options, IMO the best solution is:

- use GThread, not pthread, and there's one less porting worry if you
ever have to consider win32
- your main thread should do the GUI: all gtk_*() calls are from this
thread, and it spends most of its life sitting in gtk_main()
- long computations are done in a thread
- when a thread has some data ready to update the display, it calls
g_timeout_add(), passing in a pointer to the data
- the timeout callback happens in the main thread ... it processes the
data (I assume this is quick), updates the display, and frees the data
area

John



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