On Sat, Feb 28, 2004 at 03:59:17PM -0800, Douglas Phillipson wrote:
Ive gotten to know and use GTK pretty well so far, but I haven't seen how to do things that aren't event driven. For example, how would one monitor the serial port or uSB port for incomming data to display on the graphics area as it comes in. Can I somehow attach a GTK event to the serial port and get dropped in a callback routine to grab data when I see a byte? I don't need to know how to monitor the serial port, I can do that already but if GTK sits in an event loop, how do you get input from non GTK stuff to use and display with GTK?
For reading from sockets, files and pipes you can use an GIOChannel (see GLIB docs). Simply put, you create a GIOChannel from a file, socket or pipe. Then you add a callback to it with g_io_add_watch(). This callback is invoked whenever the specified GIOCondition is met. For reading data from other sources, like USB ports, you could use a timeout function. Have it check if data is available, and if so process it. Roland -- R.F. Smith /"\ ASCII Ribbon Campaign r s m i t h @ x s 4 a l l . n l \ / No HTML/RTF in email http://www.xs4all.nl/~rsmith/ X No Word docs in email / \ Respect for open standards
Attachment:
pgpEFFKhwRMK3.pgp
Description: PGP signature