From 80c594555c3ac4ff914b6b599e7acfb48766a223 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 20 Jan 2015 22:05:30 -0500 Subject: [PATCH] add keybinding whitelist support --- gtk2_ardour/keyeditor.cc | 36 +++++++++++++++++++++++++----------- gtk2_ardour/keyeditor.h | 3 ++- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/keyeditor.cc b/gtk2_ardour/keyeditor.cc index 67da173750..6aeb3bf467 100644 --- a/gtk2_ardour/keyeditor.cc +++ b/gtk2_ardour/keyeditor.cc @@ -114,24 +114,32 @@ KeyEditor::KeyEditor () unbind_button.set_sensitive (false); - load_blacklist (); + load_blackwhitelists (); } void -KeyEditor::load_blacklist () +KeyEditor::load_blackwhitelists () { - string blacklist; + string list; - if (!find_file (ARDOUR::ardour_data_search_path(), X_("keybindings.blacklist"), blacklist)) { - return; + if (find_file (ARDOUR::ardour_data_search_path(), X_("keybindings.blacklist"), list)) { + ifstream in (list.c_str()); + + while (in) { + string str; + in >> str; + action_blacklist.insert (make_pair (str, str)); + } } - ifstream in (blacklist.c_str()); - - while (in) { - string str; - in >> str; - action_blacklist.insert (make_pair (str, str)); + if (find_file (ARDOUR::ardour_data_search_path(), X_("keybindings.whitelist"), list)) { + ifstream in (list.c_str()); + + while (in) { + string str; + in >> str; + action_whitelist.insert (make_pair (str, str)); + } } } @@ -274,9 +282,15 @@ KeyEditor::populate () string without_action = (*p).substr (9); if (action_blacklist.find (without_action) != action_blacklist.end()) { + /* this action is in the blacklist */ continue; } + if (!action_whitelist.empty() && action_whitelist.find (without_action) == action_whitelist.end()) { + /* there is a whitelist, and this action isn't in it */ + continue; + } + parts.clear (); split (*p, parts, '/'); diff --git a/gtk2_ardour/keyeditor.h b/gtk2_ardour/keyeditor.h index 4627324824..e2b4a48a95 100644 --- a/gtk2_ardour/keyeditor.h +++ b/gtk2_ardour/keyeditor.h @@ -77,7 +77,8 @@ class KeyEditor : public ArdourWindow void reset (); std::map action_blacklist; - void load_blacklist (); + std::map action_whitelist; + void load_blackwhitelists (); }; #endif /* __ardour_gtk_key_editor_h__ */