remove "New Return" menu option from processor box; make return toggle processor...
[ardour.git] / gtk2_ardour / rc_option_editor.cc
1 #include <gtkmm/liststore.h>
2 #include <gtkmm/stock.h>
3 #include <gtkmm/scale.h>
4 #include <gtkmm2ext/utils.h>
5 #include <gtkmm2ext/slider_controller.h>
6 #include "pbd/fpu.h"
7 #include "midi++/manager.h"
8 #include "midi++/factory.h"
9 #include "ardour/dB.h"
10 #include "ardour/rc_configuration.h"
11 #include "ardour/control_protocol_manager.h"
12 #include "control_protocol/control_protocol.h"
13 #include "rc_option_editor.h"
14 #include "utils.h"
15 #include "midi_port_dialog.h"
16 #include "sfdb_ui.h"
17 #include "keyboard.h"
18 #include "i18n.h"
19
20 using namespace std;
21 using namespace sigc;
22 using namespace Gtk;
23 using namespace Gtkmm2ext;
24 using namespace PBD;
25 using namespace ARDOUR;
26
27 class MIDIPorts : public OptionEditorBox
28 {
29 public:
30         MIDIPorts (RCConfiguration* c, list<ComboOption<string>* > const & o)
31                 : _rc_config (c),
32                   _add_port_button (Stock::ADD),
33                   _port_combos (o)
34         {
35                 _store = ListStore::create (_model);
36                 _view.set_model (_store);
37                 _view.append_column (_("Name"), _model.name);
38                 _view.get_column(0)->set_resizable (true);
39                 _view.get_column(0)->set_expand (true);
40                 _view.append_column_editable (_("Online"), _model.online);
41                 _view.append_column_editable (_("Trace input"), _model.trace_input);
42                 _view.append_column_editable (_("Trace output"), _model.trace_output);
43
44                 HBox* h = manage (new HBox);
45                 h->set_spacing (4);
46                 h->pack_start (_view, true, true);
47
48                 VBox* v = manage (new VBox);
49                 v->set_spacing (4);
50                 v->pack_start (_add_port_button, false, false);
51                 h->pack_start (*v, false, false);
52
53                 _box->pack_start (*h);
54
55                 ports_changed ();
56
57                 _store->signal_row_changed().connect (mem_fun (*this, &MIDIPorts::model_changed));
58
59                 _add_port_button.signal_clicked().connect (mem_fun (*this, &MIDIPorts::add_port_clicked));
60         }
61
62         void parameter_changed (string const &) {}
63         void set_state_from_config () {}
64
65 private:
66
67         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
68         {
69                 TreeModel::Row r = *i;
70
71                 MIDI::Port* port = r[_model.port];
72                 if (!port) {
73                         return;
74                 }
75
76                 if (port->input()) {
77
78                         if (r[_model.online] == port->input()->offline()) {
79                                 port->input()->set_offline (!r[_model.online]);
80                         }
81
82                         if (r[_model.trace_input] != port->input()->tracing()) {
83                                 port->input()->trace (r[_model.trace_input], &cerr, string (port->name()) + _(" input: "));
84                         }
85                 }
86
87                 if (port->output()) {
88
89                         if (r[_model.trace_output] != port->output()->tracing()) {
90                                 port->output()->trace (r[_model.trace_output], &cerr, string (port->name()) + _(" output: "));
91                         }
92
93                 }
94         }
95
96         void setup_ports_combo (ComboOption<string>* c)
97         {
98                 c->clear ();
99                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
100                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
101                         c->add ((*i)->name(), (*i)->name());
102                 }
103         }       
104
105         void ports_changed ()
106         {
107                 /* XXX: why is this coming from here? */
108                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
109
110                 _store->clear ();
111
112                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
113
114                         TreeModel::Row r = *_store->append ();
115
116                         r[_model.name] = (*i)->name();
117
118                         if ((*i)->input()) {
119                                 r[_model.online] = !(*i)->input()->offline();
120                                 (*i)->input()->OfflineStatusChanged.connect (bind (mem_fun (*this, &MIDIPorts::port_offline_changed), (*i)));
121                                 r[_model.trace_input] = (*i)->input()->tracing();
122                         }
123
124                         if ((*i)->output()) {
125                                 r[_model.trace_output] = (*i)->output()->tracing();
126                         }
127
128                         r[_model.port] = (*i);
129                 }
130
131                 for (list<ComboOption<string>* >::iterator i = _port_combos.begin(); i != _port_combos.end(); ++i) {
132                         setup_ports_combo (*i);
133                 }
134         }
135
136         void port_offline_changed (MIDI::Port* p)
137         {
138                 if (!p->input()) {
139                         return;
140                 }
141
142                 for (TreeModel::Children::iterator i = _store->children().begin(); i != _store->children().end(); ++i) {
143                         if ((*i)[_model.port] == p) {
144                                 (*i)[_model.online] = !p->input()->offline();
145                         }
146                 }
147         }
148
149         void add_port_clicked ()
150         {
151                 MidiPortDialog dialog;
152
153                 dialog.set_position (WIN_POS_MOUSE);
154
155                 dialog.show ();
156
157                 int const r = dialog.run ();
158
159                 switch (r) {
160                 case RESPONSE_ACCEPT:
161                         break;
162                 default:
163                         return;
164                         break;
165                 }
166
167                 Glib::ustring const mode = dialog.port_mode_combo.get_active_text ();
168                 string smod;
169
170                 if (mode == _("input")) {
171                         smod = X_("input");
172                 } else if (mode == (_("output"))) {
173                         smod = X_("output");
174                 } else {
175                         smod = "duplex";
176                 }
177
178                 XMLNode node (X_("MIDI-port"));
179
180                 node.add_property ("tag", dialog.port_name.get_text());
181                 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
182                 node.add_property ("type", MIDI::PortFactory::default_port_type());
183                 node.add_property ("mode", smod);
184
185                 if (MIDI::Manager::instance()->add_port (node) != 0) {
186                         ports_changed ();
187                 }
188         }
189
190         class MIDIModelColumns : public TreeModelColumnRecord
191         {
192         public:
193                 MIDIModelColumns ()
194                 {
195                         add (name);
196                         add (online);
197                         add (trace_input);
198                         add (trace_output);
199                         add (port);
200                 }
201
202                 TreeModelColumn<string> name;
203                 TreeModelColumn<bool> online;
204                 TreeModelColumn<bool> trace_input;
205                 TreeModelColumn<bool> trace_output;
206                 TreeModelColumn<MIDI::Port*> port;
207         };
208
209         RCConfiguration* _rc_config;
210         Glib::RefPtr<ListStore> _store;
211         MIDIModelColumns _model;
212         TreeView _view;
213         Button _add_port_button;
214         ComboBoxText _mtc_combo;
215         ComboBoxText _midi_clock_combo;
216         ComboBoxText _mmc_combo;
217         ComboBoxText _mpc_combo;
218         list<ComboOption<string>* > _port_combos;
219 };
220
221
222 class ClickOptions : public OptionEditorBox
223 {
224 public:
225         ClickOptions (RCConfiguration* c, ArdourDialog* p)
226                 : _rc_config (c),
227                   _parent (p)
228         {
229                 Table* t = manage (new Table (2, 3));
230                 t->set_spacings (4);
231
232                 Label* l = manage (new Label (_("Click audio file:")));
233                 l->set_alignment (0, 0.5);
234                 t->attach (*l, 0, 1, 0, 1, FILL);
235                 t->attach (_click_path_entry, 1, 2, 0, 1, FILL);
236                 Button* b = manage (new Button (_("Browse...")));
237                 b->signal_clicked().connect (mem_fun (*this, &ClickOptions::click_browse_clicked));
238                 t->attach (*b, 2, 3, 0, 1, FILL);
239
240                 l = manage (new Label (_("Click emphasis audio file:")));
241                 l->set_alignment (0, 0.5);
242                 t->attach (*l, 0, 1, 1, 2, FILL);
243                 t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL);
244                 b = manage (new Button (_("Browse...")));
245                 b->signal_clicked().connect (mem_fun (*this, &ClickOptions::click_emphasis_browse_clicked));
246                 t->attach (*b, 2, 3, 1, 2, FILL);
247
248                 _box->pack_start (*t, false, false);
249         }
250
251         void parameter_changed (string const & p)
252         {
253                 if (p == "click-sound") {
254                         _click_path_entry.set_text (_rc_config->get_click_sound());
255                 } else if (p == "click-emphasis-sound") {
256                         _click_emphasis_path_entry.set_text (_rc_config->get_click_emphasis_sound());
257                 }
258         }
259
260         void set_state_from_config ()
261         {
262                 parameter_changed ("click-sound");
263                 parameter_changed ("click-emphasis-sound");
264         }
265
266 private:
267
268         void click_browse_clicked ()
269         {
270                 SoundFileChooser sfdb (*_parent, _("Choose Click"));
271
272                 sfdb.show_all ();
273                 sfdb.present ();
274
275                 if (sfdb.run () == RESPONSE_OK) {
276                         click_chosen (sfdb.get_filename());
277                 }
278         }
279
280         void click_chosen (string const & path)
281         {
282                 _click_path_entry.set_text (path);
283                 _rc_config->set_click_sound (path);
284         }
285
286         void click_emphasis_browse_clicked ()
287         {
288                 SoundFileChooser sfdb (*_parent, _("Choose Click Emphasis"));
289
290                 sfdb.show_all ();
291                 sfdb.present ();
292
293                 if (sfdb.run () == RESPONSE_OK) {
294                         click_emphasis_chosen (sfdb.get_filename());
295                 }
296         }
297
298         void click_emphasis_chosen (string const & path)
299         {
300                 _click_emphasis_path_entry.set_text (path);
301                 _rc_config->set_click_emphasis_sound (path);
302         }
303
304         RCConfiguration* _rc_config;
305         ArdourDialog* _parent;
306         Entry _click_path_entry;
307         Entry _click_emphasis_path_entry;
308 };
309
310 class UndoOptions : public OptionEditorBox
311 {
312 public:
313         UndoOptions (RCConfiguration* c) :
314                 _rc_config (c),
315                 _limit_undo_button (_("Limit undo history to")),
316                 _save_undo_button (_("Save undo history of"))
317         {
318                 Table* t = new Table (2, 3);
319                 t->set_spacings (4);
320
321                 t->attach (_limit_undo_button, 0, 1, 0, 1, FILL);
322                 _limit_undo_spin.set_range (0, 512);
323                 _limit_undo_spin.set_increments (1, 10);
324                 t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND);
325                 Label* l = manage (new Label (_("commands")));
326                 l->set_alignment (0, 0.5);
327                 t->attach (*l, 2, 3, 0, 1);
328
329                 t->attach (_save_undo_button, 0, 1, 1, 2, FILL);
330                 _save_undo_spin.set_range (0, 512);
331                 _save_undo_spin.set_increments (1, 10);
332                 t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND);
333                 l = manage (new Label (_("commands")));
334                 l->set_alignment (0, 0.5);
335                 t->attach (*l, 2, 3, 1, 2);
336
337                 _box->pack_start (*t);
338
339                 _limit_undo_button.signal_toggled().connect (mem_fun (*this, &UndoOptions::limit_undo_toggled));
340                 _limit_undo_spin.signal_value_changed().connect (mem_fun (*this, &UndoOptions::limit_undo_changed));
341                 _save_undo_button.signal_toggled().connect (mem_fun (*this, &UndoOptions::save_undo_toggled));
342                 _save_undo_spin.signal_value_changed().connect (mem_fun (*this, &UndoOptions::save_undo_changed));
343         }
344
345         void parameter_changed (string const & p)
346         {
347                 if (p == "history-depth") {
348                         int32_t const d = _rc_config->get_history_depth();
349                         _limit_undo_button.set_active (d != 0);
350                         _limit_undo_spin.set_sensitive (d != 0);
351                         _limit_undo_spin.set_value (d);
352                 } else if (p == "save-history") {
353                         bool const x = _rc_config->get_save_history ();
354                         _save_undo_button.set_active (x);
355                         _save_undo_spin.set_sensitive (x);
356                 } else if (p == "save-history-depth") {
357                         _save_undo_spin.set_value (_rc_config->get_saved_history_depth());
358                 }
359         }
360
361         void set_state_from_config ()
362         {
363                 parameter_changed ("save-history");
364                 parameter_changed ("history-depth");
365                 parameter_changed ("save-history-depth");
366         }
367
368         void limit_undo_toggled ()
369         {
370                 bool const x = _limit_undo_button.get_active ();
371                 _limit_undo_spin.set_sensitive (x);
372                 int32_t const n = x ? 16 : 0;
373                 _limit_undo_spin.set_value (n);
374                 _rc_config->set_history_depth (n);
375         }
376
377         void limit_undo_changed ()
378         {
379                 _rc_config->set_history_depth (_limit_undo_spin.get_value_as_int ());
380         }
381
382         void save_undo_toggled ()
383         {
384                 bool const x = _save_undo_button.get_active ();
385                 _rc_config->set_save_history (x);
386         }
387
388         void save_undo_changed ()
389         {
390                 _rc_config->set_saved_history_depth (_save_undo_spin.get_value_as_int ());
391         }
392
393 private:
394         RCConfiguration* _rc_config;
395         CheckButton _limit_undo_button;
396         SpinButton _limit_undo_spin;
397         CheckButton _save_undo_button;
398         SpinButton _save_undo_spin;
399 };
400
401
402
403 static const struct {
404     const char *name;
405     guint modifier;
406 } modifiers[] = {
407
408         { "Unmodified", 0 },
409
410 #ifdef GTKOSX
411
412         /* Command = Meta
413            Option/Alt = Mod1
414         */
415         { "Shift", GDK_SHIFT_MASK },
416         { "Command", GDK_META_MASK },
417         { "Control", GDK_CONTROL_MASK },
418         { "Option", GDK_MOD1_MASK },
419         { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
420         { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
421         { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
422         { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
423
424 #else
425         { "Shift", GDK_SHIFT_MASK },
426         { "Control", GDK_CONTROL_MASK },
427         { "Alt (Mod1)", GDK_MOD1_MASK },
428         { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
429         { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
430         { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
431         { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
432         { "Mod2", GDK_MOD2_MASK },
433         { "Mod3", GDK_MOD3_MASK },
434         { "Mod4", GDK_MOD4_MASK },
435         { "Mod5", GDK_MOD5_MASK },
436 #endif
437         { 0, 0 }
438 };
439
440
441 class KeyboardOptions : public OptionEditorBox
442 {
443 public:
444         KeyboardOptions () :
445                   _delete_button_adjustment (3, 1, 12),
446                   _delete_button_spin (_delete_button_adjustment),
447                   _edit_button_adjustment (3, 1, 5),
448                   _edit_button_spin (_edit_button_adjustment)
449
450         {
451                 /* internationalize and prepare for use with combos */
452
453                 vector<string> dumb;
454                 for (int i = 0; modifiers[i].name; ++i) {
455                         dumb.push_back (_(modifiers[i].name));
456                 }
457
458                 set_popdown_strings (_edit_modifier_combo, dumb);
459                 _edit_modifier_combo.signal_changed().connect (mem_fun(*this, &KeyboardOptions::edit_modifier_chosen));
460
461                 for (int x = 0; modifiers[x].name; ++x) {
462                         if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
463                                 _edit_modifier_combo.set_active_text (_(modifiers[x].name));
464                                 break;
465                         }
466                 }
467
468                 Table* t = manage (new Table (4, 4));
469                 t->set_spacings (4);
470
471                 Label* l = manage (new Label (_("Edit using:")));
472                 l->set_name ("OptionsLabel");
473                 l->set_alignment (0, 0.5);
474
475                 t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL);
476                 t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL);
477
478                 l = manage (new Label (_("+ button")));
479                 l->set_name ("OptionsLabel");
480
481                 t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL);
482                 t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL);
483
484                 _edit_button_spin.set_name ("OptionsEntry");
485                 _edit_button_adjustment.set_value (Keyboard::edit_button());
486                 _edit_button_adjustment.signal_value_changed().connect (mem_fun(*this, &KeyboardOptions::edit_button_changed));
487
488                 set_popdown_strings (_delete_modifier_combo, dumb);
489                 _delete_modifier_combo.signal_changed().connect (mem_fun(*this, &KeyboardOptions::delete_modifier_chosen));
490
491                 for (int x = 0; modifiers[x].name; ++x) {
492                         if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
493                                 _delete_modifier_combo.set_active_text (_(modifiers[x].name));
494                                 break;
495                         }
496                 }
497
498                 l = manage (new Label (_("Delete using:")));
499                 l->set_name ("OptionsLabel");
500                 l->set_alignment (0, 0.5);
501
502                 t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL);
503                 t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL);
504
505                 l = manage (new Label (_("+ button")));
506                 l->set_name ("OptionsLabel");
507
508                 t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL);
509                 t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL);
510
511                 _delete_button_spin.set_name ("OptionsEntry");
512                 _delete_button_adjustment.set_value (Keyboard::delete_button());
513                 _delete_button_adjustment.signal_value_changed().connect (mem_fun(*this, &KeyboardOptions::delete_button_changed));
514
515                 set_popdown_strings (_snap_modifier_combo, dumb);
516                 _snap_modifier_combo.signal_changed().connect (mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
517
518                 for (int x = 0; modifiers[x].name; ++x) {
519                         if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
520                                 _snap_modifier_combo.set_active_text (_(modifiers[x].name));
521                                 break;
522                         }
523                 }
524
525                 l = manage (new Label (_("Toggle snap using:")));
526                 l->set_name ("OptionsLabel");
527                 l->set_alignment (0, 0.5);
528
529                 t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL);
530                 t->attach (_snap_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL);
531
532                 vector<string> strs;
533
534                 for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
535                         strs.push_back (bf->first);
536                 }
537
538                 set_popdown_strings (_keyboard_layout_selector, strs);
539                 _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
540                 _keyboard_layout_selector.signal_changed().connect (mem_fun (*this, &KeyboardOptions::bindings_changed));
541
542                 l = manage (new Label (_("Keyboard layout:")));
543                 l->set_name ("OptionsLabel");
544                 l->set_alignment (0, 0.5);
545
546                 t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
547                 t->attach (_keyboard_layout_selector, 1, 2, 3, 4, FILL | EXPAND, FILL);
548
549                 _box->pack_start (*t, false, false);
550         }
551
552         void parameter_changed (string const &)
553         {
554                 /* XXX: these aren't really config options... */
555         }
556
557         void set_state_from_config ()
558         {
559                 /* XXX: these aren't really config options... */
560         }
561
562 private:
563
564         void bindings_changed ()
565         {
566                 string const txt = _keyboard_layout_selector.get_active_text();
567
568                 /* XXX: config...?  for all this keyboard stuff */
569
570                 for (map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
571                         if (txt == i->first) {
572                                 if (Keyboard::load_keybindings (i->second)) {
573                                         Keyboard::save_keybindings ();
574                                 }
575                         }
576                 }
577         }
578
579         void edit_modifier_chosen ()
580         {
581                 string const txt = _edit_modifier_combo.get_active_text();
582
583                 for (int i = 0; modifiers[i].name; ++i) {
584                         if (txt == _(modifiers[i].name)) {
585                                 Keyboard::set_edit_modifier (modifiers[i].modifier);
586                                 break;
587                         }
588                 }
589         }
590
591         void delete_modifier_chosen ()
592         {
593                 string const txt = _delete_modifier_combo.get_active_text();
594
595                 for (int i = 0; modifiers[i].name; ++i) {
596                         if (txt == _(modifiers[i].name)) {
597                                 Keyboard::set_delete_modifier (modifiers[i].modifier);
598                                 break;
599                         }
600                 }
601         }
602
603         void snap_modifier_chosen ()
604         {
605                 string const txt = _snap_modifier_combo.get_active_text();
606
607                 for (int i = 0; modifiers[i].name; ++i) {
608                         if (txt == _(modifiers[i].name)) {
609                                 Keyboard::set_snap_modifier (modifiers[i].modifier);
610                                 break;
611                         }
612                 }
613         }
614
615         void delete_button_changed ()
616         {
617                 Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
618         }
619
620         void edit_button_changed ()
621         {
622                 Keyboard::set_edit_button (_edit_button_spin.get_value_as_int());
623         }
624
625         ComboBoxText _keyboard_layout_selector;
626         ComboBoxText _edit_modifier_combo;
627         ComboBoxText _delete_modifier_combo;
628         ComboBoxText _snap_modifier_combo;
629         Adjustment _delete_button_adjustment;
630         SpinButton _delete_button_spin;
631         Adjustment _edit_button_adjustment;
632         SpinButton _edit_button_spin;
633 };
634
635 class FontScalingOptions : public OptionEditorBox
636 {
637 public:
638         FontScalingOptions (RCConfiguration* c) :
639                 _rc_config (c),
640                 _dpi_adjustment (50, 50, 250, 1, 10),
641                 _dpi_slider (_dpi_adjustment)
642         {
643                 _dpi_adjustment.set_value (_rc_config->get_font_scale () / 1024);
644
645                 Label* l = manage (new Label (_("Font scaling:")));
646                 l->set_name ("OptionsLabel");
647
648                 _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);
649                 HBox* h = manage (new HBox);
650                 h->set_spacing (4);
651                 h->pack_start (*l, false, false);
652                 h->pack_start (_dpi_slider, true, true);
653
654                 _box->pack_start (*h, false, false);
655
656                 _dpi_adjustment.signal_value_changed().connect (mem_fun (*this, &FontScalingOptions::dpi_changed));
657         }
658
659         void parameter_changed (string const & p)
660         {
661                 if (p == "font-scale") {
662                         _dpi_adjustment.set_value (_rc_config->get_font_scale() / 1024);
663                 }
664         }
665
666         void set_state_from_config ()
667         {
668                 parameter_changed ("font-scale");
669         }
670
671 private:
672
673         void dpi_changed ()
674         {
675                 _rc_config->set_font_scale ((long) floor (_dpi_adjustment.get_value() * 1024));
676                 /* XXX: should be triggered from the parameter changed signal */
677                 reset_dpi ();
678         }
679
680         RCConfiguration* _rc_config;
681         Adjustment _dpi_adjustment;
682         HScale _dpi_slider;
683 };
684
685 class SoloMuteOptions : public OptionEditorBox
686 {
687 public:
688         SoloMuteOptions (RCConfiguration* c) :
689                 _rc_config (c),
690                 // 0.781787 is the value needed for gain to be set to 0.
691                 _db_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
692
693         {
694                 if ((pix = ::get_icon ("fader_belt_h")) == 0) {
695                         throw failed_constructor();
696                 }
697
698                 _db_slider = manage (new HSliderController (pix,
699                                                             &_db_adjustment,
700                                                             false));
701
702
703                 parameter_changed ("solo-mute-gain");
704
705                 Label* l = manage (new Label (_("Solo mute cut (dB):")));
706                 l->set_name ("OptionsLabel");
707
708                 HBox* h = manage (new HBox);
709                 h->set_spacing (4);
710                 h->pack_start (*l, false, false);
711                 h->pack_start (*_db_slider, false, false);
712                 h->pack_start (_db_display, false, false);
713
714                 set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12);
715
716                 _box->pack_start (*h, false, false);
717
718                 _db_adjustment.signal_value_changed().connect (mem_fun (*this, &SoloMuteOptions::db_changed));
719         }
720
721         void parameter_changed (string const & p)
722         {
723                 if (p == "solo-mute-gain") {
724                         gain_t val = _rc_config->get_solo_mute_gain();
725
726                         _db_adjustment.set_value (gain_to_slider_position (val));
727
728                         char buf[16];
729
730                         if (val == 0.0) {
731                                 snprintf (buf, sizeof (buf), "-inf");
732                         } else {
733                                 snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
734                         }
735
736                         _db_display.set_text (buf);
737                 }
738         }
739
740         void set_state_from_config ()
741         {
742                 parameter_changed ("solo-mute-gain");
743         }
744
745 private:
746
747         void db_changed ()
748         {
749                 _rc_config->set_solo_mute_gain (slider_position_to_gain (_db_adjustment.get_value()));
750         }
751
752         RCConfiguration* _rc_config;
753         Adjustment _db_adjustment;
754         Gtkmm2ext::HSliderController* _db_slider;
755         Glib::RefPtr<Gdk::Pixbuf> pix;
756         Entry _db_display;
757 };
758
759
760 class ControlSurfacesOptions : public OptionEditorBox
761 {
762 public:
763         ControlSurfacesOptions ()
764         {
765                 _store = ListStore::create (_model);
766                 _view.set_model (_store);
767                 _view.append_column (_("Name"), _model.name);
768                 _view.get_column(0)->set_resizable (true);
769                 _view.get_column(0)->set_expand (true);
770                 _view.append_column_editable (_("Enabled"), _model.enabled);
771                 _view.append_column_editable (_("Feedback"), _model.feedback);
772
773                 _box->pack_start (_view, false, false);
774
775                 _store->signal_row_changed().connect (mem_fun (*this, &ControlSurfacesOptions::model_changed));
776         }
777
778         void parameter_changed (std::string const &)
779         {
780
781         }
782
783         void set_state_from_config ()
784         {
785                 _store->clear ();
786
787                 ControlProtocolManager& m = ControlProtocolManager::instance ();
788                 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
789
790                         if (!(*i)->mandatory) {
791                                 TreeModel::Row r = *_store->append ();
792                                 r[_model.name] = (*i)->name;
793                                 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
794                                 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
795                                 r[_model.protocol_info] = *i;
796                         }
797                 }
798         }
799
800 private:
801
802         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
803         {
804                 TreeModel::Row r = *i;
805
806                 ControlProtocolInfo* cpi = r[_model.protocol_info];
807                 if (!cpi) {
808                         return;
809                 }
810
811                 bool const was_enabled = (cpi->protocol != 0);
812                 bool const is_enabled = r[_model.enabled];
813
814                 if (was_enabled != is_enabled) {
815                         if (!was_enabled) {
816                                 ControlProtocolManager::instance().instantiate (*cpi);
817                         } else {
818                                 ControlProtocolManager::instance().teardown (*cpi);
819                         }
820                 }
821
822                 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
823                 bool const is_feedback = r[_model.feedback];
824
825                 if (was_feedback != is_feedback && cpi->protocol) {
826                         cpi->protocol->set_feedback (is_feedback);
827                 }
828         }
829
830         class ControlSurfacesModelColumns : public TreeModelColumnRecord
831         {
832         public:
833
834                 ControlSurfacesModelColumns ()
835                 {
836                         add (name);
837                         add (enabled);
838                         add (feedback);
839                         add (protocol_info);
840                 }
841
842                 TreeModelColumn<string> name;
843                 TreeModelColumn<bool> enabled;
844                 TreeModelColumn<bool> feedback;
845                 TreeModelColumn<ControlProtocolInfo*> protocol_info;
846         };
847
848         Glib::RefPtr<ListStore> _store;
849         ControlSurfacesModelColumns _model;
850         TreeView _view;
851 };
852
853
854 RCOptionEditor::RCOptionEditor ()
855         : OptionEditor (Config, _("Ardour Preferences")),
856           _rc_config (Config)
857 {
858         /* MISC */
859
860         add_option (_("Misc"), new OptionEditorHeading (_("Metering")));
861
862         ComboOption<float>* mht = new ComboOption<float> (
863                 "meter-hold",
864                 _("Meter hold time"),
865                 mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
866                 mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
867                 );
868
869         mht->add (MeterHoldOff, _("off"));
870         mht->add (MeterHoldShort, _("short"));
871         mht->add (MeterHoldMedium, _("medium"));
872         mht->add (MeterHoldLong, _("long"));
873
874         add_option (_("Misc"), mht);
875
876         ComboOption<float>* mfo = new ComboOption<float> (
877                 "meter-falloff",
878                 _("Meter fall-off"),
879                 mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
880                 mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
881                 );
882
883         mfo->add (METER_FALLOFF_OFF, _("off"));
884         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
885         mfo->add (METER_FALLOFF_SLOW, _("slow"));
886         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
887         mfo->add (METER_FALLOFF_FAST, _("fast"));
888         mfo->add (METER_FALLOFF_FASTER, _("faster"));
889         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
890
891         add_option (_("Misc"), mfo);
892
893         add_option (_("Misc"), new OptionEditorHeading (_("Undo")));
894
895         add_option (_("Misc"), new UndoOptions (_rc_config));
896
897         add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
898
899 #ifndef GTKOSX
900         /* font scaling does nothing with GDK/Quartz */
901         add_option (_("Misc"), new FontScalingOptions (_rc_config));
902 #endif
903
904         add_option (_("Misc"),
905              new BoolOption (
906                      "verify-remove-last-capture",
907                      _("Verify removal of last capture"),
908                      mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
909                      mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
910                      ));
911
912         add_option (_("Misc"),
913              new BoolOption (
914                      "periodic-safety-backups",
915                      _("Make periodic backups of the session file"),
916                      mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
917                      mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
918                      ));
919
920         add_option (_("Misc"),
921              new BoolOption (
922                      "sync-all-route-ordering",
923                      _("Syncronise editor and mixer track order"),
924                      mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
925                      mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
926                      ));
927
928         add_option (_("Misc"),
929              new BoolOption (
930                      "only-copy-imported-files",
931                      _("Always copy imported files"),
932                      mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
933                      mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
934                      ));
935
936         add_option (_("Misc"),
937              new BoolOption (
938                      "default-narrow_ms",
939                      _("Use narrow mixer strips"),
940                      mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
941                      mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
942                      ));
943
944         add_option (_("Misc"),
945              new BoolOption (
946                      "name-new-markers",
947                      _("Name new markers"),
948                      mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
949                      mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
950                      ));
951
952         /* TRANSPORT */
953
954         add_option (_("Transport"),
955              new BoolOption (
956                      "latched-record-enable",
957                      _("Keep record-enable engaged on stop"),
958                      mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
959                      mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
960                      ));
961
962         add_option (_("Transport"),
963              new BoolOption (
964                      "stop-recording-on-xrun",
965                      _("Stop recording when an xrun occurs"),
966                      mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
967                      mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
968                      ));
969
970         add_option (_("Transport"),
971              new BoolOption (
972                      "create-xrun-marker",
973                      _("Create markers where xruns occur"),
974                      mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
975                      mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
976                      ));
977
978         add_option (_("Transport"),
979              new BoolOption (
980                      "stop-at-session-end",
981                      _("Stop at the end of the session"),
982                      mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
983                      mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
984                      ));
985
986         add_option (_("Transport"),
987              new BoolOption (
988                      "primary-clock-delta-edit-cursor",
989                      _("Primary clock delta to edit cursor"),
990                      mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
991                      mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
992                      ));
993
994         add_option (_("Transport"),
995              new BoolOption (
996                      "secondary-clock-delta-edit-cursor",
997                      _("Secondary clock delta to edit cursor"),
998                      mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
999                      mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
1000                      ));
1001
1002         add_option (_("Transport"),
1003              new BoolOption (
1004                      "disable-disarm-during-roll",
1005                      _("Disable record disarm when transport is rolling"),
1006                      mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1007                      mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1008                      ));
1009
1010         /* EDITOR */
1011
1012         add_option (_("Editor"),
1013              new BoolOption (
1014                      "link-region-and-track-selection",
1015                      _("Link selection of regions and tracks"),
1016                      mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1017                      mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1018                      ));
1019
1020         add_option (_("Editor"),
1021              new BoolOption (
1022                      "automation-follows-regions",
1023                      _("Move relevant automation when regions are moved"),
1024                      mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1025                      mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1026                      ));
1027
1028         add_option (_("Editor"),
1029              new BoolOption (
1030                      "show-track-meters",
1031                      _("Show meters on tracks in the editor"),
1032                      mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1033                      mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1034                      ));
1035
1036         add_option (_("Editor"),
1037              new BoolOption (
1038                      "use-overlap-equivalency",
1039                      _("Use overlap equivalency for regions"),
1040                      mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1041                      mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1042                      ));
1043
1044         add_option (_("Editor"),
1045              new BoolOption (
1046                      "rubberbanding-snaps-to-grid",
1047                      _("Make rubberband selection rectangle snap to the grid"),
1048                      mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1049                      mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1050                      ));
1051
1052         add_option (_("Editor"),
1053              new BoolOption (
1054                      "show-waveforms",
1055                      _("Show waveforms in regions"),
1056                      mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1057                      mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1058                      ));
1059
1060         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1061                 "waveform-scale",
1062                 _("Waveform scale"),
1063                 mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1064                 mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1065                 );
1066
1067         wfs->add (Linear, _("linear"));
1068         wfs->add (Logarithmic, _("logarithmic"));
1069
1070         add_option (_("Editor"), wfs);
1071
1072         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1073                 "waveform-shape",
1074                 _("Waveform shape"),
1075                 mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1076                 mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1077                 );
1078
1079         wfsh->add (Traditional, _("traditional"));
1080         wfsh->add (Rectified, _("rectified"));
1081
1082         add_option (_("Editor"), wfsh);
1083
1084         /* AUDIO */
1085
1086         add_option (_("Audio"), new OptionEditorHeading (_("Solo")));
1087
1088
1089         add_option (_("Audio"),
1090              new BoolOption (
1091                      "solo-control-is-listen-control",
1092                      _("Solo controls are Listen controls"),
1093                      mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1094                      mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1095                      ));
1096
1097         ComboOption<ListenPosition>* lp = new ComboOption<ListenPosition> (
1098                 "listen-position",
1099                 _("Listen Position"),
1100                 mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1101                 mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1102                 );
1103
1104         lp->add (AfterFaderListen, _("after-fader listen"));
1105         lp->add (PreFaderListen, _("pre-fader listen"));
1106
1107         add_option (_("Audio"), lp);
1108         add_option (_("Audio"), new SoloMuteOptions (_rc_config));
1109
1110         add_option (_("Audio"),
1111              new BoolOption (
1112                      "solo-latched",
1113                      _("Latched solo"),
1114                      mem_fun (*_rc_config, &RCConfiguration::get_solo_latched),
1115                      mem_fun (*_rc_config, &RCConfiguration::set_solo_latched)
1116                      ));
1117
1118         add_option (_("Audio"),
1119              new BoolOption (
1120                      "show-solo-mutes",
1121                      _("Show solo muting"),
1122                      mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1123                      mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1124                      ));
1125
1126         add_option (_("Audio"),
1127              new BoolOption (
1128                      "solo-mute-override",
1129                      _("Override muting"),
1130                      mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1131                      mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1132                      ));
1133
1134         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1135
1136         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1137                 "monitoring-model",
1138                 _("Monitoring handled by"),
1139                 mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1140                 mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1141                 );
1142
1143         mm->add (HardwareMonitoring, _("JACK"));
1144         mm->add (SoftwareMonitoring, _("ardour"));
1145         mm->add (ExternalMonitoring, _("audio hardware"));
1146
1147         add_option (_("Audio"), mm);
1148
1149         add_option (_("Audio"),
1150              new BoolOption (
1151                      "tape-machine-mode",
1152                      _("Tape machine mode"),
1153                      mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1154                      mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1155                      ));
1156
1157         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1158
1159         add_option (_("Audio"),
1160                     new BoolOption (
1161                             "auto-connect-standard-busses",
1162                             _("Auto-connect master/monitor busses"),
1163                             mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1164                             mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1165                             ));
1166
1167         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1168                 "input-auto-connect",
1169                 _("Connect track and bus inputs"),
1170                 mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1171                 mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1172                 );
1173
1174         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1175         iac->add (ManualConnect, _("manually"));
1176
1177         add_option (_("Audio"), iac);
1178
1179         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1180                 "output-auto-connect",
1181                 _("Connect track and bus outputs"),
1182                 mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1183                 mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1184                 );
1185
1186         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1187         oac->add (AutoConnectMaster, _("automatically to master outputs"));
1188         oac->add (ManualConnect, _("manually"));
1189
1190         add_option (_("Audio"), oac);
1191
1192         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1193
1194         add_option (_("Audio"),
1195              new BoolOption (
1196                      "denormal-protection",
1197                      _("Use DC bias to protect against denormals"),
1198                      mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1199                      mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1200                      ));
1201
1202         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1203                 "denormal-model",
1204                 _("Processor handling"),
1205                 mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1206                 mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1207                 );
1208
1209         dm->add (DenormalNone, _("no processor handling"));
1210
1211         FPU fpu;
1212
1213         if (fpu.has_flush_to_zero()) {
1214                 dm->add (DenormalFTZ, _("use FlushToZero"));
1215         }
1216
1217         if (fpu.has_denormals_are_zero()) {
1218                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1219         }
1220
1221         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1222                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1223         }
1224
1225         add_option (_("Audio"), dm);
1226
1227         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1228
1229         add_option (_("Audio"),
1230              new BoolOption (
1231                      "plugins-stop-with-transport",
1232                      _("Stop plugins when the transport is stopped"),
1233                      mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1234                      mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1235                      ));
1236
1237         add_option (_("Audio"),
1238              new BoolOption (
1239                      "do-not-record-plugins",
1240                      _("Disable plugins during recording"),
1241                      mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1242                      mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1243                      ));
1244
1245         add_option (_("Audio"),
1246              new BoolOption (
1247                      "new-plugins-active",
1248                      _("Make new plugins active"),
1249                      mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1250                      mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1251                      ));
1252
1253         add_option (_("Audio"),
1254              new BoolOption (
1255                      "auto-analyse-audio",
1256                      _("Enable automatic analysis of audio"),
1257                      mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1258                      mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1259                      ));
1260
1261         /* MIDI CONTROL */
1262
1263         list<ComboOption<string>* > midi_combos;
1264
1265         midi_combos.push_back (new ComboOption<string> (
1266                                        "mtc-port-name",
1267                                        _("Send/Receive MTC via"),
1268                                        mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name),
1269                                        mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name)
1270                                        ));
1271
1272         midi_combos.push_back (new ComboOption<string> (
1273                                        "midi-clock-port-name",
1274                                        _("Send/Receive MIDI clock via"),
1275                                        mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name),
1276                                        mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name)
1277                                        ));
1278
1279         midi_combos.push_back (new ComboOption<string> (
1280                                        "mmc-port-name",
1281                                        _("Send/Receive MMC via"),
1282                                        mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name),
1283                                        mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name)
1284                                        ));
1285
1286         midi_combos.push_back (new ComboOption<string> (
1287                                        "midi-port-name",
1288                                        _("Send/Receive MIDI parameter control via"),
1289                                        mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name),
1290                                        mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name)
1291                                        ));
1292         
1293         add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos));
1294
1295         for (list<ComboOption<string>* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) {
1296                 add_option (_("MIDI control"), *i);
1297         }
1298
1299         add_option (_("MIDI control"),
1300                     new BoolOption (
1301                             "mmc-control",
1302                             _("Obey MIDI Machine Control commands"),
1303                             mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1304                             mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1305                             ));
1306
1307
1308         add_option (_("MIDI control"),
1309                     new BoolOption (
1310                             "send-mmc",
1311                             _("Send MIDI Machine Control commands"),
1312                             mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1313                             mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1314                             ));
1315
1316         add_option (_("MIDI control"),
1317                     new BoolOption (
1318                             "midi-feedback",
1319                             _("Send MIDI control feedback"),
1320                             mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1321                             mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1322                             ));
1323
1324         add_option (_("MIDI control"),
1325              new SpinOption<uint8_t> (
1326                      "mmc-receive-device-id",
1327                      _("Inbound MMC device ID"),
1328                      mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1329                      mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1330                      0, 128, 1, 10
1331                      ));
1332
1333         add_option (_("MIDI control"),
1334              new SpinOption<uint8_t> (
1335                      "mmc-send-device-id",
1336                      _("Outbound MMC device ID"),
1337                      mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1338                      mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1339                      0, 128, 1, 10
1340                      ));
1341
1342         add_option (_("MIDI control"),
1343              new SpinOption<int32_t> (
1344                      "initial-program-change",
1345                      _("Initial program change"),
1346                      mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1347                      mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1348                      -1, 65536, 1, 10
1349                      ));
1350
1351         /* CONTROL SURFACES */
1352
1353         add_option (_("Control surfaces"), new ControlSurfacesOptions);
1354
1355         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1356                 "remote-model",
1357                 _("Control surface remote ID"),
1358                 mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1359                 mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1360                 );
1361
1362         rm->add (UserOrdered, _("assigned by user"));
1363         rm->add (MixerOrdered, _("follows order of mixer"));
1364         rm->add (EditorOrdered, _("follows order of editor"));
1365
1366         add_option (_("Control surfaces"), rm);
1367
1368         /* CLICK */
1369
1370         add_option (_("Click"), new ClickOptions (_rc_config, this));
1371
1372         /* KEYBOARD */
1373
1374         add_option (_("Keyboard"), new KeyboardOptions);
1375 }
1376
1377