What's the best way to connect a GTK+ signal to a non-static member function?
I have a GUI class in c++ that uses gtk, and i want do something like this:
Gui::Gui ()
{
gtk_signal_connect(GTK_OBJECT(somObject),
"clicked",
GTK_SIGNAL_FUNC( &(this->ClickHandler) ),
NULL);
}
void Gui::ClickHandler(GtkWidget *w, gpointer data)
{
// handle the click
}
I know this doesn't work b/c the GTK_SIGNAL
_FUNC can't point to a member function unless it's a static function, so what's the best way to do this? Is it possible to use a single proxy handler function and boost::bind somehow? Here is what I tried:
gtk_signal_connect(GTK_OBJECT(somObject), "clicked",
GTK_SIGNAL_FUNC( SigHandler ),
boost::bind( &(Gui::ClickHandler), this) );
void SigHandler(GtkWidget *w, gpointer data)
{
data(w);
}
void Gui::ClickHandler(GtkWidget *w) { // handle the click }
here's the error: gui.cc: error: 'data' cannot be used as a function