GIOChannel Tutorial
From: Brook Keele (bkeele_at__NOSPAM_guidedfate.com)
Date: 07/14/03
- Next message: David Schwartz: "Re: Profiling multithreaded C++ code"
- Previous message: John Reiser: "Re: Profiling multithreaded C++ code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 14 Jul 2003 01:34:52 GMT
Does anyone know any GOOD documentation on GIOChannel? I have been trying
to get a basic Gtk+ 2.2 app running. The gist os to run a command and pipe
the output to a TextView object. After adding the watch, it never gets to
the 'command_read' callback function.
Any help would be appreciated.
Here is a little code example of what I am doing.
on_button1_clicked
{
...
text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); pipe(out);
outch[0] = g_io_channel_unix_new(out[0]); outch[1] =
g_io_channel_unix_new(out[1]);
g_io_add_watch(outch[0], G_IO_IN, (GIOFunc) command_read, text);
result = forkexecv(args, out);
...
}
gboolean
command_read(GIOChannel * channel, GIOCondition condition, gpointer data)
{
gint fd;
gint result;
GtkTextBuffer *buf = GTK_TEXT_BUFFER(data); GtkTextIter *iter;
gchar curchar;
if (condition == G_IO_IN) {
fd = g_io_channel_unix_get_fd(channel); result = read(fd, &curchar, 1);
if (result == 1) {
gtk_text_buffer_get_iter_at_offset(buf, iter, -1);
gtk_text_buffer_insert(buf, iter, &curchar, 1);
} else
return FALSE;
return TRUE;
}
return FALSE;
}
-- Brook A. Keele (bkeele@_NOSPAM_guidedfate.com) ---------------------------------------------------------- > ... What will be next, maybe you disable to run non GPL > executables under linux ? Actually no. We are researching how to stop trolls posting to the kernel list as our main AI project. - Alan Cox on linux-kernel
- Next message: David Schwartz: "Re: Profiling multithreaded C++ code"
- Previous message: John Reiser: "Re: Profiling multithreaded C++ code"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]