Re: select( ) ?

On Thu, 29 Jul 1999, Halfline wrote:

> I'm attempting(unsuccessfully) to make a GTK+/GNOME plugin for Licq.
>  The plugin is supposed to read( ) a file descriptor(the pipe) to
> find out if there is a Signal or Event from the daemon.
>  My question is: How do I have GNOME monitor the pipe and call a
> callback(which will read( ) it) when it changes?  Do I do something
> with select( )?  The Qt Plugin uses a QSocketNotifier, does GTK+
> or GNOME have something like this?

GLib implements a main loop concept that basically invokes
select() and calls the appropriate callbacks then.
if you don't want to fiddle around with the lower level
g_io_channels and add a watch there for it, you can use the
very convenient gdk_input_add*() interface to monitor fds.

>  Source code examples would be
> very welcome.  Also, is there a way to have a function executed
> once per cycle of the main gtk loop?  Thank you

you probably want to use idles or timeouts for this task,
gtk exports API calls for this in gtkmain.h, alternatively
you can use the GLib interface for this, which gives you
a little more felxibility (i.e. prioritized timeouts).
keep in mind though, that permanent idle handlers will suck
up the CPU.

and please insert newlines into your test next time.

> --Halfline


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