Re: [gtkmm] Glib::IOChannel



Murray Cumming Comneon com wrote:
From: Christopher Clark [mailto:clark compudata-systems com] I've been working through the tutorial, and when I found that the Monitoring I/O page was out of date, I wanted to try and get the demo running anyway with a Glib::IOChannel.


I believe that it's up-to-date now. Please submit a bug if something in the
book is wrong, with a link to the book online, showing exactly which part
you mean.

  I was looking at the example in:

http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch17s02.html

Which says to use Gtk::Main::input.connect, which doesn't appear to exist in the current headers. However, if I use Glib::signal_io() (thanks, Ross) it works fine.

This is what I think the logic should look like (called from within ExampleApp::ExampleApp):

Glib::RefPtr<Glib::IOChannel> ifile =
  Glib::IOChannel::create_from_file("testfifo", "r");
Glib::RefPtr<Glib::IOSource> isource = ifile->create_watch(Glib::IO_IN);
isource->connect(SigC::slot(*this, &ExampleApp::on_input_read));

This works, and gets rid of an object.

Glib::RefPtr<Glib::IOChannel> ifile =
  Glib::IOChannel::create_from_file("testfifo", "r");
Glib::signal_io().connect(SigC::slot(*this, &ExampleApp::on_input_read),
                          ifile, Glib::IO_IN);

Expansion of this into a revised section in the tutorial is left as an exercise for the reader.

--
Christopher Clark <clark compudata-systems com>
Pongidae, and proud of it.

  Praeterea censeo Carthaginem esse delendam.
                                                             -- Cato sr.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]