A nifty feature of GDK (the library that underlies GTK), is the
ability to have it check for data on a file descriptor for you (as
returned by open(2) or socket(2)). This is especially useful for
networking applications. The function:
gint gdk_input_add( gint source,
GdkInputCondition condition,
GdkInputFunction function,
gpointer data ); |
Where the first argument is the file descriptor you wish to have
watched, and the second specifies what you want GDK to look for. This
may be one of:
As I'm sure you've figured out already, the third argument is the
function you wish to have called when the above conditions are
satisfied, and the fourth is the data to pass to this function.
The return value is a tag that may be used to stop GDK from monitoring
this file descriptor using the following function.
void gdk_input_remove( gint tag ); |
The callback function should be declared as:
void input_callback( gpointer data,
gint source,
GdkInputCondition condition ); |
Where source and condition are as specified above.