You don't need sigc::bind
here since you are not binding any additional arguments to the slot (dealing with dereferencing the member function pointer for this
is already taken care of by sigc::mem_fun
). So, this is sufficient:
_timeout_slot = sigc::mem_fun(*this, &MyWindow::on_timeout)
_connection = Glib::signal_timeout().connect(_timeout_slot, timeout_value);
A quick tip: if you can use C++11, you can just pass lambdas as arguments to connect, which makes things more readable:
_connection = Glib::signal_timeout().connect([this]{ return on_timeout(); }, timeout_value);
For this to work, you may need to add
namespace sigc{
SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE
}
Also, if you want to connect to signals of a class instance (say a Gtk::Button* btn
), you can make things even more compact by defining a macro
#define CONNECT(src, signal, ...) (src)->signal_##signal().connect(__VA_ARGS__)
which then allows you to write
CONNECT(btn, clicked, [this]{ btn_clicked_slot(); });