how can I force a redraw?



I have an application that pops up a progress window
containing message and status labels, stop and OK buttons,
and a progress bar. When the application updates the
window, it calls the following function:

  void process_events_queue(void)
  {
    while (gtk_events_pending()) gtk_main_iteration();
    return;
  }    

However, this only processes events and high priority idle
functions. The redraw and resize actions have lower priority:

  #define GTK_PRIORITY_REDRAW  (G_PRIORITY_HIGH_IDLE + 20)
  #define GTK_PRIORITY_RESIZE  (G_PRIORITY_HIGH_IDLE + 10)

so my window is not fully updated before control returns to the
application. I tried running gtk_main with a timeout as follows:

  static int exit_main_loop(gpointer dummy) 
  {
    gtk_main_quit(); 
    /* don't reset the timer */
    return(0);
  }

  void process_events_queue(void)
  {
    /* 5 milliseconds is long enough */
    gtk_timeout_add(5, exit_main_loop, NULL);
    gtk_main();
    return;
  }

This works but seems a bit of a kludge. Comments?







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