Re: Delay in Displaying Dialog
- From: "Matt Fischer" <mattfischer84 gmail com>
- To: "Marshall Lake" <mlake mlake net>
- Cc: gtk-list gnome org
- Subject: Re: Delay in Displaying Dialog
- Date: Tue, 16 Jan 2007 01:11:32 -0600
On 1/15/07, Marshall Lake <mlake mlake net> wrote:
After the text being sent to the text widget ends and process flow falls
back into gtk_main() then all the other widgets within the secondary
dialog appear including the first few lines of text which had been
missing.
This line leads me to believe that you may not be relinquishing control to the Gtk mainloop. When the text comes into the second dialog box, are you locking up the program until it is all read? For instance, are you simply reading from a socket or file descriptor repeatedly until the text has all been received? If so, that's most likely your problem.
Gtk doesn't run in a separate thread, so when it is instructed to do something, such as display a widget, it actually queues the work to be performed later, by the Gtk mainloop. When a function of yours is called, such as a callback for a button being pressed, it is the mainloop which actually does the calling, and it is done with the expectation that the function will do its work quickly, and then return, allowing the mainloop to continue running, and dispatching input events, redrawing widgets, etc. If one of your callbacks takes an extended amount of time to do something, the mainloop is unable to run, thus making the UI unresponsive, preventing expose requests from being serviced, and other Bad Things.
There are a few different ways around this problem. They all amount to deferring the work until later, and chopping it up into small pieces, so that it never actually blocks the mainloop for a significant amount of time. For example, you can set up an "idle handler", which will be called by the Gtk mainloop whenever it doesn't have any other work to do. Inside of this callback, you could check the data source to see if any new data has appeared, and if so, add it to the text widget, and then quickly return (at which point the mainloop would continue running, and actually expose the new text on the screen.) I believe it's also possible to tell the mainloop about a file descriptor which should be watched, and have it call a function whenever new data appears. I have never used this tactic (hopefully someone else can clarify this), but you might try looking at the documentation for the Glib mainloop and the Gtk mainloop, both available at
http://www.gtk.org/api/ .
Good luck--if this turns out not to be the problem you're having, be sure to send a reply with some more description, and we'll see what we can do.
--Matt
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]