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