* first working version of editing MIDI channels of individual notes, see: http:...
[ardour.git] / gtk2_ardour / ardour_ui_options.cc
1 /*
2     Copyright (C) 2005 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 #include <pbd/convert.h>
21 #include <pbd/stacktrace.h>
22
23 #include <gtkmm2ext/utils.h>
24
25 #include <ardour/configuration.h>
26 #include <ardour/session.h>
27 #include <ardour/audioengine.h>
28
29 #ifdef HAVE_LIBLO
30 #include <ardour/osc.h>
31 #endif
32
33 #include "ardour_ui.h"
34 #include "actions.h"
35 #include "gui_thread.h"
36 #include "public_editor.h"
37
38 #include "i18n.h"
39
40 using namespace Gtk;
41 using namespace Gtkmm2ext;
42 using namespace ARDOUR;
43 using namespace PBD;
44 using namespace sigc;
45
46 void
47 ARDOUR_UI::toggle_time_master ()
48 {
49         ActionManager::toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
50 }
51
52 void
53 ARDOUR_UI::toggle_send_mtc ()
54 {
55         ActionManager::toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
56 }
57
58 void
59 ARDOUR_UI::toggle_send_mmc ()
60 {
61         ActionManager::toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
62 }
63
64 void
65 ARDOUR_UI::toggle_use_mmc ()
66 {
67         ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
68 }
69
70 void
71 ARDOUR_UI::toggle_use_osc ()
72 {
73         ActionManager::toggle_config_state ("options", "UseOSC", &Configuration::set_use_osc, &Configuration::get_use_osc);
74 }
75
76 void
77 ARDOUR_UI::toggle_send_midi_feedback ()
78 {
79         ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
80 }
81
82 void
83 ARDOUR_UI::toggle_denormal_protection ()
84 {
85         ActionManager::toggle_config_state ("options", "DenormalProtection", &Configuration::set_denormal_protection, &Configuration::get_denormal_protection);
86 }
87
88 void
89 ARDOUR_UI::toggle_only_copy_imported_files ()
90 {
91         ActionManager::toggle_config_state ("options", "OnlyCopyImportedFiles", &Configuration::set_only_copy_imported_files, &Configuration::get_only_copy_imported_files);
92 }
93
94
95 void
96 ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
97 {
98         const char *action = 0;
99
100         switch (hf) {
101         case BWF:
102                 action = X_("FileHeaderFormatBWF");
103                 break;
104         case WAVE:
105                 action = X_("FileHeaderFormatWAVE");
106                 break;
107         case WAVE64:
108                 action = X_("FileHeaderFormatWAVE64");
109                 break;
110         case iXML:
111                 action = X_("FileHeaderFormatiXML");
112                 break;
113         case RF64:
114                 action = X_("FileHeaderFormatRF64");
115                 break;
116         case CAF:
117                 action = X_("FileHeaderFormatCAF");
118                 break;
119         case AIFF:
120                 action = X_("FileHeaderFormatAIFF");
121                 break;
122         default:
123                 fatal << string_compose (_("programming error: %1"), "illegal file header format in ::set_native_file_header_format") << endmsg;
124                 /*NOTREACHED*/  
125         }
126
127         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
128
129         if (act) {
130                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
131                 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
132                         Config->set_native_file_header_format (hf);
133                 }
134         }
135 }
136
137 void
138 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
139 {
140         const char* action = 0;
141
142         switch (sf) {
143         case FormatFloat:
144                 action = X_("FileDataFormatFloat");
145                 break;
146         case FormatInt24:
147                 action = X_("FileDataFormat24bit");
148                 break;
149         case FormatInt16:
150                 action = X_("FileDataFormat16bit");
151                 break;
152         default:
153                 fatal << string_compose (_("programming error: %1"), "illegal file data format in ::set_native_file_data_format") << endmsg;
154                 /*NOTREACHED*/
155         }
156
157         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
158
159         if (act) {
160                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
161                 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
162                         Config->set_native_file_data_format (sf);
163                 }
164         }
165 }
166
167 void
168 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
169 {
170         const char* action;
171         
172         switch (option) {
173         case AutoConnectPhysical:
174                 action = X_("InputAutoConnectPhysical");
175                 break;
176         default:
177                 action = X_("InputAutoConnectManual");
178         }
179
180         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
181
182         if (act) {
183                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
184
185                 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
186                         Config->set_input_auto_connect (option);
187                 }
188         }
189 }
190
191 void
192 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
193 {
194         const char* action;
195         
196         switch (option) {
197         case AutoConnectPhysical:
198                 action = X_("OutputAutoConnectPhysical");
199                 break;
200         case AutoConnectMaster:
201                 action = X_("OutputAutoConnectMaster");
202                 break;
203         default:
204                 action = X_("OutputAutoConnectManual");
205         }
206
207         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
208
209         if (act) {
210                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
211
212                 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
213                         Config->set_output_auto_connect (option);
214                 }
215         }
216 }
217
218 void
219 ARDOUR_UI::set_solo_model (SoloModel model)
220 {
221         const char* action = 0;
222
223         switch (model) {
224         case SoloBus:
225                 action = X_("SoloViaBus");
226                 break;
227                 
228         case InverseMute:
229                 action = X_("SoloInPlace");
230                 break;
231         default:
232                 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
233                 /*NOTREACHED*/
234         }
235
236         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
237
238         if (act) {
239                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
240
241                 if (ract && ract->get_active() && Config->get_solo_model() != model) {
242                         Config->set_solo_model (model);
243                 }
244         }
245
246 }
247
248 void
249 ARDOUR_UI::set_remote_model (RemoteModel model)
250 {
251         const char* action = 0;
252
253         switch (model) {
254         case UserOrdered:
255                 action = X_("RemoteUserDefined");
256                 break;
257         case MixerOrdered:
258                 action = X_("RemoteMixerDefined");
259                 break;
260         case EditorOrdered:
261                 action = X_("RemoteEditorDefined");
262                 break;
263
264         default:
265                 fatal << string_compose (_("programming error: unknown remote model in ARDOUR_UI::set_remote_model: %1"), model) << endmsg;
266                 /*NOTREACHED*/
267         }
268
269         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
270
271         if (act) {
272                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
273
274                 if (ract && ract->get_active() && Config->get_remote_model() != model) {
275                         Config->set_remote_model (model);
276                 }
277         }
278
279 }
280
281 void
282 ARDOUR_UI::set_monitor_model (MonitorModel model)
283 {
284         const char* action = 0;
285
286         switch (model) {
287         case HardwareMonitoring:
288                 action = X_("UseHardwareMonitoring");
289                 break;
290                 
291         case SoftwareMonitoring:
292                 action = X_("UseSoftwareMonitoring");
293                 break;
294         case ExternalMonitoring:
295                 action = X_("UseExternalMonitoring");
296                 break;
297
298         default:
299                 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
300                 /*NOTREACHED*/
301         }
302
303         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
304
305         if (act) {
306                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
307
308                 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
309                         Config->set_monitoring_model (model);
310                 }
311         }
312
313 }
314
315 void
316 ARDOUR_UI::set_denormal_model (DenormalModel model)
317 {
318         const char* action = 0;
319
320         switch (model) {
321         case DenormalNone:
322                 action = X_("DenormalNone");
323                 break;
324
325         case DenormalFTZ:
326                 action = X_("DenormalFTZ");
327                 break;
328                 
329         case DenormalDAZ:
330                 action = X_("DenormalDAZ");
331                 break;
332
333         case DenormalFTZDAZ:
334                 action = X_("DenormalFTZDAZ");
335                 break;
336
337         default:
338                 fatal << string_compose (_("programming error: unknown denormal model in ARDOUR_UI::set_denormal_model: %1"), model) << endmsg;
339                 /*NOTREACHED*/
340         }
341
342         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
343
344         if (act) {
345                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
346
347                 if (ract && ract->get_active() && Config->get_denormal_model() != model) {
348                         Config->set_denormal_model (model);
349                 }
350         }
351
352 }
353
354 void
355 ARDOUR_UI::toggle_auto_input ()
356 {
357         ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
358 }
359
360 void
361 ARDOUR_UI::toggle_auto_play ()
362 {
363         ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
364 }
365
366 void
367 ARDOUR_UI::toggle_auto_return ()
368 {
369         ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
370 }
371
372 void
373 ARDOUR_UI::toggle_click ()
374 {
375         ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
376 }
377
378 void
379 ARDOUR_UI::toggle_session_auto_loop ()
380 {
381         if (session) {
382                 if (session->get_play_loop()) {
383                         if (session->transport_rolling()) {
384                                 transport_roll();
385                         } else {
386                                 session->request_play_loop (false);
387                         }
388                 } else {
389                         session->request_play_loop (true);
390                 }
391         }
392 }
393
394 void
395 ARDOUR_UI::unset_dual_punch ()
396 {
397         Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
398         
399         if (action) {
400                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
401                 if (tact) {
402                         ignore_dual_punch = true;
403                         tact->set_active (false);
404                         ignore_dual_punch = false;
405                 }
406         }
407 }
408
409 void
410 ARDOUR_UI::toggle_punch ()
411 {
412         if (ignore_dual_punch) {
413                 return;
414         }
415
416         Glib::RefPtr<Action> action = ActionManager::get_action ("Transport", "TogglePunch");
417
418         if (action) {
419
420                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action);
421
422                 if (!tact) {
423                         return;
424                 }
425
426                 /* drive the other two actions from this one */
427
428                 Glib::RefPtr<Action> in_action = ActionManager::get_action ("Transport", "TogglePunchIn");
429                 Glib::RefPtr<Action> out_action = ActionManager::get_action ("Transport", "TogglePunchOut");
430
431                 if (in_action && out_action) {
432                         Glib::RefPtr<ToggleAction> tiact = Glib::RefPtr<ToggleAction>::cast_dynamic(in_action);
433                         Glib::RefPtr<ToggleAction> toact = Glib::RefPtr<ToggleAction>::cast_dynamic(out_action);
434                         tiact->set_active (tact->get_active());
435                         toact->set_active (tact->get_active());
436                 }
437         }
438 }
439
440 void
441 ARDOUR_UI::toggle_punch_in ()
442 {
443         ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
444 }
445
446 void
447 ARDOUR_UI::toggle_punch_out ()
448 {
449         ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
450 }
451
452 void
453 ARDOUR_UI::toggle_video_sync()
454 {
455         Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
456         if (act) {
457                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
458                 Config->set_use_video_sync (tact->get_active());
459         }
460 }
461
462 void
463 ARDOUR_UI::toggle_editing_space()
464 {
465         Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
466         if (act) {
467                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
468                 if (tact->get_active()) {
469                         maximise_editing_space ();
470                 } else {
471                         restore_editing_space ();
472                 }
473         }
474 }
475
476 void
477 ARDOUR_UI::toggle_StopPluginsWithTransport()
478 {
479         ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
480 }
481
482 void
483 ARDOUR_UI::toggle_LatchedRecordEnable()
484 {
485         ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
486 }
487
488 void
489 ARDOUR_UI::toggle_RegionEquivalentsOverlap()
490 {
491         ActionManager::toggle_config_state ("options", "RegionEquivalentsOverlap", &Configuration::set_use_overlap_equivalency, &Configuration::get_use_overlap_equivalency);
492 }
493
494 void
495 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
496 {
497         ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
498 }
499
500 void
501 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
502 {
503         ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
504 }
505
506 void
507 ARDOUR_UI::toggle_PeriodicSafetyBackups()
508 {
509         ActionManager::toggle_config_state ("options", "PeriodicSafetyBackups", &Configuration::set_periodic_safety_backups, &Configuration::get_periodic_safety_backups);
510 }
511
512 void
513 ARDOUR_UI::toggle_StopRecordingOnXrun()
514 {
515         ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
516 }
517
518 void
519 ARDOUR_UI::toggle_CreateXrunMarker()
520 {
521         ActionManager::toggle_config_state ("options", "CreateXrunMarker", &Configuration::set_create_xrun_marker, &Configuration::get_create_xrun_marker);
522 }
523
524 void
525 ARDOUR_UI::toggle_sync_order_keys ()
526 {
527         ActionManager::toggle_config_state ("options", "SyncEditorAndMixerTrackOrder", &Configuration::set_sync_all_route_ordering, &Configuration::get_sync_all_route_ordering);
528 }
529
530 void
531 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
532 {
533         ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
534 }
535
536 void
537 ARDOUR_UI::toggle_GainReduceFastTransport()
538 {
539         ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
540 }
541
542 void
543 ARDOUR_UI::toggle_LatchedSolo()
544 {
545         ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
546 }
547
548 void
549 ARDOUR_UI::toggle_ShowSoloMutes()
550 {
551         ActionManager::toggle_config_state ("options", "ShowSoloMutes", &Configuration::set_show_solo_mutes, &Configuration::get_show_solo_mutes);
552 }
553
554 void
555 ARDOUR_UI::toggle_PrimaryClockDeltaEditCursor()
556 {
557         ActionManager::toggle_config_state ("options", "PrimaryClockDeltaEditCursor", &Configuration::set_primary_clock_delta_edit_cursor, &Configuration::get_primary_clock_delta_edit_cursor);
558 }
559
560 void
561 ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor()
562 {
563         ActionManager::toggle_config_state ("options", "SecondaryClockDeltaEditCursor", &Configuration::set_secondary_clock_delta_edit_cursor, &Configuration::get_secondary_clock_delta_edit_cursor);
564 }
565
566 void
567 ARDOUR_UI::toggle_ShowTrackMeters()
568 {
569         ActionManager::toggle_config_state ("options", "ShowTrackMeters", &Configuration::set_show_track_meters, &Configuration::get_show_track_meters);
570 }
571
572 void
573 ARDOUR_UI::toggle_TapeMachineMode ()
574 {
575         ActionManager::toggle_config_state ("options", "ToggleTapeMachineMode", &Configuration::set_tape_machine_mode, &Configuration::get_tape_machine_mode);
576 }
577
578 void
579 ARDOUR_UI::toggle_use_narrow_ms()
580 {
581         ActionManager::toggle_config_state ("options", "DefaultNarrowMS", &Configuration::set_default_narrow_ms, &Configuration::get_default_narrow_ms);
582 }
583
584 void
585 ARDOUR_UI::toggle_rubberbanding_snaps_to_grid ()
586 {
587         ActionManager::toggle_config_state ("options", "RubberbandingSnapsToGrid", &Configuration::set_rubberbanding_snaps_to_grid, &Configuration::get_rubberbanding_snaps_to_grid);
588 }
589
590 void
591 ARDOUR_UI::toggle_auto_analyse_audio ()
592 {
593         ActionManager::toggle_config_state ("options", "AutoAnalyseAudio", &Configuration::set_auto_analyse_audio, &Configuration::get_auto_analyse_audio);
594 }
595
596 void
597 ARDOUR_UI::mtc_port_changed ()
598 {
599         bool have_mtc;
600
601         if (session) {
602                 if (session->mtc_port()) {
603                         have_mtc = true;
604                 } else {
605                         have_mtc = false;
606                 }
607         } else {
608                 have_mtc = false;
609         }
610
611         positional_sync_strings.clear ();
612         positional_sync_strings.push_back (slave_source_to_string (None));
613         if (have_mtc) {
614                 positional_sync_strings.push_back (slave_source_to_string (MTC));
615         }
616         positional_sync_strings.push_back (slave_source_to_string (JACK));
617         
618         set_popdown_strings (sync_option_combo, positional_sync_strings);
619 }
620
621 void
622 ARDOUR_UI::setup_session_options ()
623 {
624         mtc_port_changed ();
625
626         Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
627 }
628
629
630 void
631 ARDOUR_UI::map_solo_model ()
632 {
633         const char* on;
634
635         if (Config->get_solo_model() == InverseMute) {
636                 on = X_("SoloInPlace");
637         } else {
638                 on = X_("SoloViaBus");
639         }
640
641         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
642         if (act) {
643                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
644
645                 if (tact && !tact->get_active()) {
646                         tact->set_active (true);
647                 }
648         }
649 }
650
651 void
652 ARDOUR_UI::map_monitor_model ()
653 {
654         const char* on = 0;
655
656         switch (Config->get_monitoring_model()) {
657         case HardwareMonitoring:
658                 on = X_("UseHardwareMonitoring");
659                 break;
660         case SoftwareMonitoring:
661                 on = X_("UseSoftwareMonitoring");
662                 break;
663         case ExternalMonitoring:
664                 on = X_("UseExternalMonitoring");
665                 break;
666         }
667
668         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
669         if (act) {
670                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
671
672                 if (tact && !tact->get_active()) {
673                         tact->set_active (true);
674                 }
675         }
676 }
677
678 void
679 ARDOUR_UI::map_denormal_protection ()
680 {
681         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("DenormalProtection"));
682         if (act) {
683                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
684
685                 if (tact && !tact->get_active()) {
686                         tact->set_active (Config->get_denormal_protection());
687                 }
688         }
689 }
690
691 void
692 ARDOUR_UI::map_denormal_model ()
693 {
694         const char* on = 0;
695
696         switch (Config->get_denormal_model()) {
697         case DenormalNone:
698                 on = X_("DenormalNone");
699                 break;
700         case DenormalFTZ:
701                 on = X_("DenormalFTZ");
702                 break;
703         case DenormalDAZ:
704                 on = X_("DenormalDAZ");
705                 break;
706         case DenormalFTZDAZ:
707                 on = X_("DenormalFTZDAZ");
708                 break;
709         }
710
711         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
712         if (act) {
713                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
714
715                 if (tact && !tact->get_active()) {
716                         tact->set_active (true);
717                 }
718         }
719 }
720
721 void
722 ARDOUR_UI::map_remote_model ()
723 {
724         const char* on = 0;
725
726         switch (Config->get_remote_model()) {
727         case UserOrdered:
728                 on = X_("RemoteUserDefined");
729                 break;
730         case MixerOrdered:
731                 on = X_("RemoteMixerDefined");
732                 break;
733         case EditorOrdered:
734                 on = X_("RemoteEditorDefined");
735                 break;
736         }
737
738         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
739         if (act) {
740                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
741
742                 if (tact && !tact->get_active()) {
743                         tact->set_active (true);
744                 }
745         }
746 }
747
748 void
749 ARDOUR_UI::map_file_header_format ()
750 {
751         const char* action = 0;
752
753         switch (Config->get_native_file_header_format()) {
754         case BWF:
755                 action = X_("FileHeaderFormatBWF");
756                 break;
757
758         case WAVE:
759                 action = X_("FileHeaderFormatWAVE");
760                 break;
761
762         case WAVE64:
763                 action = X_("FileHeaderFormatWAVE64");
764                 break;
765
766         case iXML:
767                 action = X_("FileHeaderFormatiXML");
768                 break;
769
770         case RF64:
771                 action = X_("FileHeaderFormatRF64");
772                 break;
773
774         case CAF:
775                 action = X_("FileHeaderFormatCAF");
776                 break;
777
778         default:
779                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
780                                          Config->get_native_file_header_format()) << endmsg;
781                 /*NOTREACHED*/
782         }
783
784
785         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
786
787         if (act) {
788                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
789
790                 if (tact && !tact->get_active()) {
791                         tact->set_active (true);
792                 }
793         }
794 }
795
796 void
797 ARDOUR_UI::map_file_data_format ()
798 {
799         const char* action = 0;
800
801         switch (Config->get_native_file_data_format()) {
802         case FormatFloat:
803                 action = X_("FileDataFormatFloat");
804                 break;
805
806         case FormatInt24:
807                 action = X_("FileDataFormat24bit");
808                 break;
809
810         case FormatInt16:
811                 action = X_("FileDataFormat16bit");
812                 break;
813
814         default:
815                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
816                                          Config->get_native_file_data_format()) << endmsg;
817                 /*NOTREACHED*/
818         }
819
820
821         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
822
823         if (act) {
824                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
825
826                 if (tact && !tact->get_active()) {
827                         tact->set_active (true);
828                 }
829         }
830 }
831
832 void
833 ARDOUR_UI::map_input_auto_connect ()
834 {
835         const char* on;
836
837         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
838                 on = "InputAutoConnectManual";
839         } else {
840                 on = "InputAutoConnectPhysical";
841         }
842
843         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
844         if (act) {
845                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
846
847                 if (tact && !tact->get_active()) {
848                         tact->set_active (true);
849                 }
850         }
851 }
852
853 void
854 ARDOUR_UI::map_output_auto_connect ()
855 {
856         const char* on;
857
858         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
859                 on = "OutputAutoConnectManual";
860         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
861                 on = "OutputAutoConnectPhysical";
862         } else {
863                 on = "OutputAutoConnectMaster";
864         }
865
866         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
867         if (act) {
868                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
869                 
870                 if (tact && !tact->get_active()) {
871                         tact->set_active (true);
872                 }
873         }
874 }
875
876 void
877 ARDOUR_UI::map_only_copy_imported_files ()
878 {
879         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("OnlyCopyImportedFiles"));
880         if (act) {
881                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
882
883                 if (tact && !tact->get_active()) {
884                         tact->set_active (Config->get_only_copy_imported_files());
885                 }
886         }
887
888 }
889
890
891 void
892 ARDOUR_UI::map_meter_falloff ()
893 {
894         const char* action = X_("MeterFalloffMedium");
895
896         float val = Config->get_meter_falloff ();
897         MeterFalloff code = meter_falloff_from_float(val);
898
899         switch (code) {
900         case MeterFalloffOff:
901                 action = X_("MeterFalloffOff");
902                 break;
903         case MeterFalloffSlowest:
904                 action = X_("MeterFalloffSlowest");
905                 break;
906         case MeterFalloffSlow:
907                 action = X_("MeterFalloffSlow");
908                 break;
909         case MeterFalloffMedium:
910                 action = X_("MeterFalloffMedium");
911                 break;
912         case MeterFalloffFast:
913                 action = X_("MeterFalloffFast");
914                 break;
915         case MeterFalloffFaster:
916                 action = X_("MeterFalloffFaster");
917                 break;
918         case MeterFalloffFastest:
919                 action = X_("MeterFalloffFastest");
920                 break;
921         }
922
923         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
924
925         if (act) {
926                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
927                 if (ract && !ract->get_active()) {
928                         ract->set_active (true);
929                 }
930         }
931 }
932
933 void
934 ARDOUR_UI::map_meter_hold ()
935 {
936         const char* action = X_("MeterHoldMedium");
937
938         /* XXX hack alert. Fix this. Please */
939
940         float val = Config->get_meter_hold ();
941         MeterHold code = (MeterHold) (int) (floor (val));
942
943         switch (code) {
944         case MeterHoldOff:
945                 action = X_("MeterHoldOff");
946                 break;
947         case MeterHoldShort:
948                 action = X_("MeterHoldShort");
949                 break;
950         case MeterHoldMedium:
951                 action = X_("MeterHoldMedium");
952                 break;
953         case MeterHoldLong:
954                 action = X_("MeterHoldLong");
955                 break;
956         }
957
958         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
959
960         if (act) {
961                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
962                 if (ract && !ract->get_active()) {
963                         ract->set_active (true);
964                 }
965         }
966 }
967
968 void 
969 ARDOUR_UI::set_meter_hold (MeterHold val)
970 {
971         const char* action = 0;
972         float fval;
973
974         fval = meter_hold_to_float (val);
975
976         switch (val) {
977         case MeterHoldOff:
978                 action = X_("MeterHoldOff");
979                 break;
980         case MeterHoldShort:
981                 action = X_("MeterHoldShort");
982                 break;
983         case MeterHoldMedium:
984                 action = X_("MeterHoldMedium");
985                 break;
986         case MeterHoldLong:
987                 action = X_("MeterHoldLong");
988                 break;
989         }
990
991         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
992         
993         if (act) {
994                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
995                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
996                         Config->set_meter_hold (fval);
997                 }
998         }
999 }
1000
1001 void
1002 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
1003 {
1004         const char* action = 0;
1005         float fval;
1006
1007         fval = meter_falloff_to_float (val);
1008
1009         switch (val) {
1010         case MeterFalloffOff:
1011                 action = X_("MeterFalloffOff");
1012                 break;
1013         case MeterFalloffSlowest:
1014                 action = X_("MeterFalloffSlowest");
1015                 break;
1016         case MeterFalloffSlow:
1017                 action = X_("MeterFalloffSlow");
1018                 break;
1019         case MeterFalloffMedium:
1020                 action = X_("MeterFalloffMedium");
1021                 break;
1022         case MeterFalloffFast:
1023                 action = X_("MeterFalloffFast");
1024                 break;
1025         case MeterFalloffFaster:
1026                 action = X_("MeterFalloffFaster");
1027                 break;
1028         case MeterFalloffFastest:
1029                 action = X_("MeterFalloffFastest");
1030                 break;
1031         }
1032
1033         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
1034
1035         if (act) {
1036                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
1037                 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
1038                         Config->set_meter_falloff (fval);
1039                 }
1040         }
1041 }
1042
1043 void
1044 ARDOUR_UI::parameter_changed (const char* parameter_name)
1045 {
1046         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
1047
1048 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1049         
1050         if (PARAM_IS ("slave-source")) {
1051
1052                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
1053                 
1054                 switch (Config->get_slave_source()) {
1055                 case None:
1056                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
1057                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
1058                         break;
1059
1060                 default:
1061                         /* XXX need to make auto-play is off as well as insensitive */
1062                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
1063                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
1064                         break;
1065                 }
1066
1067         } else if (PARAM_IS ("send-mtc")) {
1068
1069                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
1070
1071         } else if (PARAM_IS ("send-mmc")) {
1072
1073
1074                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
1075
1076         } else if (PARAM_IS ("use-osc")) {
1077
1078 #ifdef HAVE_LIBLO
1079                 if (Config->get_use_osc()) {
1080                         osc->start ();
1081                 } else {
1082                         osc->stop ();
1083                 }
1084 #endif
1085
1086                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
1087                 
1088         } else if (PARAM_IS ("mmc-control")) {
1089                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
1090
1091         } else if (PARAM_IS ("midi-feedback")) {
1092                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
1093         } else if (PARAM_IS ("do-not-record-plugins")) {
1094                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
1095         } else if (PARAM_IS ("latched-record-enable")) {
1096                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1097         } else if (PARAM_IS ("solo-latched")) {
1098                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
1099         } else if (PARAM_IS ("show-solo-mutes")) {
1100                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
1101         } else if (PARAM_IS ("solo-model")) {
1102                 map_solo_model ();
1103         } else if (PARAM_IS ("auto-play")) {
1104                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
1105         } else if (PARAM_IS ("auto-return")) {
1106                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
1107         } else if (PARAM_IS ("auto-input")) {
1108                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
1109         } else if (PARAM_IS ("tape-machine-mode")) {
1110                 ActionManager::map_some_state ("options", "ToggleTapeMachineMode", &Configuration::get_tape_machine_mode);
1111         } else if (PARAM_IS ("punch-out")) {
1112                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
1113                 if (!Config->get_punch_out()) {
1114                         unset_dual_punch ();
1115                 }
1116         } else if (PARAM_IS ("punch-in")) {
1117                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
1118                 if (!Config->get_punch_in()) {
1119                         unset_dual_punch ();
1120                 }
1121         } else if (PARAM_IS ("clicking")) {
1122                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
1123         } else if (PARAM_IS ("jack-time-master")) {
1124                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
1125         } else if (PARAM_IS ("plugins-stop-with-transport")) {
1126                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
1127         } else if (PARAM_IS ("latched-record-enable")) {
1128                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1129         } else if (PARAM_IS ("verify-remove-last-capture")) {
1130                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
1131         } else if (PARAM_IS ("periodic-safety-backups")) {
1132                 ActionManager::map_some_state ("options",  "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
1133         } else if (PARAM_IS ("stop-recording-on-xrun")) {
1134                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
1135         } else if (PARAM_IS ("create-xrun-marker")) {
1136                 ActionManager::map_some_state ("options",  "CreateXrunMarker", &Configuration::get_create_xrun_marker);
1137         } else if (PARAM_IS ("sync-all-route-ordering")) {
1138                 ActionManager::map_some_state ("options",  "SyncEditorAndMixerTrackOrder", &Configuration::get_sync_all_route_ordering);
1139         } else if (PARAM_IS ("stop-at-session-end")) {
1140                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
1141         } else if (PARAM_IS ("monitoring-model")) {
1142                 map_monitor_model ();
1143         } else if (PARAM_IS ("denormal-model")) {
1144                 map_denormal_model ();
1145         } else if (PARAM_IS ("denormal-protection")) {
1146                 map_denormal_protection ();
1147         } else if (PARAM_IS ("remote-model")) {
1148                 map_remote_model ();
1149         } else if (PARAM_IS ("use-video-sync")) {
1150                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
1151         } else if (PARAM_IS ("quieten-at-speed")) {
1152                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
1153         } else if (PARAM_IS ("shuttle-behaviour")) {
1154
1155                 switch (Config->get_shuttle_behaviour ()) {
1156                 case Sprung:
1157                         shuttle_style_button.set_active_text (_("sprung"));
1158                         shuttle_fract = 0.0;
1159                         shuttle_box.queue_draw ();
1160                         if (session) {
1161                                 if (session->transport_rolling()) {
1162                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
1163                                         session->request_transport_speed (1.0);
1164                                 }
1165                         }
1166                         break;
1167                 case Wheel:
1168                         shuttle_style_button.set_active_text (_("wheel"));
1169                         break;
1170                 }
1171
1172         } else if (PARAM_IS ("shuttle-units")) {
1173                 
1174                 switch (Config->get_shuttle_units()) {
1175                 case Percentage:
1176                         shuttle_units_button.set_label("% ");
1177                         break;
1178                 case Semitones:
1179                         shuttle_units_button.set_label(_("ST"));
1180                         break;
1181                 }
1182         } else if (PARAM_IS ("input-auto-connect")) {
1183                 map_input_auto_connect ();
1184         } else if (PARAM_IS ("output-auto-connect")) {
1185                 map_output_auto_connect ();
1186         } else if (PARAM_IS ("native-file-header-format")) {
1187                 map_file_header_format ();
1188         } else if (PARAM_IS ("native-file-data-format")) {
1189                 map_file_data_format ();
1190         } else if (PARAM_IS ("meter-hold")) {
1191                 map_meter_hold ();
1192         } else if (PARAM_IS ("meter-falloff")) {
1193                 map_meter_falloff ();
1194         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
1195                 if (session) {
1196                         primary_clock.set (session->audible_frame(), true);
1197                         secondary_clock.set (session->audible_frame(), true);
1198                 } else {
1199                         primary_clock.set (0, true);
1200                         secondary_clock.set (0, true);
1201                 }
1202         } else if (PARAM_IS ("use-overlap-equivalency")) {
1203                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
1204         } else if (PARAM_IS ("primary-clock-delta-edit-cursor")) {
1205                 ActionManager::map_some_state ("options",  "PrimaryClockDeltaEditCursor", &Configuration::get_primary_clock_delta_edit_cursor);
1206         } else if (PARAM_IS ("secondary-clock-delta-edit-cursor")) {
1207                 ActionManager::map_some_state ("options",  "SecondaryClockDeltaEditCursor", &Configuration::get_secondary_clock_delta_edit_cursor);
1208         } else if (PARAM_IS ("only-copy-imported-files")) {
1209                 map_only_copy_imported_files ();
1210         } else if (PARAM_IS ("show-track-meters")) {
1211                 ActionManager::map_some_state ("options",  "ShowTrackMeters", &Configuration::get_show_track_meters);
1212                 editor->toggle_meter_updating();
1213         } else if (PARAM_IS ("default-narrow_ms")) {
1214                 ActionManager::map_some_state ("options",  "DefaultNarrowMS", &Configuration::get_default_narrow_ms);
1215         } else if (PARAM_IS ("rubberbanding-snaps-to-grid")) {
1216                 ActionManager::map_some_state ("options", "RubberbandingSnapsToGrid", &Configuration::get_rubberbanding_snaps_to_grid);
1217         }
1218
1219                            
1220
1221 #undef PARAM_IS
1222 }