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