Re: keep an io_channel from wasting my time?
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list gnome org
- Subject: Re: keep an io_channel from wasting my time?
- Date: Fri, 13 Dec 2002 21:01:56 -0500
On Fri, Dec 13, 2002 at 08:48:55PM -0500, Jeff Abrahamson wrote:
> No, but a variable contains the amount of stuff to write. I was hoping
> the main loop could key off of additional criteria, although it didn't
> look like it could.
Well the main loop can key off about anything (you can write a custom
GSource implementation), but the prebuilt IO watch GSource is
only keyed off the file descriptor.
> So then the queue_output function would contain code that says
> g_io_add_watch(gout, G_IO_OUT, do_output, mel);
> and the output handler itself would contain code that says
> return 0;
> return 1;
Yep, those are pretty standard idioms.
Also you might use the source ID (returned from g_io_add_watch())
instead of a boolean, so you can g_source_remove() if you need to.
if (output_handler_id == 0)
output_handler_id = g_io_add_watch ();
Most apps have to store the source ID anyhow because when the window
is closed or whatever they might have to remove it.
] [Thread Prev