+
+void
+ActionManager::uncheck_toggleaction (const char * name)
+{
+ char *last_slash = strrchr (name, '/');
+
+ if (last_slash == 0) {
+ fatal << string_compose (_("programmer error: %1 %2"), X_("illegal toggle action name"), name) << endmsg;
+ /*NOTREACHED*/
+ return;
+ }
+
+ /* 10 = strlen ("<Actions>/") */
+ size_t len = last_slash - (name + 10);
+
+ char* group_name = new char[len+1];
+ memcpy (group_name, name + 10, len);
+ group_name[len] = '\0';
+
+ char* action_name = last_slash + 1;
+
+ RefPtr<Action> act = get_action (group_name, action_name);
+ if (act) {
+ RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
+ tact->set_active (false);
+ } else {
+ error << string_compose (_("Unknown action name: %1"), name) << endmsg;
+ }
+
+ delete [] group_name;
+}
+
+/** 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";
+ }
+}