Re: [gtk-list] Couple of questions about g_io_*

Mikael Hermansson wrote:
> How do I use g_io_channel_* calls in glib

I've been writing documentation for this today.

On Unix systems, I think its fairly easy to use. The easiest
way is to use gdk_input_add (), which is described a bit in the
tutorial. That creates a GIOChannel for you and adds it into the
main event loop, so you can have a function called whenever there
is data to read from a file/pipe/socket (or when it is safe to write
to it).

On Windows systems things look slightly messy since separate
code is needed to handle plain files, pipes, and sockets.
And comments in glib.h indicate that some parts aren't finished.

I don't know what you're expected to do to handle GIOChannels in a
portable way. It's also a bit odd having gdk_input_add() in GDK,
but that is probably because the main event loop was there originally.
Maybe that should be deprecated, and a similar convenience function
added to GLib instead.

> 1. Why is the no public g_io_channel_free(GIOChannel *)?

GIOChannels are reference counted. They are freed when the
reference count reaches 0. They are created with a reference
count of 1. Use g_io_channel_unref() when you're done with it.

> 2. Is there any example code of g_io_* somewere?

I can't find any. Look at the code for gdk_input_add_full() in
I can send you what I've written so far for the docs, if you like.
It's almost complete, though it lacks example code.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]