X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Factions.cc;h=43d2eb83c9cd84fe2c2c22664b912171bffc0525;hb=62a2d6a0647cd636f8711acceccc22142bb899aa;hp=bdb6821f89933a290e27562c44270c258173702a;hpb=59cdb46c2fed1faf3ae7828198d4da5c5874e59f;p=ardour.git diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index bdb6821f89..43d2eb83c9 100644 --- a/gtk2_ardour/actions.cc +++ b/gtk2_ardour/actions.cc @@ -36,7 +36,7 @@ #include "gtkmm2ext/actions.h" -#include "utils.h" +#include "ardour_ui.h" #include "actions.h" #include "i18n.h" @@ -76,7 +76,7 @@ ActionManager::load_menus (const string& menus_file) { std::string ui_file; - find_file_in_search_path (ardour_config_search_path(), menus_file, ui_file); + find_file (ardour_config_search_path(), menus_file, ui_file); bool loaded = false; @@ -85,15 +85,15 @@ ActionManager::load_menus (const string& menus_file) info << string_compose (_("Loading menus from %1"), ui_file) << endmsg; loaded = true; } catch (Glib::MarkupError& err) { - error << string_compose (_("badly formatted UI definition file: %1"), err.what()) << endmsg; - cerr << string_compose (_("badly formatted UI definition file: %1"), err.what()) << endl; + error << string_compose (_("badly formatted menu definition file: %1"), err.what()) << endmsg; + cerr << string_compose (_("badly formatted menu definition file: %1"), err.what()) << endl; } catch (...) { error << string_compose (_("%1 menu definition file not found"), PROGRAM_NAME) << endmsg; } if (!loaded) { - cerr << string_compose (_("%1 will not work without a valid ardour.menus file"), PROGRAM_NAME) << endl; - error << string_compose (_("%1 will not work without a valid ardour.menus file"), PROGRAM_NAME) << endmsg; + cerr << string_compose (_("%1 will not work without a valid menu definition file"), PROGRAM_NAME) << endl; + error << string_compose (_("%1 will not work without a valid menu definition file"), PROGRAM_NAME) << endmsg; exit(1); } } @@ -123,6 +123,31 @@ ActionManager::toggle_config_state (const char* group, const char* action, bool } } +/** 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 (UIConfiguration::*set)(bool), bool (UIConfiguration::*get)(void) const) +{ + Glib::RefPtr act = ActionManager::get_action (group, action); + + if (act) { + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + + if (tact) { + bool x = (ARDOUR_UI::config()->*get)(); + + if (x != tact->get_active()) { + (ARDOUR_UI::config()->*set) (!x); + } + } + } +} + void ActionManager::toggle_config_state_foo (const char* group, const char* action, sigc::slot set, sigc::slot get) { @@ -165,6 +190,29 @@ ActionManager::map_some_state (const char* group, const char* action, bool (RCCo } } +/** 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 (UIConfiguration::*get)() const) +{ + Glib::RefPtr act = ActionManager::get_action (group, action); + if (act) { + Glib::RefPtr tact = Glib::RefPtr::cast_dynamic(act); + + if (tact) { + + bool x = (ARDOUR_UI::config()->*get)(); + + if (tact->get_active() != x) { + tact->set_active (x); + } + } + } +} + void ActionManager::map_some_state (const char* group, const char* action, sigc::slot get) {