Re: Event pending problem

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

 



On Thu, Sep 21, 2006 at 11:53:44PM +0000, DC A wrote:
>
> for(gflt=0; gflt <=1; )
>    {
>        gtk_progress_bar_update((GtkProgressBar*)pbar, gflt);
>
>        while(gtk_events_pending())
>           gtk_main_iteration();
>
>        gflt += 0.1;
>        sleep(1);
>
>        if( gflt > 1) break;
>    }
>
>
> Why use while loop for event pendings? You can clearly see that there is
> only one event pending which is gtk_progress_bar_update.

gtk_progress_bar_update() is no event, it is GtkProgressBar
method telling it to update.

Events are coming from the X server (and possibly other
sources).

You need the loop even if you do not update anything,
because users can move, resize and focus windows, make them
invisible and visible again, click on things, press keys,
etc.  All these actions generate events that have to be
handled.  And if your code did not give Gtk+ the opportunity
to process them, the GUI would freeze.

The reaction to some events may cause more events to occur.
Of course, if you tested gtk_events_pending() and called
gtk_main_iteration() often enough, Gtk+ would catch up
eventually, but the while loop is better.

Yeti

Again thanks.

--AD

_________________________________________________________________
Don?t waste time standing in line?try shopping online. Visit Sympatico / MSN Shopping today! http://shopping.sympatico.msn.ca

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux