On Wed, Apr 14, 2004 at 10:42:58PM +0200, Jan Hudec wrote:
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.<snip>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 started?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.
I have Glib::Idle->add( sub {while (Gtk2->events_pending()) {Gtk2->main_iteration()}}); at the end of my GUI code.
* It's actualy more complicated, but all redrawing only happens from mainloop.[...]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 will.
I think that I may well be doing this - I just wanted a long running process to be able to update a text pane (in real time, if possible) to give the user some feedback. This was an intermediate stage on the way to using a progress bar, I think, but I got a little stuck. Thank you for your suggestions and comments. Bob -- I'm a soldier, not a diplomat. I can only tell the truth. -- Kirk, "Errand of Mercy", stardate 3198.9
Attachment:
signature.asc
Description: Digital signature