Re: update a progress bar from a thread



You must use gdk_threads_enter and gdk_threads_leave surrounding any UI
change on the thread, to acquire the gdk global mutex.

On Mon, 2006-05-15 at 13:50 +0200, nik600 wrote:
hi

i upgrade a progress bar from the body of a thread with the following code:

void *body_monitor_avanzamento(void *args){
  monitor_avanzamento *m=(monitor_avanzamento *)args;


  float avanzamento=0.0;

  while(avanzamento<1){

    avanzamento=(float)*(m->db->counter_shared)/(float)m->tot_pacchetti;
 
      gdk_threads_enter();

    gtk_progress_bar_set_fraction ((GtkProgressBar
*)m->scroll_avanzamento_simulazione,avanzamento);

      gdk_threads_leave()

    gtk_widget_show(m->scroll_avanzamento_simulazione);

//    ^^^^^This is not needed

    sleep(1);
  }
}

it works, but i can see the progress bar update only when i go with
the mouse over the progress bar, maybe i have to call another update
function?

i've also tried to make a  gtk_widget_show_all of the windows, but
without any result...

thanks nik





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