enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / mackie / gui.cc
index 61ca6504cb844ed5db005c89f73b7f24e0837e1f..06786197e2b0be6a000a03f801326de4c4a37f24 100644 (file)
@@ -34,6 +34,7 @@
 #include "pbd/stacktrace.h"
 
 #include "gtkmm2ext/actions.h"
+#include "gtkmm2ext/bindings.h"
 #include "gtkmm2ext/gui_thread.h"
 #include "gtkmm2ext/utils.h"
 
@@ -47,7 +48,7 @@
 #include "surface.h"
 #include "surface_port.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -203,9 +204,11 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        vector<string> profiles;
 
        for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
+               cerr << "add discovered profile " << i->first << endl;
                profiles.push_back (i->first);
        }
        Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
+       cerr << "set active profile from " << p.device_profile().name() << endl;
        _profile_combo.set_active_text (p.device_profile().name());
        _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::profile_combo_changed));
 
@@ -449,12 +452,13 @@ MackieControlProtocolGUI::build_available_action_menu ()
        vector<string> labels;
        vector<string> tooltips;
        vector<string> keys;
-       vector<AccelKey> bindings;
+       vector<Glib::RefPtr<Gtk::Action> > actions;
+
        typedef std::map<string,TreeIter> NodeMap;
        NodeMap nodes;
        NodeMap::iterator r;
 
-       ActionManager::get_all_actions (labels, paths, tooltips, keys, bindings);
+       Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
 
        vector<string>::iterator k;
        vector<string>::iterator p;
@@ -464,8 +468,9 @@ 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. */
+          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();
@@ -487,7 +492,6 @@ MackieControlProtocolGUI::build_available_action_menu ()
        parent = *(rowp);
        parent[available_action_columns.name] = _("CmdAlt");
 
-
        for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
 
                TreeModel::Row row;
@@ -618,54 +622,68 @@ MackieControlProtocolGUI::refresh_function_key_editor ()
                string action;
                const string defstring = "\u2022";
 
-               action = dp.get_button_action (bid, 0);
-               if (action.empty()) {
-                       row[function_key_columns.plain] = defstring;
-               } else {
-                       if (action.find ('/') == string::npos) {
-                               /* Probably a key alias */
-                               row[function_key_columns.plain] = action;
-                       } else {
+               /* We only allow plain bindings for Fn keys. All others are
+                * reserved for hard-coded actions.
+                */
 
-                               act = ActionManager::get_action (action.c_str());
-                               if (act) {
-                                       row[function_key_columns.plain] = act->get_label();
+               if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
+
+                       action = dp.get_button_action (bid, 0);
+                       if (action.empty()) {
+                               row[function_key_columns.plain] = defstring;
+                       } else {
+                               if (action.find ('/') == string::npos) {
+                                       /* Probably a key alias */
+                                       row[function_key_columns.plain] = action;
                                } else {
-                                       row[function_key_columns.plain] = defstring;
+
+                                       act = ActionManager::get_action (action.c_str());
+                                       if (act) {
+                                               row[function_key_columns.plain] = act->get_label();
+                                       } else {
+                                               row[function_key_columns.plain] = defstring;
+                                       }
                                }
                        }
                }
 
-               action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
-               if (action.empty()) {
-                       row[function_key_columns.control] = defstring;
-               } else {
-                       if (action.find ('/') == string::npos) {
-                               /* Probably a key alias */
-                               row[function_key_columns.control] = action;
+               /* We only allow plain bindings for Fn keys. All others are
+                * reserved for hard-coded actions.
+                */
+
+               if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
+
+                       action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
+                       if (action.empty()) {
+                               row[function_key_columns.shift] = defstring;
                        } else {
-                               act = ActionManager::get_action (action.c_str());
-                               if (act) {
-                                       row[function_key_columns.control] = act->get_label();
+                               if (action.find ('/') == string::npos) {
+                                       /* Probably a key alias */
+                                       row[function_key_columns.shift] = action;
                                } else {
-                                       row[function_key_columns.control] = defstring;
+                                       act = ActionManager::get_action (action.c_str());
+                                       if (act) {
+                                               row[function_key_columns.shift] = act->get_label();
+                                       } else {
+                                               row[function_key_columns.shift] = defstring;
+                                       }
                                }
                        }
                }
 
-               action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
+               action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
                if (action.empty()) {
-                       row[function_key_columns.shift] = defstring;
+                       row[function_key_columns.control] = defstring;
                } else {
                        if (action.find ('/') == string::npos) {
                                /* Probably a key alias */
-                               row[function_key_columns.shift] = action;
+                               row[function_key_columns.control] = action;
                        } else {
                                act = ActionManager::get_action (action.c_str());
                                if (act) {
-                                       row[function_key_columns.shift] = act->get_label();
+                                       row[function_key_columns.control] = act->get_label();
                                } else {
-                                       row[function_key_columns.shift] = defstring;
+                                       row[function_key_columns.control] = defstring;
                                }
                        }
                }