Gtkmm main loop
So, I have a gtkmm application in which one class is responsible for encapsulating what comes out of a pipe. All the data isn't going to hit the pipe at once though, so I can't just do a bunch of blocking fgetc()'s. I tried some awkward solution about spawning off a separate thread which watched the file descriptor, but that eventually led to needing to update the GUI in this separate thread, which is a big no-no since gtkmm is not threadsafe.
I've done a fair amount of work with gtk and in gtk I would just have the main loop poll the file descriptor for me. I would like to do the same thing in gtkmm, however the function to instruct the main loop to poll a file descriptor was a method of the glib main loop. In gtk this wasn't a problem because the gtk main loop was just a glib main loop. However, in the gtkmm documentation the Gtk::Main claims to inherit only from sigc::trackable, not Glib::Main, and the method I need is a method of Glib::MainContext.
So is Gtk::Main a child of Glib::Main and it's not documented or is there another way to get the main loop to poll a file descriptor for you?
Okay, so I just tried it so what did and did not work. I used this line to register my callback and file descriptor
"Glib::signal_io()" Get the default signal-io object
"connect" Connect a file descriptor
"sigc::mem_fun(*this, &Action::onPoll)" The slot referring to the callback method.
"from" the name of the file descriptor
"Glib::IO_IN | Glib::IO_HUP" call the callback when there is data to read or the file descriptor closes
This works partially, the callback is being called for the HUP, but not when there's new I/O.
|All times are GMT -5. The time now is 04:21 AM.|