Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 23dbe49bc2fbd86096de282a461e6c66 > files > 328

gtk2-devel-docs-2.24.7-3.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Monitoring IO</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="UP"
TITLE="Timeouts, IO and Idle Functions"
HREF="c1759.html"><LINK
REL="PREVIOUS"
TITLE="Timeouts, IO and Idle Functions"
HREF="c1759.html"><LINK
REL="NEXT"
TITLE="Idle Functions"
HREF="x1790.html"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="c1759.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Timeouts, IO and Idle Functions</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x1790.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-MONITORINGIO"
>Monitoring IO</A
></H1
><P
>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:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>gint gdk_input_add( gint              source,
                    GdkInputCondition condition,
                    GdkInputFunction  function,
                    gpointer          data );</PRE
></TD
></TR
></TABLE
><P
>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:</P
><P
></P
><UL
><LI
><P
><TT
CLASS="LITERAL"
>GDK_INPUT_READ</TT
> - Call your function when there is data
ready for reading on your file descriptor.</P
></LI
><LI
><P
><TT
CLASS="LITERAL"
>GDK_INPUT_WRITE</TT
> - Call your function when the file
descriptor is ready for writing.</P
></LI
></UL
><P
>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.</P
><P
>The return value is a tag that may be used to stop GDK from monitoring
this file descriptor using the following function.</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void gdk_input_remove( gint tag );</PRE
></TD
></TR
></TABLE
><P
>The callback function should be declared as:</P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>void input_callback( gpointer          data,
                     gint              source, 
                     GdkInputCondition condition );</PRE
></TD
></TR
></TABLE
><P
>Where <TT
CLASS="LITERAL"
>source</TT
> and <TT
CLASS="LITERAL"
>condition</TT
> are as specified above.</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="c1759.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x1790.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Timeouts, IO and Idle Functions</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c1759.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Idle Functions</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>