diff --git a/libs/surfaces/cc121/cc121.h b/libs/surfaces/cc121/cc121.h index db3ef435ff..7ef9b6a063 100644 --- a/libs/surfaces/cc121/cc121.h +++ b/libs/surfaces/cc121/cc121.h @@ -150,7 +150,7 @@ class CC121 : public ARDOUR::ControlProtocol, public AbstractUI { }; enum ButtonState { - ShiftDown = 0x1, + ShiftDown = 0x1, RewindDown = 0x2, StopDown = 0x4, UserDown = 0x8, diff --git a/libs/surfaces/cc121/gui.cc b/libs/surfaces/cc121/gui.cc index c532298e48..7a36054825 100644 --- a/libs/surfaces/cc121/gui.cc +++ b/libs/surfaces/cc121/gui.cc @@ -428,45 +428,12 @@ CC121GUI::build_foot_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs) build_action_combo (cb, actions, CC121::Footswitch, bs); } -bool -CC121GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found) -{ - TreeModel::Row row = *iter; - string path = row[action_model.path()]; - - if (path == action_path) { - *found = iter; - return true; - } - - return false; -} - void CC121GUI::build_user_action_combo (Gtk::ComboBox& cb, CC121::ButtonState bs, CC121::ButtonID id) { - cb.set_model (action_model.model()); - cb.pack_start (action_model.name()); - cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs)); - - /* set the active "row" to the right value for the current button binding */ - string current_action = fp.get_action (id, false, bs); /* lookup release action */ - - if (current_action.empty()) { - cb.set_active (0); /* "disabled" */ - return; - } - - TreeModel::iterator iter = action_model.model()->children().end(); - - action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &CC121GUI::find_action_in_model), current_action, &iter)); - - if (iter != action_model.model()->children().end()) { - cb.set_active (iter); - } else { - cb.set_active (0); - } + action_model.build_action_combo (cb, current_action); + cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &CC121GUI::action_changed), &cb, id, bs)); } Glib::RefPtr diff --git a/libs/surfaces/cc121/gui.h b/libs/surfaces/cc121/gui.h index 41371ea026..6abf0f24cb 100644 --- a/libs/surfaces/cc121/gui.h +++ b/libs/surfaces/cc121/gui.h @@ -101,9 +101,6 @@ private: void build_foot_action_combo (Gtk::ComboBox&, CC121::ButtonState); void action_changed (Gtk::ComboBox*, CC121::ButtonID, CC121::ButtonState); - - bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found); - }; } diff --git a/libs/surfaces/faderport/gui.cc b/libs/surfaces/faderport/gui.cc index 279bd16087..28b5976d06 100644 --- a/libs/surfaces/faderport/gui.cc +++ b/libs/surfaces/faderport/gui.cc @@ -460,19 +460,6 @@ FPGUI::build_foot_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs) build_action_combo (cb, actions, FaderPort::Footswitch, bs); } -bool -FPGUI::find_action_in_model (const TreeModel::iterator& iter, std::string const & action_path, TreeModel::iterator* found) -{ - TreeModel::Row row = *iter; - string path = row[action_model.path()]; - - if (path == action_path) { - *found = iter; - return true; - } - - return false; -} void FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs) @@ -480,28 +467,12 @@ FPGUI::build_user_action_combo (Gtk::ComboBox& cb, FaderPort::ButtonState bs) #ifndef MIXBUS bs = FaderPort::ButtonState (bs|FaderPort::UserDown); #endif - cb.set_model (action_model.model()); - cb.pack_start (action_model.name()); - cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs)); /* set the active "row" to the right value for the current button binding */ string current_action = fp.get_action (FaderPort::User, false, bs); /* lookup release action */ - - if (current_action.empty()) { - cb.set_active (0); /* "disabled" */ - return; - } - - TreeModel::iterator iter = action_model.model()->children().end(); - - action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FPGUI::find_action_in_model), current_action, &iter)); - - if (iter != action_model.model()->children().end()) { - cb.set_active (iter); - } else { - cb.set_active (0); - } + action_model.build_action_combo (cb, current_action); + cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FPGUI::action_changed), &cb, FaderPort::User, bs)); } diff --git a/libs/surfaces/faderport/gui.h b/libs/surfaces/faderport/gui.h index 60ad81d75f..fc9c92677a 100644 --- a/libs/surfaces/faderport/gui.h +++ b/libs/surfaces/faderport/gui.h @@ -99,9 +99,6 @@ private: void build_foot_action_combo (Gtk::ComboBox&, FaderPort::ButtonState); void action_changed (Gtk::ComboBox*, FaderPort::ButtonID, FaderPort::ButtonState); - - bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found); - }; } diff --git a/libs/surfaces/faderport8/gui.cc b/libs/surfaces/faderport8/gui.cc index a4b0b9b172..dffa1b7651 100644 --- a/libs/surfaces/faderport8/gui.cc +++ b/libs/surfaces/faderport8/gui.cc @@ -341,43 +341,13 @@ FP8GUI::active_port_changed (Gtk::ComboBox* combo, bool for_input) -bool -FP8GUI::find_action_in_model (const TreeModel::iterator& iter, std::string const& action_path, TreeModel::iterator* found) -{ - TreeModel::Row row = *iter; - string path = row[action_model.path()]; - - if (path == action_path) { - *found = iter; - return true; - } - - return false; -} void FP8GUI::build_action_combo (Gtk::ComboBox& cb, FP8Controls::ButtonId id) { - cb.set_model (action_model.model()); - cb.pack_start (action_model.name()); - /* set the active "row" to the right value for the current button binding */ string current_action = fp.get_button_action (id, false); /* lookup release action */ - - if (current_action.empty()) { - cb.set_active (0); /* "disabled" */ - } else { - TreeModel::iterator iter = action_model.model()->children().end(); - - action_model.model()->foreach_iter (sigc::bind (sigc::mem_fun (*this, &FP8GUI::find_action_in_model), current_action, &iter)); - - if (iter != action_model.model()->children().end()) { - cb.set_active (iter); - } else { - cb.set_active (0); - } - } - /* bind signal _after_ setting the current value */ + action_model.build_action_combo(cb, current_action); cb.signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &FP8GUI::action_changed), &cb, id)); } diff --git a/libs/surfaces/faderport8/gui.h b/libs/surfaces/faderport8/gui.h index 8b8eacd2d7..b29e36d78c 100644 --- a/libs/surfaces/faderport8/gui.h +++ b/libs/surfaces/faderport8/gui.h @@ -98,8 +98,6 @@ private: const ActionManager::ActionModel& action_model; std::map action_map; // map from action names to paths - - bool find_action_in_model (const Gtk::TreeModel::iterator& iter, std::string const & action_path, Gtk::TreeModel::iterator* found); }; } }