GTK application that will update when some file stream (STDIN) changes

Hello All

I am writing an application (with gtk3, and C) that will be updating a label with data from a file stream (stdin). I have written a simple ui that will be showing a label, which works. Then I have added code to watch an io channel, like so

ioChannel = g_io_channel_unix_new(STDIN_FILENO);
g_io_add_watch(ioChannel, G_IO_IN | G_IO_HUP, lineRead, NULL);

The channel is being read and the data printed on stdout (in the lineRead callback function). But I can not see the ui anymore.

When I do not watch the io channel, then the ui is being shown.

I know that, when doing this with a thread, I can not update the widgets in that thread. But how would we be doing this, with io channels.

Regards
Riza

GIO is probably easier to use, with for example GUnixInputStream.

With GIO you can read a GInputStream and receive a callback when data is read.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.