progress bar use



On Monday, 16 January 2012, Nick Belshaw <nick s belshaw googlemail com>
wrote:
I would like to implement a progress-bar to make clear to users stuff is
happening.
Specifics involve loading and pre-processing of files. Some files might be
very big requiring some 10's of seconds to do all stuff.
At the moment the processing of the files blocks any updates I try to push
to the progress bar.
Do I have to go to threads or is there another way of handling this?

A simple solution is to run an iteration of the gtk main loop every few
milliseconds:

http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#g-main-context-iteration

This may not be possible, of course, depending on the operation you are
performing.

Threads are actually very easy. Launch a thread to do the load and have it
send messages to the main GUI thread as it runs to update your application
about progress. Don't call any gtk stuff from the bg thread. You can do the
whole thing in less then 20 lines of C (probably).

John



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