[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GTK Progress bar: assistance pls.
- From: Bin Chen <binary chen gmail com>
- To: vijayasarathy setsindia net
- Cc: gtk-app-devel-list gnome org
- Subject: Re: GTK Progress bar: assistance pls.
- Date: Mon, 07 Jan 2008 15:56:20 +0800
在 2008-01-07一的 13:18 +0530,vijayasarathy setsindia net写道:
> for(i=start_count;i<end_count;i++)
> {
> //g_print("i = (%d)\n",i);
> while(j<100000)//To kill time, keep counting until a
> lakh
> j++;
> j = 0;//Make j 0 for the next loop.
> //sleep(2);
> pdata->fraction = (gdouble)i/(gdouble)(range);
>
> fflush(NULL);
> //gtk_progress_bar_pulse (GTK_PROGRESS_BAR
> (pdata->pbar));
> //gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR
> (pdata->pbar),pdata->fraction );
> gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR
> (pdata->pbar),
> pdata->fraction);
> }//End for i = start_count to end_count
For this code snippet, you update all your progress in the loop and not
yield the control to gtk_main(), this is the problem.
You should not write code like this, using a timer to update the
progress bar instead of this loop, otherwise the drawing instruction
will be pending due to your full control of CPU.
Bin
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]