Re: Updating a TextView with the results of a long, processor-intensive process

On Wed, Apr 14, 2004 at 19:41:30 +0100, Bob Wilkinson wrote:
On Tue, Apr 13, 2004 at 11:17:21PM -0400, muppet wrote:

On Tuesday, April 13, 2004, at 05:23 PM, Bob Wilkinson wrote:

I have read the FAQ Q: How do i keep my gui updating while doing a 
long file read?
and added code to the process_infile routine.
However, it only updated my TextView at the end of the processing.

Some sanity-check questions:
- Are you returning control to the event loop?

Implicitly. once the processing routine is finished control returns.
How would I do this explicitly, once the processing routine is

Since all problems you described later seem to be this one:

You should know, that Gtk+ applications are NOT threaded (normaly).
Things don't happen in parallel in them. Instead they run from a big
event loop, that waits for something to happen and calls appropriate
function that responds. All the redrawing is tightly bound to events
sent by the X server. Thus it can only happen from the mainloop^*. So
you need to pass control to the main loop for ANYTHING to be redrawn.

There are two ways to pass control to mainloop.
1) Returning. You must set an idle handler to do the rest of the work
   (it will be called once pending events are processed).
2) Calling gtk_main_iteration()/Gtk2->main_iteration(). That will
   process pending events once and return. So you have to call it
   regularly from a long-running routine.

* It's actualy more complicated, but all redrawing only happens from


OK - I will ignore threads. I will go to look at
Gnome::VTE::Terminal. If this does what I want, I will inform the
list (and publish the code)

It won't solve your problem. Only properly passing control to mainloop

                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature

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