Re: Update progress bar without returning to main loop?
- From: Toralf Lund <toralf procaptura com>
- To: Murray Cumming <murrayc murrayc com>
- Cc: GTK-- Mailing List <gtkmm-list gnome org>
- Subject: Re: Update progress bar without returning to main loop?
- Date: Wed, 28 Sep 2005 14:13:52 +0200
Murray Cumming wrote:
Should there perhaps also be an example illustrating the approach I
eventually took to resolve my problem (see my other posts...)
It's really just a matter of replacing
wait_on_system();
with
pb->gdk_window()->process_updates(false);
in the example, I believe.
I'm sceptical that this can really work well enough, but I would have to
do some research/experiments to find out, if I found time.
It works!
I believe this is the right and proper way of forcing queued redraw
requests to be handled out immediately, which is something the toolkit
generally can and should allow. I mean, how to do this was quite hard to
find in the API documentation, but that does not mean it's an
undocumented feature; it's actually there if you know where to look.
From the Gtk::Widget doc,
int Gtk::Widget::send_expose ( GdkEvent* /event/ )
Very rarely-used function.
This function is used to emit an expose event signals on a widget. This
function is not normally used directly. The only time it is used is when
propagating an expose event to a child NO_WINDOW widget, and that is
normally done using Gtk::Container::propagate_expose()
<http://www.gtkmm.org/docs/gtkmm-2.4/docs/reference/html/classGtk_1_1Container.html#a17>.
If you want to force an area of a window to be redrawn, use
gdk_window_invalidate_rect() or gdk_window_invalidate_region(). To cause
the redraw to be done immediately, follow that call with a call to
gdk_window_process_updates().
I'm more sceptical to docs that suggesti to users that you have to use
event loop constructs and/or threads in order to do something as simple
as this. Not that there is anything wrong with Bob's example as such,
it's just that it shows the way to program *if you want to respond to
user input while the job progresses*. It you don't, then I daresay
running an event loop is overly complex and/or simply wrong.
- T
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]