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