Re: GTK Progress bar: assistance pls.
- From: carlo <carlo-ag libero it>
- To: gtk-app-devel-list gnome org
- Subject: Re: GTK Progress bar: assistance pls.
- Date: Mon, 07 Jan 2008 10:41:59 +0100
vijayasarathy setsindia net ha scritto lo scorso 07/01/2008 08:34:
Hey Bin Chen[or how do I call you :-)],
First of all, thank you very much for your instant reply.
Let me give a simple pseudo-code explaining my problem. Please see what I
can do with this.
Program Goal: Do work w1 "iterations" number of times, and keep showing
progress of this whole work regularly.
Pseudo code:
for(i=0;i<iterations;i++)
{
do w1;
fraction = (i+1)/iterations;
Update progress bar using this fraction.
}
This is what I coded, and the progress bar never got updated until
fraction was 0.99[that is, the progress bar went from zero to 100 % after
the whole work was done].
that is: until your loop returns control to the (gtk) main loop; one
(easy) way to do what you want is to allow the main loop to accomplish
its tasks (among which the refreshing of current progress bar settings)
is the following:
for (i = 0; i < iterations; i ++)
{
<do "w1">
fraction = (gdouble)(i + 1) / iterations;
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (widget), fraction);
while (gtk_events_pending ())
{
gtk_main_iteration ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]