GtkProgressBar and updating other widgets



Hello all,

In an image processing application, I have a set of Radio buttons to
select the method to process my image.
This works fine.
As processes are long, I have added a GtkProgressBar. But now, the Radio
buttons are not updated according to my selection. During the process,
the GUI is blocked except the progress bar using gtk_grab_add().
If I don't block the GUI, the Radio buttons are of course correctly
updated. But preventing other  GUI modifications during process is
mandatory for me.

I tried to add  "while (gtk_events_pending()) gtk_main_iteration();" at
different positions in the callback function before launching the
process but it does not change anything.

Any idea on how to make these buttons to updated according to the
selection ?


Here is the skeleton of the application :

/* Progress_bar.c : 3 functions to initialize, update and reset the
GtkProgressBar */
int progressbar_init(GtkWidget *main_window)
{
  /* pbar is declared global */
  pbar = lookup_widget(main_window, "progressbar");
  if (pbar == NULL)
    return 0;

  gtk_grab_add(pbar);
  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar), 0.0);
  while (gtk_events_pending())
    gtk_main_iteration();

  return 1;
}

void progressbar_update(gdouble percent)
{
  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar), percent);
  while (gtk_events_pending())
    gtk_main_iteration();
}

void progressbar_reset(void)
{
  gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar), 0.0);
  while (gtk_events_pending())
    gtk_main_iteration();
  gtk_grab_remove(pbar);
}


/* Callback_for_process.c */
void on_method1_radio_button_pressed(GtkButton *button, gpointer
user_data)
{
  [...]
  progressbar_init(main_window);
  for (i=0; i<nb_pixels; i++)        /* inner process */
  {
    [...]
    progressbar_update((gdouble) i / nb_pixels);
  }
  progessbar_reset();
}


Kind regards,
-- 
Stéphane Albin
e-mail: stephane point albin chez free point fr
www: http://stephane.albin.free.fr







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