glibmm 2.34.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
Glib::SignalIO Class Reference
The Main Event Loop

`#include <glibmm/main.h>`

## Public Member Functions

sigc::connection | connect (const sigc::slot< bool, IOCondition >& slot, int fd, IOCondition condition, int priority=PRIORITY_DEFAULT)
| Connects an I/O handler that watches a file descriptor.
sigc::connection | connect (const sigc::slot< bool, IOCondition >& slot, const Glib::RefPtr< IOChannel >& channel, IOCondition condition, int priority=PRIORITY_DEFAULT)
| Connects an I/O handler that watches an I/O channel.

## Member Function Documentation

sigc::connection Glib::SignalIO::connect | ( | const sigc::slot< bool, IOCondition >& | slot,
|  | int | fd,
|  | IOCondition | condition,
|  | int | priority = `PRIORITY_DEFAULT`
| ) |  |

Connects an I/O handler that watches a file descriptor.

bool io_handler(Glib::IOCondition io_condition) { ... }
Glib::signal_io().connect(sigc::ptr_fun(&io_handler), fd, Glib::IO_IN | Glib::IO_HUP);

is equivalent to:

bool io_handler(Glib::IOCondition io_condition) { ... }
const Glib::RefPtr<Glib::IOSource> io_source = Glib::IOSource::create(fd, Glib::IO_IN | Glib::IO_HUP);
io_source->connect(sigc::ptr_fun(&io_handler));
io_source->attach(Glib::MainContext::get_default());

Parameters

  slot | A slot to call when polling fd results in an event that matches condition. The event will be passed as a parameter to slot. If `io_handler()` returns `false` the handler is disconnected.
  fd | The file descriptor (or a `HANDLE` on Win32 systems) to watch.
  condition | The conditions to watch for.
  priority | The priority of the new event source.

Returns
  A connection handle, which can be used to disconnect the handler.

sigc::connection Glib::SignalIO::connect | ( | const sigc::slot< bool, IOCondition >& | slot,
|  | const Glib::RefPtr< IOChannel >& | channel,
|  | IOCondition | condition,
|  | int | priority = `PRIORITY_DEFAULT`
| ) |  |

Connects an I/O handler that watches an I/O channel.

bool io_handler(Glib::IOCondition io_condition) { ... }
Glib::signal_io().connect(sigc::ptr_fun(&io_handler), channel, Glib::IO_IN | Glib::IO_HUP);

is equivalent to:

bool io_handler(Glib::IOCondition io_condition) { ... }
const Glib::RefPtr<Glib::IOSource> io_source = Glib::IOSource::create(channel, Glib::IO_IN | Glib::IO_HUP);
io_source->connect(sigc::ptr_fun(&io_handler));
io_source->attach(Glib::MainContext::get_default());

Parameters

  slot | A slot to call when polling channel results in an event that matches condition. The event will be passed as a parameter to slot. If `io_handler()` returns `false` the handler is disconnected.
  channel | The IOChannel object to watch.
  condition | The conditions to watch for.
  priority | The priority of the new event source.

Returns
  A connection handle, which can be used to disconnect the handler.