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