Re: Providing gtk_main() with asynchronous data
- From: Tristan Van Berkom <tvb gnome org>
- To: Pat Mahoney <pat polycrystal org>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Providing gtk_main() with asynchronous data
- Date: Mon, 01 Aug 2005 17:36:47 -0400
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]