From 974e5dcc0ca4dcaebf084097728c6e3fe88781c0 Mon Sep 17 00:00:00 2001 From: Len Ovens Date: Sat, 20 Jun 2015 09:32:46 -0700 Subject: [PATCH] Add option to mackie control profile editor to remove binding (fixes #6301) --- libs/surfaces/mackie/gui.cc | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/libs/surfaces/mackie/gui.cc b/libs/surfaces/mackie/gui.cc index 105bac060c..0df0935f56 100644 --- a/libs/surfaces/mackie/gui.cc +++ b/libs/surfaces/mackie/gui.cc @@ -242,6 +242,15 @@ MackieControlProtocolGUI::build_available_action_menu () available_action_model->clear (); + /* Because there are button bindings built in that are not + in the key binding map, there needs to be a way to undo + a profile edit. */ + TreeIter rowp; + TreeModel::Row parent; + rowp = available_action_model->append(); + parent = *(rowp); + parent[available_action_columns.name] = _("Remove Binding"); + for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) { TreeModel::Row row; @@ -451,6 +460,11 @@ MackieControlProtocolGUI::refresh_function_key_editor () void MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col) { + // Remove Binding is not in the action map but still valid + bool remove (false); + if ( text == "Remove Binding") { + remove = true; + } Gtk::TreePath path(sPath); Gtk::TreeModel::iterator row = function_key_model->get_iter(path); @@ -459,17 +473,23 @@ MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib std::map::iterator i = action_map.find (text); if (i == action_map.end()) { - return; + if (!remove) { + return; + } } - Glib::RefPtr act = ActionManager::get_action (i->second.c_str()); - if (act) { + if (act || remove) { /* update visible text, using string supplied by available action model so that it matches and is found within the model. */ - (*row).set_value (col.index(), text); + if (remove) { + Glib::ustring dot = "\u2022"; + (*row).set_value (col.index(), dot); + } else { + (*row).set_value (col.index(), text); + } /* update the current DeviceProfile, using the full * path @@ -497,7 +517,12 @@ MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib modifier = 0; } - _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second); + if (remove) { + _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, ""); + } else { + _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second); + } + } else { std::cerr << "no such action\n"; }