I'm trying to make multiple Gtk::ToggleButton's to act as Gtk::RadioButton's. When one of the buttons is pressed that other switch off.
It would be as simple as creating a switch statement if Gtk::ToggleButton didn't handle switching (pressed or not pressed) on its own.
So, I'm planning to handle it's switching as regular button with calling signal_clicked().connect() which calls for function set_active(true/false) which makes button look pressed or not pressed.
Here is example of what I'm trying to do:
Event calls when button is clicked:
//enum {infoState, artState, editState, userState, exitState}; is initialised in header
artButt.signal_clicked().connect(sigc::bind<short int>(sigc::mem_fun(*this, &fooclass::toggleButton), artButt));
editButt.signal_clicked().connect(sigc::bind<short int>(sigc::mem_fun(*this, &fooclass::toggleButton), editButt));
Toggling button:
void fooClass::toggleButton()
{
//oldState and enum {infoState, artState, editState, userState, exitState}; are initialised in header
if(oldState != newState)
{
//disable old togglebutton
switch (oldState)
{
case infoState:
infoButt.set_active(false);
break;
case artState:
artButt.set_active(false);
break;
case editState:
editButt.set_active(false);
break;
case userState:
userButt.set_active(false);
break;
}
//enable new one
switch (newState)
{
case infoState:
userButt.set_active(false);
break;
case artState:
artButt.set_active(true);
break;
case editState:
editButt.set_active(true);
break;
case userState:
userButt.set_active(true);
break;
}
oldState = newState;
}
}
Just useGtk::RadioButton
directly. With the draw-indicator
property you can make them look like regular toggle buttons.