Updating progress bar



Hello. Sorry for my last posting (the answer was right in the previous
post on the list, but I sent mine before reading it).  I'd like to
update a progress bar while a time-consuming function is working.  I
read in the FAQ that I have to call  'while(g_main_iteration(FALSE));'
inside the function that changes the widget. Now, that function in my
case is as follows :

gint display_progress_update (gpointer p)
{
static float percentage=0.0;
gtk_progress_bar_update(GTK_PROGRESS_BAR(p), percentage);
percentage+=0.1;
if (percentage>=1.0)
percentage=0.0;
return (TRUE);
}

and the calling function:

progress=gtk_timeout_add(50,display_progress_update,p);
for(;;);  /* this represents a time consuming function.


My problem is that if I insert the 'while' snippet into
display_progress_update (that is after gtk_progress_bar_update)  it
simply does not work, while if I put it inside the for loop it works
well. I do not want to insert it in my time consuming function since it
could be just reading a long file, with no loops (that's why I want to
use timeouts ). I even thought of setting up another timeout just for
it, but still no effect.
Could anybody please explain how all this should be set up?
Thank you in advance for your kind answers.
Fedrico Bravo.





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