Pregunta

I am developing a simple application in C with GTK+2.0 GUI, on Linux of course, this application is designed to control a device which is connected over the USB port and is using FTDI driver to emulate RS232 asynchronious protocol over the USB port.

I wanted to create event driven control, like signals in GTK which are used to detect when the button is clicked et cetera. I found glib library for this, I have read in the documentation it seems clear. I know I must use functions like g_io_add_watch() to add event to be detected, that I can define my functions which would be "triggered" by this event and that for example "G_IO_IN" means it will be triggered when there is some output from the device. I just cannot find any usefull examples on the web.

The other thing is, I do not understand how to use GTK+2.0 and glib at once, because both have their own program loops to detect events (gtk_main() for GTK+2.0 and GMainLoop in glib).

I would be greatfull if you share some interesting examples, links, tutorials et cetera. Maybe I need to know more specific vocabulary, because I cannot find anything usefull on the web to solve this problem. Thanks!

¿Fue útil?

Solución

GTK+ uses GLib, and the main loop is not an exception. This means the GTK+ loop is a GMainLoop, hence all the GLib functions can be used with it.

Here is a reference to the GTK+ code to prove this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top