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