+/** Examine the state of a Configuration setting and a toggle action, and toggle the Configuration
+ * setting if its state doesn't match the toggle action.
+ * @param group Action group.
+ * @param action Action name.
+ * @param Method to set the state of the Configuration setting.
+ * @param Method to get the state of the Configuration setting.
+ */
+void
+ActionManager::toggle_config_state (const char* group, const char* action, bool (Configuration::*set)(bool), bool (Configuration::*get)(void) const)
+{
+ Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
+ if (act) {
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+
+ if (tact) {
+ bool x = (Config->*get)();
+
+ if (x != tact->get_active()) {
+ (Config->*set) (!x);
+ }
+ }
+ }
+}
+
+void
+ActionManager::toggle_config_state (const char* group, const char* action, sigc::slot<void> theSlot)
+{
+ Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
+ if (act) {
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+ if (tact->get_active()) {
+ theSlot ();
+ }
+ }
+}
+
+
+/** Set the state of a ToggleAction using a particular Configuration get() method
+ * @param group Action group.
+ * @param action Action name.
+ * @param get Method to obtain the state that the ToggleAction should have.
+ */
+void
+ActionManager::map_some_state (const char* group, const char* action, bool (Configuration::*get)() const)
+{
+ Glib::RefPtr<Action> act = ActionManager::get_action (group, action);
+ if (act) {
+ Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
+
+ if (tact) {
+
+ bool x = (Config->*get)();
+
+ if (tact->get_active() != x) {
+ tact->set_active (x);
+ }
+ } else {
+ cerr << group << ':' << action << " is not a toggle\n";
+ }
+ } else {
+ cerr << group << ':' << action << " not an action\n";
+ }
+}