After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 88368 - signal_io() feature request
signal_io() feature request
Status: RESOLVED NOTABUG
Product: gtkmm
Classification: Bindings
Component: general
2.0
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2002-07-16 17:29 UTC by Morten Brix Pedersen
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Brix Pedersen 2002-07-16 17:29:04 UTC
In gtkmm 1.2, I used g_io_add_watch() to watch file descriptors.
In gtkmm 2, I can use signal_io() and have the advantage to use
SigC::Connections instead.

However, g_io_add_watch() passes a GIOChannel to it's callback function
which can be used to read/write from. This feature is lacking with SignalIO
/ signal_io()

E.g.:

  g_io_add_watch(g_io_channel_unix_new(filedescriptor),
         GIOCondition (G_IO_IN),
         &Class::callback, this);                           

The prototype for Class::callback would then be:
static gboolean Class::callback(GIOChannel* iochannel, GIOCondition cond,
gpointer data);

Here, the iochannel can be used to read/write from.

With signal_io():

  signal_io().connect(
        slot(*this, &Class::callback),
        filedescriptor, Glib::IO_IN);

The prototype will look like this:

bool Class::callback(Glib::IOCondition cond);

In the last example, I don't have the possibility to read from the file
descriptor or a iochannel. This forces me to make 'filedescriptor' a member
of the class, and I can't reuse the same callback for many different
filedescriptors.
Comment 1 Murray Cumming 2002-07-20 15:50:08 UTC
Please try to provide a patch. Maybe you can override based on
SigC::Slot type.

I have _no_ idea what this stuff does or whether it's a good idea.
Comment 2 Murray Cumming 2002-07-27 11:55:45 UTC
This will be punted unless a patch is provided soon.
Comment 3 Andreas Holzmann 2002-08-29 14:31:20 UTC
Cannot you just pass the filedescriptor to your callback via bind()?

E.g.
  signal_io().connect(
        bind(slot(*this, &Class::callback), filedescriptor),
        filedescriptor, Glib::IO_IN);

Comment 4 Morten Brix Pedersen 2002-08-29 15:06:38 UTC
You are completely right. Sorry that I missed this.