mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 14:54:56 +01:00
Separate set_toggleaction_state () API
Prepare for a method consistent with access_action(): * separate group + action names * no action string parsing overhead. * no fatal, abort () call for invalid actions
This commit is contained in:
parent
e1a29c4e46
commit
bbc8c1354e
2 changed files with 26 additions and 17 deletions
|
|
@ -220,19 +220,19 @@ ActionManager::set_sensitive (vector<RefPtr<Action> >& actions, bool state)
|
|||
}
|
||||
|
||||
void
|
||||
ActionManager::check_toggleaction (string n)
|
||||
ActionManager::check_toggleaction (const string& n)
|
||||
{
|
||||
set_toggleaction_state (n, true);
|
||||
}
|
||||
|
||||
void
|
||||
ActionManager::uncheck_toggleaction (string n)
|
||||
ActionManager::uncheck_toggleaction (const string& n)
|
||||
{
|
||||
set_toggleaction_state (n, false);
|
||||
}
|
||||
|
||||
void
|
||||
ActionManager::set_toggleaction_state (string n, bool s)
|
||||
ActionManager::set_toggleaction_state (const string& n, bool s)
|
||||
{
|
||||
char const * name = n.c_str ();
|
||||
|
||||
|
|
@ -252,18 +252,27 @@ ActionManager::set_toggleaction_state (string n, bool s)
|
|||
group_name[len] = '\0';
|
||||
|
||||
const 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 (s);
|
||||
} else {
|
||||
error << string_compose (_("Unknown action name: %1"), name) << endmsg;
|
||||
if (!set_toggleaction_state (group_name, action_name, s)) {
|
||||
error << string_compose (_("Unknown action name: %1/%2"), group_name, action_name) << endmsg;
|
||||
}
|
||||
|
||||
delete [] group_name;
|
||||
}
|
||||
|
||||
bool
|
||||
ActionManager::set_toggleaction_state (const char* group_name, const char* action_name, bool s)
|
||||
{
|
||||
RefPtr<Action> act = get_action (group_name, action_name);
|
||||
if (act) {
|
||||
RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic(act);
|
||||
if (tact) {
|
||||
tact->set_active (s);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ActionManager::do_action (const char* group, const char*action)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ namespace ActionManager {
|
|||
LIBGTKMM2EXT_API extern void do_action (const char* group, const char* name);
|
||||
LIBGTKMM2EXT_API extern void set_toggle_action (const char* group, const char* name, bool);
|
||||
|
||||
LIBGTKMM2EXT_API extern void check_toggleaction (std::string);
|
||||
LIBGTKMM2EXT_API extern void uncheck_toggleaction (std::string);
|
||||
LIBGTKMM2EXT_API extern void set_toggleaction_state (std::string, bool);
|
||||
LIBGTKMM2EXT_API extern void check_toggleaction (const std::string&);
|
||||
LIBGTKMM2EXT_API extern void uncheck_toggleaction (const std::string&);
|
||||
LIBGTKMM2EXT_API extern void set_toggleaction_state (const std::string&, bool);
|
||||
LIBGTKMM2EXT_API extern bool set_toggleaction_state (const char*, const char*, bool);
|
||||
|
||||
|
||||
LIBGTKMM2EXT_API extern void save_action_states ();
|
||||
LIBGTKMM2EXT_API extern void enable_active_actions ();
|
||||
LIBGTKMM2EXT_API extern void disable_active_actions ();
|
||||
LIBGTKMM2EXT_API extern void save_action_states ();
|
||||
LIBGTKMM2EXT_API extern void enable_active_actions ();
|
||||
LIBGTKMM2EXT_API extern void disable_active_actions ();
|
||||
};
|
||||
|
||||
#endif /* __libgtkmm2ext_actions_h__ */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue