Re: Refreshing the GUI without gtk_main ()



Chris Seaton wrote:
Russell Shaw wrote:
Previous posts have said not to do *any* gui operations outside of the
main gtk thread. Is there a list of what can and can't be done?

I think you can do anything, provided you use the gdk_threads_... wrapper.

Agreed.

An alternative is to setup a messaging system. The IO thread passes
messages to the GUI thread, so the IO thread itself never calls any GUI
functions.

Yes, and like this approach.  I think it's cleaner.  My threads never
use GUI functions (at present at least).

Any way that you do it, your GUI must never become unresponsive as the
result of a normal operation such as reading from a file. That's
completely unacceptable, and how applications like Windows Explorer
manage to be written.

Take the Nautilus developer's approach - simply banish the idea of any
IO in the main thread.

This is not so true.  My application does non-blocking IO reads in main
event loop and it never freezes even if input is not immediatly available.
All you need is to make proper setup with g_io_add_watch().

My opinion about threads in GTK+/GLib program is that you should only
start one for tasks that need lots of CPU time (not IO!) and that are
impossible, clumsy or pain in the arse to do in small chunks (i.e.
between main loop iterations so that the loop doesn't freeze).

Paul



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