Re: Non-blocking dialog

On 09.08, Jim Heald wrote:
Hello there!

I'm writing a GTK+ application in C. In my application I'm running two
commands that take a bit of time; in order to not make it appear that the
program has just frozen, I am wanting to do the following:

1) run the dialog, which has a spinner widget
2) add to the dialog area a message that says what the first command does
3) run the first command
4) add a message saying that the second command is running
5) run the second command
6) add a done message
7) allow the user to click "Ok" to close (or maybe delay for a second and

Your "commands" here are blocking the main thread, thus GTK+ can't
update any widget, not even show a window. It's the typical "don't block
the main thread" problem and the solution is to run your commands in
another thread and push update messages (e.g. for a progressbar if you
need that) to the main thread using g_idle_add.

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