X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Factions.cc;h=43d2eb83c9cd84fe2c2c22664b912171bffc0525;hb=58137b83262208bb317c3dbd08f95698b409f254;hp=343dd20308476424f3af5269d7d35f15dcd2a814;hpb=105caf23daf5aed16c7ee8b904fcca2ddbd4f59f;p=ardour.git diff --git a/gtk2_ardour/actions.cc b/gtk2_ardour/actions.cc index 343dd20308..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" @@ -58,20 +58,25 @@ vector > ActionManager::playlist_selection_sensitive_actions vector > ActionManager::mouse_edit_point_requires_canvas_actions; vector > ActionManager::range_sensitive_actions; -vector > ActionManager::jack_sensitive_actions; -vector > ActionManager::jack_opposite_sensitive_actions; +vector > ActionManager::engine_sensitive_actions; +vector > ActionManager::engine_opposite_sensitive_actions; vector > ActionManager::transport_sensitive_actions; vector > ActionManager::edit_point_in_region_sensitive_actions; +static Glib::RefPtr ui_manager; void ActionManager::init () { - std::string ui_file; - ui_manager = UIManager::create (); +} + +void +ActionManager::load_menus (const string& menus_file) +{ + std::string ui_file; - find_file_in_search_path (ardour_config_search_path(), "ardour.menus", ui_file); + find_file (ardour_config_search_path(), menus_file, ui_file); bool loaded = false; @@ -80,15 +85,15 @@ ActionManager::init () 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); } } @@ -118,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) { @@ -160,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) {