Dmitry M. Shatrov wrote: [ ... ]
Could you point to some additional documentation on how to actually create own `GSource`s? An example? I'm stuck with it just because plain glib docs didn't give me understanding of what is what, and google was also successfull in keeping the secret.
A good example would be the g-io-channel sources, take a look at giounix.c, a GSource must provide four functions to integrated it as an event source into the main loop (see: http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html for an enlightening discusion on how the mainloop functions) :
GSourceFuncs g_io_watch_funcs = { g_io_unix_prepare, // I believe this is called every time the mainloop // for this thread/process is ready to go into // "wait state", you'll need to check into that for sure.
g_io_unix_check, // is this source ready to be dispatched ?
g_io_unix_dispatch, // call the appropriate callback for this source
g_io_unix_finalize // free allocated stuff etc... (called when the // user calls g_source_remove or when the user // callback returns FALSE). };
You would basicly want your "check" function to return TRUE when there is data on the GAsyncQueue.
To create a source (g_io_add_watch):
static GSource * g_io_unix_create_watch (GIOChannel *channel, GIOCondition condition) { GSource *source; GIOUnixWatch *watch; /*...*/
/* Here the "watch" is and extended version of the GSource structure; * glib will use the "g_io_watch_funcs" to work with the source and * anything else you will need to know you can use this extended struct * for (example, you will probably want to know what GAsyncQueue you * are going to pop stuff off of in your "check" func). */ source = g_source_new (&g_io_watch_funcs, sizeof (GIOUnixWatch)); watch = (GIOUnixWatch *)source;
/*...*/ }
Hope this helps ;-)
Cheers, -Tristan
_______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list