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