Re: Providing gtk_main() with asynchronous data



Pat Mahoney wrote:
[...]
The GSourceFuncs "prepare" and "check" are only passed the GSource and
no other data.  Thus, the only way they can check any variable is
through a global variable.  Now, my program would like to dynamically
create several (likely never more than 3-5) threads to feed the
mainloop.

In gereral this is how we deal with this problem:

typedef struct {
    GSource  source;
    gpointer my;
    gint     extended;
    gchar   *data;
} GMySource;

1.) Cast the GSource * to GMySource in your callbacks
2.) Make sure to pass sizeof (GMySource) to g_source_new.

(See giounix.c in glib for a working example)

Cheers,
                         -Tristan



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