Remove some debugging code which causes slow flashy screen updates.
[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
34 #include "i18n.h"
35
36 using namespace Gtk;
37 using namespace Gtkmm2ext;
38 using namespace ARDOUR;
39 using namespace PBD;
40 using namespace sigc;
41
42 void
43 ARDOUR_UI::toggle_time_master ()
44 {
45         ActionManager::toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
46 }
47
48 void
49 ARDOUR_UI::toggle_send_mtc ()
50 {
51         ActionManager::toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
52 }
53
54 void
55 ARDOUR_UI::toggle_send_mmc ()
56 {
57         ActionManager::toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
58 }
59
60 void
61 ARDOUR_UI::toggle_use_mmc ()
62 {
63         ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
64 }
65
66 void
67 ARDOUR_UI::toggle_use_osc ()
68 {
69         ActionManager::toggle_config_state ("options", "UseOSC", &Configuration::set_use_osc, &Configuration::get_use_osc);
70 }
71
72 void
73 ARDOUR_UI::toggle_send_midi_feedback ()
74 {
75         ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
76 }
77
78 void
79 ARDOUR_UI::toggle_denormal_protection ()
80 {
81         ActionManager::toggle_config_state ("options", "DenormalProtection", &Configuration::set_denormal_protection, &Configuration::get_denormal_protection);
82 }
83
84 void
85 ARDOUR_UI::toggle_only_copy_imported_files ()
86 {
87         ActionManager::toggle_config_state ("options", "OnlyCopyImportedFiles", &Configuration::set_only_copy_imported_files, &Configuration::get_only_copy_imported_files);
88 }
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::toggle_punch_in ()
392 {
393         ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
394 }
395
396 void
397 ARDOUR_UI::toggle_punch_out ()
398 {
399         ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
400 }
401
402 void
403 ARDOUR_UI::toggle_video_sync()
404 {
405         Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
406         if (act) {
407                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
408                 Config->set_use_video_sync (tact->get_active());
409         }
410 }
411
412 void
413 ARDOUR_UI::toggle_editing_space()
414 {
415         Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
416         if (act) {
417                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
418                 if (tact->get_active()) {
419                         maximise_editing_space ();
420                 } else {
421                         restore_editing_space ();
422                 }
423         }
424 }
425
426 void
427 ARDOUR_UI::toggle_StopPluginsWithTransport()
428 {
429         ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
430 }
431
432 void
433 ARDOUR_UI::toggle_LatchedRecordEnable()
434 {
435         ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
436 }
437
438 void
439 ARDOUR_UI::toggle_RegionEquivalentsOverlap()
440 {
441         ActionManager::toggle_config_state ("options", "RegionEquivalentsOverlap", &Configuration::set_use_overlap_equivalency, &Configuration::get_use_overlap_equivalency);
442 }
443
444 void
445 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
446 {
447         ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
448 }
449
450 void
451 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
452 {
453         ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
454 }
455
456 void
457 ARDOUR_UI::toggle_PeriodicSafetyBackups()
458 {
459         ActionManager::toggle_config_state ("options", "PeriodicSafetyBackups", &Configuration::set_periodic_safety_backups, &Configuration::get_periodic_safety_backups);
460 }
461
462 void
463 ARDOUR_UI::toggle_StopRecordingOnXrun()
464 {
465         ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
466 }
467
468 void
469 ARDOUR_UI::toggle_sync_order_keys ()
470 {
471         ActionManager::toggle_config_state ("options", "SyncEditorAndMixerTrackOrder", &Configuration::set_sync_all_route_ordering, &Configuration::get_sync_all_route_ordering);
472 }
473
474 void
475 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
476 {
477         ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
478 }
479
480 void
481 ARDOUR_UI::toggle_GainReduceFastTransport()
482 {
483         ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
484 }
485
486 void
487 ARDOUR_UI::toggle_LatchedSolo()
488 {
489         ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
490 }
491
492 void
493 ARDOUR_UI::toggle_ShowSoloMutes()
494 {
495         ActionManager::toggle_config_state ("options", "ShowSoloMutes", &Configuration::set_show_solo_mutes, &Configuration::get_show_solo_mutes);
496 }
497
498 void
499 ARDOUR_UI::toggle_PrimaryClockDeltaEditCursor()
500 {
501         ActionManager::toggle_config_state ("options", "PrimaryClockDeltaEditCursor", &Configuration::set_primary_clock_delta_edit_cursor, &Configuration::get_primary_clock_delta_edit_cursor);
502 }
503
504 void
505 ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor()
506 {
507         ActionManager::toggle_config_state ("options", "SecondaryClockDeltaEditCursor", &Configuration::set_secondary_clock_delta_edit_cursor, &Configuration::get_secondary_clock_delta_edit_cursor);
508 }
509
510 void
511 ARDOUR_UI::mtc_port_changed ()
512 {
513         bool have_mtc;
514
515         if (session) {
516                 if (session->mtc_port()) {
517                         have_mtc = true;
518                 } else {
519                         have_mtc = false;
520                 }
521         } else {
522                 have_mtc = false;
523         }
524
525         positional_sync_strings.clear ();
526         positional_sync_strings.push_back (slave_source_to_string (None));
527         if (have_mtc) {
528                 positional_sync_strings.push_back (slave_source_to_string (MTC));
529         }
530         positional_sync_strings.push_back (slave_source_to_string (JACK));
531         
532         set_popdown_strings (sync_option_combo, positional_sync_strings);
533 }
534
535 void
536 ARDOUR_UI::setup_session_options ()
537 {
538         mtc_port_changed ();
539
540         Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
541 }
542
543
544 void
545 ARDOUR_UI::map_solo_model ()
546 {
547         const char* on;
548
549         if (Config->get_solo_model() == InverseMute) {
550                 on = X_("SoloInPlace");
551         } else {
552                 on = X_("SoloViaBus");
553         }
554
555         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
556         if (act) {
557                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
558
559                 if (tact && !tact->get_active()) {
560                         tact->set_active (true);
561                 }
562         }
563 }
564
565 void
566 ARDOUR_UI::map_monitor_model ()
567 {
568         const char* on = 0;
569
570         switch (Config->get_monitoring_model()) {
571         case HardwareMonitoring:
572                 on = X_("UseHardwareMonitoring");
573                 break;
574         case SoftwareMonitoring:
575                 on = X_("UseSoftwareMonitoring");
576                 break;
577         case ExternalMonitoring:
578                 on = X_("UseExternalMonitoring");
579                 break;
580         }
581
582         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
583         if (act) {
584                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
585
586                 if (tact && !tact->get_active()) {
587                         tact->set_active (true);
588                 }
589         }
590 }
591
592 void
593 ARDOUR_UI::map_denormal_protection ()
594 {
595         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("DenormalProtection"));
596         if (act) {
597                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
598
599                 if (tact && !tact->get_active()) {
600                         tact->set_active (Config->get_denormal_protection());
601                 }
602         }
603 }
604
605 void
606 ARDOUR_UI::map_denormal_model ()
607 {
608         const char* on = 0;
609
610         switch (Config->get_denormal_model()) {
611         case DenormalNone:
612                 on = X_("DenormalNone");
613                 break;
614         case DenormalFTZ:
615                 on = X_("DenormalFTZ");
616                 break;
617         case DenormalDAZ:
618                 on = X_("DenormalDAZ");
619                 break;
620         case DenormalFTZDAZ:
621                 on = X_("DenormalFTZDAZ");
622                 break;
623         }
624
625         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
626         if (act) {
627                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
628
629                 if (tact && !tact->get_active()) {
630                         tact->set_active (true);
631                 }
632         }
633 }
634
635 void
636 ARDOUR_UI::map_remote_model ()
637 {
638         const char* on = 0;
639
640         switch (Config->get_remote_model()) {
641         case UserOrdered:
642                 on = X_("RemoteUserDefined");
643                 break;
644         case MixerOrdered:
645                 on = X_("RemoteMixerDefined");
646                 break;
647         case EditorOrdered:
648                 on = X_("RemoteEditorDefined");
649                 break;
650         }
651
652         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
653         if (act) {
654                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
655
656                 if (tact && !tact->get_active()) {
657                         tact->set_active (true);
658                 }
659         }
660 }
661
662 void
663 ARDOUR_UI::map_file_header_format ()
664 {
665         const char* action = 0;
666
667         switch (Config->get_native_file_header_format()) {
668         case BWF:
669                 action = X_("FileHeaderFormatBWF");
670                 break;
671
672         case WAVE:
673                 action = X_("FileHeaderFormatWAVE");
674                 break;
675
676         case WAVE64:
677                 action = X_("FileHeaderFormatWAVE64");
678                 break;
679
680         case iXML:
681                 action = X_("FileHeaderFormatiXML");
682                 break;
683
684         case RF64:
685                 action = X_("FileHeaderFormatRF64");
686                 break;
687
688         case CAF:
689                 action = X_("FileHeaderFormatCAF");
690                 break;
691
692         default:
693                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
694                                          Config->get_native_file_header_format()) << endmsg;
695                 /*NOTREACHED*/
696         }
697
698
699         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
700
701         if (act) {
702                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
703
704                 if (tact && !tact->get_active()) {
705                         tact->set_active (true);
706                 }
707         }
708 }
709
710 void
711 ARDOUR_UI::map_file_data_format ()
712 {
713         const char* action = 0;
714
715         switch (Config->get_native_file_data_format()) {
716         case FormatFloat:
717                 action = X_("FileDataFormatFloat");
718                 break;
719
720         case FormatInt24:
721                 action = X_("FileDataFormat24bit");
722                 break;
723
724         case FormatInt16:
725                 action = X_("FileDataFormat16bit");
726                 break;
727
728         default:
729                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
730                                          Config->get_native_file_data_format()) << endmsg;
731                 /*NOTREACHED*/
732         }
733
734
735         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
736
737         if (act) {
738                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
739
740                 if (tact && !tact->get_active()) {
741                         tact->set_active (true);
742                 }
743         }
744 }
745
746 void
747 ARDOUR_UI::map_input_auto_connect ()
748 {
749         const char* on;
750
751         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
752                 on = "InputAutoConnectManual";
753         } else {
754                 on = "InputAutoConnectPhysical";
755         }
756
757         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
758         if (act) {
759                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
760
761                 if (tact && !tact->get_active()) {
762                         tact->set_active (true);
763                 }
764         }
765 }
766
767 void
768 ARDOUR_UI::map_output_auto_connect ()
769 {
770         const char* on;
771
772         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
773                 on = "OutputAutoConnectManual";
774         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
775                 on = "OutputAutoConnectPhysical";
776         } else {
777                 on = "OutputAutoConnectMaster";
778         }
779
780         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
781         if (act) {
782                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
783                 
784                 if (tact && !tact->get_active()) {
785                         tact->set_active (true);
786                 }
787         }
788 }
789
790 void
791 ARDOUR_UI::map_only_copy_imported_files ()
792 {
793         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("OnlyCopyImportedFiles"));
794         if (act) {
795                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
796
797                 if (tact && !tact->get_active()) {
798                         tact->set_active (Config->get_only_copy_imported_files());
799                 }
800         }
801
802 }
803
804
805 void
806 ARDOUR_UI::map_meter_falloff ()
807 {
808         const char* action = X_("MeterFalloffMedium");
809
810         float val = Config->get_meter_falloff ();
811         MeterFalloff code = meter_falloff_from_float(val);
812
813         switch (code) {
814         case MeterFalloffOff:
815                 action = X_("MeterFalloffOff");
816                 break;
817         case MeterFalloffSlowest:
818                 action = X_("MeterFalloffSlowest");
819                 break;
820         case MeterFalloffSlow:
821                 action = X_("MeterFalloffSlow");
822                 break;
823         case MeterFalloffMedium:
824                 action = X_("MeterFalloffMedium");
825                 break;
826         case MeterFalloffFast:
827                 action = X_("MeterFalloffFast");
828                 break;
829         case MeterFalloffFaster:
830                 action = X_("MeterFalloffFaster");
831                 break;
832         case MeterFalloffFastest:
833                 action = X_("MeterFalloffFastest");
834                 break;
835         }
836
837         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
838
839         if (act) {
840                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
841                 if (ract && !ract->get_active()) {
842                         ract->set_active (true);
843                 }
844         }
845 }
846
847 void
848 ARDOUR_UI::map_meter_hold ()
849 {
850         const char* action = X_("MeterHoldMedium");
851
852         /* XXX hack alert. Fix this. Please */
853
854         float val = Config->get_meter_hold ();
855         MeterHold code = (MeterHold) (int) (floor (val));
856
857         switch (code) {
858         case MeterHoldOff:
859                 action = X_("MeterHoldOff");
860                 break;
861         case MeterHoldShort:
862                 action = X_("MeterHoldShort");
863                 break;
864         case MeterHoldMedium:
865                 action = X_("MeterHoldMedium");
866                 break;
867         case MeterHoldLong:
868                 action = X_("MeterHoldLong");
869                 break;
870         }
871
872         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
873
874         if (act) {
875                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
876                 if (ract && !ract->get_active()) {
877                         ract->set_active (true);
878                 }
879         }
880 }
881
882 void 
883 ARDOUR_UI::set_meter_hold (MeterHold val)
884 {
885         const char* action = 0;
886         float fval;
887
888         fval = meter_hold_to_float (val);
889
890         switch (val) {
891         case MeterHoldOff:
892                 action = X_("MeterHoldOff");
893                 break;
894         case MeterHoldShort:
895                 action = X_("MeterHoldShort");
896                 break;
897         case MeterHoldMedium:
898                 action = X_("MeterHoldMedium");
899                 break;
900         case MeterHoldLong:
901                 action = X_("MeterHoldLong");
902                 break;
903         }
904
905         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
906         
907         if (act) {
908                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
909                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
910                         Config->set_meter_hold (fval);
911                 }
912         }
913 }
914
915 void
916 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
917 {
918         const char* action = 0;
919         float fval;
920
921         fval = meter_falloff_to_float (val);
922
923         switch (val) {
924         case MeterFalloffOff:
925                 action = X_("MeterFalloffOff");
926                 break;
927         case MeterFalloffSlowest:
928                 action = X_("MeterFalloffSlowest");
929                 break;
930         case MeterFalloffSlow:
931                 action = X_("MeterFalloffSlow");
932                 break;
933         case MeterFalloffMedium:
934                 action = X_("MeterFalloffMedium");
935                 break;
936         case MeterFalloffFast:
937                 action = X_("MeterFalloffFast");
938                 break;
939         case MeterFalloffFaster:
940                 action = X_("MeterFalloffFaster");
941                 break;
942         case MeterFalloffFastest:
943                 action = X_("MeterFalloffFastest");
944                 break;
945         }
946
947         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
948
949         if (act) {
950                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
951                 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
952                         Config->set_meter_falloff (fval);
953                 }
954         }
955 }
956
957 void
958 ARDOUR_UI::parameter_changed (const char* parameter_name)
959 {
960         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
961
962 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
963         
964         if (PARAM_IS ("slave-source")) {
965
966                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
967                 
968                 switch (Config->get_slave_source()) {
969                 case None:
970                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
971                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
972                         break;
973
974                 default:
975                         /* XXX need to make auto-play is off as well as insensitive */
976                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
977                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
978                         break;
979                 }
980
981         } else if (PARAM_IS ("send-mtc")) {
982
983                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
984
985         } else if (PARAM_IS ("send-mmc")) {
986
987                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
988
989         } else if (PARAM_IS ("use-osc")) {
990
991 #ifdef HAVE_LIBLO
992                 if (Config->get_use_osc()) {
993                         osc->start ();
994                 } else {
995                         osc->stop ();
996                 }
997 #endif
998
999                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
1000                 
1001         } else if (PARAM_IS ("mmc-control")) {
1002                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
1003         } else if (PARAM_IS ("midi-feedback")) {
1004                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
1005         } else if (PARAM_IS ("do-not-record-plugins")) {
1006                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
1007         } else if (PARAM_IS ("latched-record-enable")) {
1008                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1009         } else if (PARAM_IS ("solo-latched")) {
1010                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
1011         } else if (PARAM_IS ("show-solo-mutes")) {
1012                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
1013         } else if (PARAM_IS ("solo-model")) {
1014                 map_solo_model ();
1015         } else if (PARAM_IS ("auto-play")) {
1016                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
1017         } else if (PARAM_IS ("auto-return")) {
1018                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
1019         } else if (PARAM_IS ("auto-input")) {
1020                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
1021         } else if (PARAM_IS ("punch-out")) {
1022                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
1023         } else if (PARAM_IS ("punch-in")) {
1024                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
1025         } else if (PARAM_IS ("clicking")) {
1026                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
1027         } else if (PARAM_IS ("jack-time-master")) {
1028                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
1029         } else if (PARAM_IS ("plugins-stop-with-transport")) {
1030                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
1031         } else if (PARAM_IS ("latched-record-enable")) {
1032                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1033         } else if (PARAM_IS ("verify-remove-last-capture")) {
1034                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
1035         } else if (PARAM_IS ("periodic-safety-backups")) {
1036                 ActionManager::map_some_state ("options",  "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
1037         } else if (PARAM_IS ("stop-recording-on-xrun")) {
1038                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
1039         } else if (PARAM_IS ("sync-all-route-ordering")) {
1040                 ActionManager::map_some_state ("options",  "SyncEditorAndMixerTrackOrder", &Configuration::get_sync_all_route_ordering);
1041         } else if (PARAM_IS ("stop-at-session-end")) {
1042                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
1043         } else if (PARAM_IS ("monitoring-model")) {
1044                 map_monitor_model ();
1045         } else if (PARAM_IS ("denormal-model")) {
1046                 map_denormal_model ();
1047         } else if (PARAM_IS ("denormal-protection")) {
1048                 map_denormal_protection ();
1049         } else if (PARAM_IS ("remote-model")) {
1050                 map_remote_model ();
1051         } else if (PARAM_IS ("use-video-sync")) {
1052                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
1053         } else if (PARAM_IS ("quieten-at-speed")) {
1054                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
1055         } else if (PARAM_IS ("shuttle-behaviour")) {
1056
1057                 switch (Config->get_shuttle_behaviour ()) {
1058                 case Sprung:
1059                         shuttle_style_button.set_active_text (_("sprung"));
1060                         shuttle_fract = 0.0;
1061                         shuttle_box.queue_draw ();
1062                         if (session) {
1063                                 if (session->transport_rolling()) {
1064                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
1065                                         session->request_transport_speed (1.0);
1066                                 }
1067                         }
1068                         break;
1069                 case Wheel:
1070                         shuttle_style_button.set_active_text (_("wheel"));
1071                         break;
1072                 }
1073
1074         } else if (PARAM_IS ("shuttle-units")) {
1075                 
1076                 switch (Config->get_shuttle_units()) {
1077                 case Percentage:
1078                         shuttle_units_button.set_label("% ");
1079                         break;
1080                 case Semitones:
1081                         shuttle_units_button.set_label(_("ST"));
1082                         break;
1083                 }
1084         } else if (PARAM_IS ("input-auto-connect")) {
1085                 map_input_auto_connect ();
1086         } else if (PARAM_IS ("output-auto-connect")) {
1087                 map_output_auto_connect ();
1088         } else if (PARAM_IS ("native-file-header-format")) {
1089                 map_file_header_format ();
1090         } else if (PARAM_IS ("native-file-data-format")) {
1091                 map_file_data_format ();
1092         } else if (PARAM_IS ("meter-hold")) {
1093                 map_meter_hold ();
1094         } else if (PARAM_IS ("meter-falloff")) {
1095                 map_meter_falloff ();
1096         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
1097                 if (session) {
1098                         primary_clock.set (session->audible_frame(), true);
1099                         secondary_clock.set (session->audible_frame(), true);
1100                 } else {
1101                         primary_clock.set (0, true);
1102                         secondary_clock.set (0, true);
1103                 }
1104         } else if (PARAM_IS ("use-overlap-equivalency")) {
1105                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
1106         } else if (PARAM_IS ("primary-clock-delta-edit-cursor")) {
1107                 ActionManager::map_some_state ("options",  "PrimaryClockDeltaEditCursor", &Configuration::get_primary_clock_delta_edit_cursor);
1108         } else if (PARAM_IS ("secondary-clock-delta-edit-cursor")) {
1109                 ActionManager::map_some_state ("options",  "SecondaryClockDeltaEditCursor", &Configuration::get_secondary_clock_delta_edit_cursor);
1110         } else if (PARAM_IS ("only-copy-imported-files")) {
1111                 map_only_copy_imported_files ();
1112         }
1113
1114 #undef PARAM_IS
1115 }