Re: gtk_events_pending



Chris Manning wrote:
A quick question on gtk_events_pending ()
- where exactly is this supposed to go? I have put it in both my main
function and the function that it's supposed to be calling while events
are pending, and they both appear to work equally as well. Is this one
of those things that doesn't really matter, or should it belong in one
place or the other? Thanks!

You usualy dont need it,
    generaly your main loop is `gtk_main();',
`gtk_events_pending();' is often used when processing large
datasets in your ui (i.e. before threads we're supported in gtk
or when you're too lazy to implement them) like so:
============================================================
void
crunch_large_dataset_button_clicked(GtkButton *button,
                                    gpointer user_data)
{
    /* ... */
    for (element in list of large data set) {
        data_crunching();
        /* This effectivly "nests" the main loop so that your
         * UI stays responsive during this callback.
         */
        while (gtk_events_pending()) {
            gtk_main_iteration_do(FALSE);
/*
http://developer.gnome.org/doc/API/2.0/gtk/gtk-General.html#gtk-main-iteration
*/
        }
    }
}
============================================================


Cheers,
                            -Tristan





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