gtkmm Notebook signal_switch_page().connect

Asked by Massimiliano Maniscalco

I'm developing a program in C++ using gtkmm 2.4 on a Ubuntu 11.04 system.
I created a GUI using Glade, I have a Window with a Notebook of 4 pages. I need to connect the signal_switch_page to a callback function of an object class.
The function member is declared as follow:
void Controller::
onMainPageSwitch ( Gtk::Widget *page, guint page_num )
{
    ...do something here...
}

The signals are connected in this function:
void Controller::
connectSignals ( void )
{
 _addToolButton->signal_clicked ().connect (sigc::mem_fun (this, &Controller::onAddToolClicked) );
 _remToolButton->signal_clicked ().connect (sigc::mem_fun (this, &Controller::onRemToolClicked) );
 _mainNotebook->signal_switch_page ().connect (sigc::mem_fun (this, &Controller::onMainPageSwitch) );
}

the _mainNotebook connection doesn't compile with gtkmm 2.4 (while I had not problem when compiling with gtkmm 3.0),
the compiler error is:

/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103:39: error: no match for call to ‘(sigc::bound_mem_functor0<void, Controller>) (_GtkNotebookPage* const&, const unsigned int&)’
/usr/include/sigc++-2.0/sigc++/functors/mem_fun.h:1786:12: note: candidate is: T_return sigc::bound_mem_functor0<T_return, T_obj>::operator()() const [with T_return = void, T_obj = Controller]
/usr/include/sigc++-2.0/sigc++/adaptors/adaptor_trait.h:103:39: error: return-statement with a value, in function returning 'void'

Does anyone know how to fix it to make it works with gtkmm 2.4 ?
I tried to remove the parameters from the onMainPageSwitch but the error is the same.

Please help

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu gtkmm2.4 Edit question
Assignee:
No assignee Edit question
Solved by:
Massimiliano Maniscalco
Solved:
Last query:
Last reply:
Revision history for this message
Massimiliano Maniscalco (massi-neptune) said :
#1

I understood what is the problem. The code I wrote was OK for gtkmm 3.0, but to make it works with gtkmm 2.4 is enough to change the first parameter type of the callback method from Gtk::Widget* to GtkNotebookPage*.

So the correct method is:

void Controller::onMainPageSwitch ( GtkNotebookPage *page, guint page_num )
{
      ... do something ....
}

It is very annoying that the on-line reference pages are talking only about gtkmm 3.0 and I had to search a lot to find informations about gtkmm 2.4.

Hope this will be help full to anyone who got the same problem with gtkmm.