diff --git a/libs/surfaces/faderport/faderport.cc b/libs/surfaces/faderport/faderport.cc index 12707ac577..4ecc71f74a 100644 --- a/libs/surfaces/faderport/faderport.cc +++ b/libs/surfaces/faderport/faderport.cc @@ -793,6 +793,30 @@ FaderPort::Button::set_action (string const& name, bool when_pressed, FaderPort: } } +string +FaderPort::Button::get_action (bool press, FaderPort::ButtonState bs) +{ + ToDoMap::iterator x; + + if (press) { + if ((x = on_press.find (bs)) == on_press.end()) { + return string(); + } + if (x->second.type != NamedAction) { + return string (); + } + return x->second.action_name; + } else { + if ((x = on_release.find (bs)) == on_release.end()) { + return string(); + } + if (x->second.type != NamedAction) { + return string (); + } + return x->second.action_name; + } +} + void FaderPort::Button::set_action (boost::function f, bool when_pressed, FaderPort::ButtonState bs) { @@ -1107,3 +1131,9 @@ FaderPort::set_action (ButtonID id, std::string const& action_name, bool on_pres { get_button(id).set_action (action_name, on_press, bs); } + +string +FaderPort::get_action (ButtonID id, bool press, ButtonState bs) +{ + return get_button(id).get_action (press, bs); +} diff --git a/libs/surfaces/faderport/faderport.h b/libs/surfaces/faderport/faderport.h index 0436e9e01e..2c08b9f847 100644 --- a/libs/surfaces/faderport/faderport.h +++ b/libs/surfaces/faderport/faderport.h @@ -156,6 +156,7 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI _current_route; @@ -221,6 +222,8 @@ class FaderPort : public ARDOUR::ControlProtocol, public AbstractUI function, bool on_press, FaderPort::ButtonState = ButtonState (0)); + std::string get_action (bool press, FaderPort::ButtonState bs = ButtonState (0)); + void set_led_state (boost::shared_ptr, int onoff, bool force = false); void invoke (ButtonState bs, bool press); bool uses_flash () const { return flash; } diff --git a/libs/surfaces/faderport/gui.cc b/libs/surfaces/faderport/gui.cc index 4dcf2920e9..e6be281c1a 100644 --- a/libs/surfaces/faderport/gui.cc +++ b/libs/surfaces/faderport/gui.cc @@ -426,22 +426,37 @@ FPGUI::build_action_combo (Gtk::ComboBox& cb, vector > const Glib::RefPtr model (Gtk::ListStore::create (action_columns)); TreeIter rowp; TreeModel::Row row; + string current_action = fp.get_action (id, true, bs); + int active_row = -1; + int n; + vector >::const_iterator i; rowp = model->append(); row = *(rowp); row[action_columns.name] = _("Disabled"); row[action_columns.path] = string(); - for (vector >::const_iterator i = actions.begin(); i != actions.end(); ++i) { + if (current_action.empty()) { + active_row = 0; + } + + for (i = actions.begin(), n = 0; i != actions.end(); ++i, ++n) { rowp = model->append(); row = *(rowp); row[action_columns.name] = i->first; row[action_columns.path] = i->second; + if (current_action == i->second) { + active_row = n+1; + } } cb.set_model (model); cb.pack_start (action_columns.name); + if (active_row >= 0) { + cb.set_active (active_row); + } + cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, id)); }