Re: Updating a statusbar widget



On Wed, 26 Jul 2000, Tony Denault wrote:

 Hi, 

> On Sun, 23 Jul 2000, Vlad Harchev wrote:
> 
> > 
> > while (gtk_events_pending())
> >         gtk_main_iteration();
> > 
> 
> 
> I am doing this, see my print_status function to write text
> status to a label:
> 
> int print_status( char *fmt, ... )
> {
>    char buf[256];
>    va_list argptr;
> 
>    va_start( argptr, fmt);
>    vsprintf( buf, fmt, argptr);
>    va_end( argptr );
> 
>    /* update single line feedback widget on main screen */
>    gtk_label_set_text( GTK_LABEL(Feedback_search_w), buf );
> 
>    /* force update of widgets */
>    while ( gtk_events_pending() ) 
>       gtk_main_iteration();
>    // while ( gtk_main_iteration());   <- this one from the FAQ don't  work!
> 
>    return ERR_NONE;
> }
> 
> Some problems:
> 
> 1. The suggested code from the FAQ doesn't work:
>      "while (gtk_main_iteration(FALSE));"
>    I am using GTK 1.2.7. Is the FAQ out of date with the GTK release?

  Probably it should be while gtk_main_iteration_do(FALSE) since
  gtk_main_iteration() doesn't accept any arguments. If it's really bug in
  FAQ, please submit bug report somewhere :)

> 2. Worse, this solution does more than just drawing updates. It also
>    processing other events on the queue. If I call print_status(), any
>    user input to widget and their call backs are called, expired timers
>    call backs get called, etc This make the cure, worse that the problem.

    As for timers - it looks like the right thing to call them.
    As for everything else: if you call print_status in some long loop (that
can last rather long in average), in order to prevent user interacting with
other widgets you can instead pop modal window with just one message 
 "Please wait, %d%% done".

> Is there a better method to handle this situation?
> I think this is the best gtk 1.2.x can do. Will 1.4.x work better?

  Yes, it looks like the best gtk 1.2.x can do. I don't know for 1.4.x

> Tony
>  
> /-----------------------------------------------------------------------------\
> | Tony Denault                        | Internet: denault@irtf.ifa.hawaii.edu |
> | NASA IRTF, Institute of Astronomy   |                 Phone: (808) 974-4206 |
> | 1175 Manono St., Bldg 393           |                   Fax: (808) 974-4207 |
> | Hilo, Hawaii 96720                  |                                       |
> \-----------------------------------------------------------------------------/
> 
> 
> 

 Best regards,
  -Vlad





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