diff --git a/gtk2_ardour/ardour.menus.in b/gtk2_ardour/ardour.menus.in
index 72dff39e3e..117cb8004b 100644
--- a/gtk2_ardour/ardour.menus.in
+++ b/gtk2_ardour/ardour.menus.in
@@ -432,8 +432,6 @@
-
diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h
index 64d7ce04a1..89646dc3d3 100644
--- a/gtk2_ardour/ardour_ui.h
+++ b/gtk2_ardour/ardour_ui.h
@@ -494,7 +494,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void use_menubar_as_top_menubar ();
void build_menu_bar ();
- void build_control_surface_menu ();
Gtk::Label wall_clock_label;
Gtk::EventBox wall_clock_box;
@@ -685,9 +684,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI
void mtc_port_changed ();
void parameter_changed (std::string);
- void toggle_control_protocol (ARDOUR::ControlProtocolInfo*);
- void toggle_control_protocol_feedback (ARDOUR::ControlProtocolInfo*, const char* group_name, std::string action_name);
-
bool first_idle ();
void no_memory_warning ();
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc
index 61bb5d6ef7..8d70f725f2 100644
--- a/gtk2_ardour/ardour_ui_ed.cc
+++ b/gtk2_ardour/ardour_ui_ed.cc
@@ -91,7 +91,6 @@ ARDOUR_UI::install_actions ()
ActionManager::register_action (main_actions, X_("Files"), _("Import/Export"));
ActionManager::register_action (main_actions, X_("Cleanup"), _("Cleanup"));
ActionManager::register_action (main_actions, X_("Sync"), _("Sync"));
- ActionManager::register_action (main_actions, X_("Options"), _("Options"));
ActionManager::register_action (main_actions, X_("TransportOptions"), _("Options"));
ActionManager::register_action (main_actions, X_("Help"), _("Help"));
ActionManager::register_action (main_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
@@ -450,52 +449,6 @@ ARDOUR_UI::install_actions ()
ActionManager::add_action_group (common_actions);
}
-void
-ARDOUR_UI::toggle_control_protocol (ControlProtocolInfo* cpi)
-{
- if (!session) {
- /* this happens when we build the menu bar when control protocol support
- has been used in the past for some given protocol - the item needs
- to be made active, but there is no session yet.
- */
- return;
- }
-
- if (cpi->protocol == 0) {
- ControlProtocolManager::instance().instantiate (*cpi);
- } else {
- ControlProtocolManager::instance().teardown (*cpi);
- }
-}
-
-void
-ARDOUR_UI::toggle_control_protocol_feedback (ControlProtocolInfo* cpi, const char* group, string action)
-{
- if (!session) {
- /* this happens when we build the menu bar when control protocol support
- has been used in the past for some given protocol - the item needs
- to be made active, but there is no session yet.
- */
- return;
- }
-
- if (cpi->protocol) {
- Glib::RefPtr act = ActionManager::get_action (group, action.c_str());
-
- if (act) {
- Glib::RefPtr tact = Glib::RefPtr::cast_dynamic (act);
-
- if (tact) {
- bool x = tact->get_active();
-
- if (x != cpi->protocol->get_feedback()) {
- cpi->protocol->set_feedback (x);
- }
- }
- }
- }
-}
-
void
ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
{
@@ -547,84 +500,9 @@ ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
}
}
-void
-ARDOUR_UI::build_control_surface_menu ()
-{
- list::iterator i;
- bool with_feedback;
-
- /* !!! this has to match the top level entry from ardour.menus */
-
- string ui = "\n"
- "\n\n";
-
- ActionManager::ui_manager->add_ui_from_string (ui);
-}
-
void
ARDOUR_UI::build_menu_bar ()
{
- if (!Profile->get_sae()) {
- build_control_surface_menu ();
- }
-
menu_bar = dynamic_cast (ActionManager::get_widget (X_("/Main")));
menu_bar->set_name ("MainMenuBar");
diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc
index 1bd437ab8a..c1a5897265 100644
--- a/gtk2_ardour/rc_option_editor.cc
+++ b/gtk2_ardour/rc_option_editor.cc
@@ -6,6 +6,8 @@
#include "midi++/manager.h"
#include "midi++/factory.h"
#include "ardour/rc_configuration.h"
+#include "ardour/control_protocol_manager.h"
+#include "control_protocol/control_protocol.h"
#include "rc_option_editor.h"
#include "utils.h"
#include "midi_port_dialog.h"
@@ -30,6 +32,8 @@ public:
_store = ListStore::create (_model);
_view.set_model (_store);
_view.append_column (_("Name"), _model.name);
+ _view.get_column(0)->set_resizable (true);
+ _view.get_column(0)->set_expand (true);
_view.append_column_editable (_("Online"), _model.online);
_view.append_column_editable (_("Trace input"), _model.trace_input);
_view.append_column_editable (_("Trace output"), _model.trace_output);
@@ -689,6 +693,101 @@ private:
HScale _dpi_slider;
};
+
+class ControlSurfacesOptions : public OptionEditorBox
+{
+public:
+ ControlSurfacesOptions ()
+ {
+ _store = ListStore::create (_model);
+ _view.set_model (_store);
+ _view.append_column (_("Name"), _model.name);
+ _view.get_column(0)->set_resizable (true);
+ _view.get_column(0)->set_expand (true);
+ _view.append_column_editable (_("Enabled"), _model.enabled);
+ _view.append_column_editable (_("Feedback"), _model.feedback);
+
+ _box->pack_start (_view, false, false);
+
+ _store->signal_row_changed().connect (mem_fun (*this, &ControlSurfacesOptions::model_changed));
+ }
+
+ void parameter_changed (std::string const &)
+ {
+
+ }
+
+ void set_state_from_config ()
+ {
+ _store->clear ();
+
+ ControlProtocolManager& m = ControlProtocolManager::instance ();
+ for (list::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
+
+ if (!(*i)->mandatory) {
+ TreeModel::Row r = *_store->append ();
+ r[_model.name] = (*i)->name;
+ r[_model.enabled] = ((*i)->protocol || (*i)->requested);
+ r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
+ r[_model.protocol_info] = *i;
+ }
+ }
+ }
+
+private:
+
+ void model_changed (TreeModel::Path const & p, TreeModel::iterator const & i)
+ {
+ TreeModel::Row r = *i;
+
+ ControlProtocolInfo* cpi = r[_model.protocol_info];
+ if (!cpi) {
+ return;
+ }
+
+ bool const was_enabled = (cpi->protocol != 0);
+ bool const is_enabled = r[_model.enabled];
+
+ if (was_enabled != is_enabled) {
+ if (!was_enabled) {
+ ControlProtocolManager::instance().instantiate (*cpi);
+ } else {
+ ControlProtocolManager::instance().teardown (*cpi);
+ }
+ }
+
+ bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
+ bool const is_feedback = r[_model.feedback];
+
+ if (was_feedback != is_feedback && cpi->protocol) {
+ cpi->protocol->set_feedback (is_feedback);
+ }
+ }
+
+ class ControlSurfacesModelColumns : public TreeModelColumnRecord
+ {
+ public:
+
+ ControlSurfacesModelColumns ()
+ {
+ add (name);
+ add (enabled);
+ add (feedback);
+ add (protocol_info);
+ }
+
+ TreeModelColumn name;
+ TreeModelColumn enabled;
+ TreeModelColumn feedback;
+ TreeModelColumn protocol_info;
+ };
+
+ Glib::RefPtr _store;
+ ControlSurfacesModelColumns _model;
+ TreeView _view;
+};
+
+
RCOptionEditor::RCOptionEditor ()
: OptionEditor (Config, _("Ardour Preferences")),
_rc_config (Config)
@@ -734,19 +833,6 @@ RCOptionEditor::RCOptionEditor ()
add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
- ComboOption* rm = new ComboOption (
- "remote-model",
- _("Control surface remote ID"),
- mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
- mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
- );
-
- rm->add (UserOrdered, _("assigned by user"));
- rm->add (MixerOrdered, _("follows order of mixer"));
- rm->add (EditorOrdered, _("follows order of editor"));
-
- add_option (_("Misc"), rm);
-
#ifndef GTKOSX
/* font scaling does nothing with GDK/Quartz */
add_option (_("Misc"), new FontScalingOptions (_rc_config));
@@ -1082,6 +1168,23 @@ RCOptionEditor::RCOptionEditor ()
-1, 65536, 1, 10
));
+ /* CONTROL SURFACES */
+
+ add_option (_("Control surfaces"), new ControlSurfacesOptions);
+
+ ComboOption* rm = new ComboOption (
+ "remote-model",
+ _("Control surface remote ID"),
+ mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
+ mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
+ );
+
+ rm->add (UserOrdered, _("assigned by user"));
+ rm->add (MixerOrdered, _("follows order of mixer"));
+ rm->add (EditorOrdered, _("follows order of editor"));
+
+ add_option (_("Control surfaces"), rm);
+
/* CLICK */
add_option (_("Click"), new ClickOptions (_rc_config, this));