Update progress bar without returning to main loop?



I have what I believe is a classic issue with progress bars, but I have never found a good solution in the docs or via a web search:

I'm trying to indicate progress of a signal handler that takes a *long* time via a Gtk::ProgressBar and multiple calls (as the work progresses) using the set_fraction() method. The problem is that these calls have no real effect, since the actual GUI update isn't done until after the application returns to the main loop (i.e. when the handler is done and the progress has reached 100%). The only way I've found to ensure it's redrawn as the work progresses, is to flush events using something like:

while(Gtk::Main::events_pending())
  Gtk::Main::iteration(false);

But this has some nasty side effects. In particular, it means that user input like button clicks, text field updates also handled, which is not what I want; I need the window to be unresponsive while the above mentioned callback is being executed.

Is there an alternative?

- Toralf






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