Add option to use narrow mixer strips by default, and fix ardour_system.rc being...
[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::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::toggle_ShowTrackMeters()
512 {
513         ActionManager::toggle_config_state ("options", "ShowTrackMeters", &Configuration::set_show_track_meters, &Configuration::get_show_track_meters);
514 }
515
516 void
517 ARDOUR_UI::toggle_use_narrow_ms()
518 {
519         ActionManager::toggle_config_state ("options", "DefaultNarrowMS", &Configuration::set_default_narrow_ms, &Configuration::get_default_narrow_ms);
520 }
521
522 void
523 ARDOUR_UI::mtc_port_changed ()
524 {
525         bool have_mtc;
526
527         if (session) {
528                 if (session->mtc_port()) {
529                         have_mtc = true;
530                 } else {
531                         have_mtc = false;
532                 }
533         } else {
534                 have_mtc = false;
535         }
536
537         positional_sync_strings.clear ();
538         positional_sync_strings.push_back (slave_source_to_string (None));
539         if (have_mtc) {
540                 positional_sync_strings.push_back (slave_source_to_string (MTC));
541         }
542         positional_sync_strings.push_back (slave_source_to_string (JACK));
543
544         set_popdown_strings (sync_option_combo, positional_sync_strings);
545 }
546
547 void
548 ARDOUR_UI::setup_session_options ()
549 {
550         mtc_port_changed ();
551
552         Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
553 }
554
555
556 void
557 ARDOUR_UI::map_solo_model ()
558 {
559         const char* on;
560
561         if (Config->get_solo_model() == InverseMute) {
562                 on = X_("SoloInPlace");
563         } else {
564                 on = X_("SoloViaBus");
565         }
566
567         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
568         if (act) {
569                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
570
571                 if (tact && !tact->get_active()) {
572                         tact->set_active (true);
573                 }
574         }
575 }
576
577 void
578 ARDOUR_UI::map_monitor_model ()
579 {
580         const char* on = 0;
581
582         switch (Config->get_monitoring_model()) {
583         case HardwareMonitoring:
584                 on = X_("UseHardwareMonitoring");
585                 break;
586         case SoftwareMonitoring:
587                 on = X_("UseSoftwareMonitoring");
588                 break;
589         case ExternalMonitoring:
590                 on = X_("UseExternalMonitoring");
591                 break;
592         }
593
594         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
595         if (act) {
596                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
597
598                 if (tact && !tact->get_active()) {
599                         tact->set_active (true);
600                 }
601         }
602 }
603
604 void
605 ARDOUR_UI::map_denormal_protection ()
606 {
607         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("DenormalProtection"));
608         if (act) {
609                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
610
611                 if (tact && !tact->get_active()) {
612                         tact->set_active (Config->get_denormal_protection());
613                 }
614         }
615 }
616
617 void
618 ARDOUR_UI::map_denormal_model ()
619 {
620         const char* on = 0;
621
622         switch (Config->get_denormal_model()) {
623         case DenormalNone:
624                 on = X_("DenormalNone");
625                 break;
626         case DenormalFTZ:
627                 on = X_("DenormalFTZ");
628                 break;
629         case DenormalDAZ:
630                 on = X_("DenormalDAZ");
631                 break;
632         case DenormalFTZDAZ:
633                 on = X_("DenormalFTZDAZ");
634                 break;
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_remote_model ()
649 {
650         const char* on = 0;
651
652         switch (Config->get_remote_model()) {
653         case UserOrdered:
654                 on = X_("RemoteUserDefined");
655                 break;
656         case MixerOrdered:
657                 on = X_("RemoteMixerDefined");
658                 break;
659         case EditorOrdered:
660                 on = X_("RemoteEditorDefined");
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_file_header_format ()
676 {
677         const char* action = 0;
678
679         switch (Config->get_native_file_header_format()) {
680         case BWF:
681                 action = X_("FileHeaderFormatBWF");
682                 break;
683
684         case WAVE:
685                 action = X_("FileHeaderFormatWAVE");
686                 break;
687
688         case WAVE64:
689                 action = X_("FileHeaderFormatWAVE64");
690                 break;
691
692         case iXML:
693                 action = X_("FileHeaderFormatiXML");
694                 break;
695
696         case RF64:
697                 action = X_("FileHeaderFormatRF64");
698                 break;
699
700         case CAF:
701                 action = X_("FileHeaderFormatCAF");
702                 break;
703
704         default:
705                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
706                                          Config->get_native_file_header_format()) << endmsg;
707                 /*NOTREACHED*/
708         }
709
710
711         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
712
713         if (act) {
714                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
715
716                 if (tact && !tact->get_active()) {
717                         tact->set_active (true);
718                 }
719         }
720 }
721
722 void
723 ARDOUR_UI::map_file_data_format ()
724 {
725         const char* action = 0;
726
727         switch (Config->get_native_file_data_format()) {
728         case FormatFloat:
729                 action = X_("FileDataFormatFloat");
730                 break;
731
732         case FormatInt24:
733                 action = X_("FileDataFormat24bit");
734                 break;
735
736         case FormatInt16:
737                 action = X_("FileDataFormat16bit");
738                 break;
739
740         default:
741                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
742                                          Config->get_native_file_data_format()) << endmsg;
743                 /*NOTREACHED*/
744         }
745
746
747         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
748
749         if (act) {
750                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
751
752                 if (tact && !tact->get_active()) {
753                         tact->set_active (true);
754                 }
755         }
756 }
757
758 void
759 ARDOUR_UI::map_input_auto_connect ()
760 {
761         const char* on;
762
763         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
764                 on = "InputAutoConnectManual";
765         } else {
766                 on = "InputAutoConnectPhysical";
767         }
768
769         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
770         if (act) {
771                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
772
773                 if (tact && !tact->get_active()) {
774                         tact->set_active (true);
775                 }
776         }
777 }
778
779 void
780 ARDOUR_UI::map_output_auto_connect ()
781 {
782         const char* on;
783
784         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
785                 on = "OutputAutoConnectManual";
786         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
787                 on = "OutputAutoConnectPhysical";
788         } else {
789                 on = "OutputAutoConnectMaster";
790         }
791
792         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
793         if (act) {
794                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
795                 
796                 if (tact && !tact->get_active()) {
797                         tact->set_active (true);
798                 }
799         }
800 }
801
802 void
803 ARDOUR_UI::map_only_copy_imported_files ()
804 {
805         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("OnlyCopyImportedFiles"));
806         if (act) {
807                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
808
809                 if (tact && !tact->get_active()) {
810                         tact->set_active (Config->get_only_copy_imported_files());
811                 }
812         }
813
814 }
815
816 void
817 ARDOUR_UI::map_meter_falloff ()
818 {
819         const char* action = X_("MeterFalloffMedium");
820
821         float val = Config->get_meter_falloff ();
822         MeterFalloff code = meter_falloff_from_float(val);
823
824         switch (code) {
825         case MeterFalloffOff:
826                 action = X_("MeterFalloffOff");
827                 break;
828         case MeterFalloffSlowest:
829                 action = X_("MeterFalloffSlowest");
830                 break;
831         case MeterFalloffSlow:
832                 action = X_("MeterFalloffSlow");
833                 break;
834         case MeterFalloffMedium:
835                 action = X_("MeterFalloffMedium");
836                 break;
837         case MeterFalloffFast:
838                 action = X_("MeterFalloffFast");
839                 break;
840         case MeterFalloffFaster:
841                 action = X_("MeterFalloffFaster");
842                 break;
843         case MeterFalloffFastest:
844                 action = X_("MeterFalloffFastest");
845                 break;
846         }
847
848         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
849
850         if (act) {
851                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
852                 if (ract && !ract->get_active()) {
853                         ract->set_active (true);
854                 }
855         }
856 }
857
858 void
859 ARDOUR_UI::map_meter_hold ()
860 {
861         const char* action = X_("MeterHoldMedium");
862
863         /* XXX hack alert. Fix this. Please */
864
865         float val = Config->get_meter_hold ();
866         MeterHold code = (MeterHold) (int) (floor (val));
867
868         switch (code) {
869         case MeterHoldOff:
870                 action = X_("MeterHoldOff");
871                 break;
872         case MeterHoldShort:
873                 action = X_("MeterHoldShort");
874                 break;
875         case MeterHoldMedium:
876                 action = X_("MeterHoldMedium");
877                 break;
878         case MeterHoldLong:
879                 action = X_("MeterHoldLong");
880                 break;
881         }
882
883         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
884
885         if (act) {
886                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
887                 if (ract && !ract->get_active()) {
888                         ract->set_active (true);
889                 }
890         }
891 }
892
893 void 
894 ARDOUR_UI::set_meter_hold (MeterHold val)
895 {
896         const char* action = 0;
897         float fval;
898
899         fval = meter_hold_to_float (val);
900
901         switch (val) {
902         case MeterHoldOff:
903                 action = X_("MeterHoldOff");
904                 break;
905         case MeterHoldShort:
906                 action = X_("MeterHoldShort");
907                 break;
908         case MeterHoldMedium:
909                 action = X_("MeterHoldMedium");
910                 break;
911         case MeterHoldLong:
912                 action = X_("MeterHoldLong");
913                 break;
914         }
915
916         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
917         
918         if (act) {
919                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
920                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
921                         Config->set_meter_hold (fval);
922                 }
923         }
924 }
925
926 void
927 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
928 {
929         const char* action = 0;
930         float fval;
931
932         fval = meter_falloff_to_float (val);
933
934         switch (val) {
935         case MeterFalloffOff:
936                 action = X_("MeterFalloffOff");
937                 break;
938         case MeterFalloffSlowest:
939                 action = X_("MeterFalloffSlowest");
940                 break;
941         case MeterFalloffSlow:
942                 action = X_("MeterFalloffSlow");
943                 break;
944         case MeterFalloffMedium:
945                 action = X_("MeterFalloffMedium");
946                 break;
947         case MeterFalloffFast:
948                 action = X_("MeterFalloffFast");
949                 break;
950         case MeterFalloffFaster:
951                 action = X_("MeterFalloffFaster");
952                 break;
953         case MeterFalloffFastest:
954                 action = X_("MeterFalloffFastest");
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() && Config->get_meter_falloff () != fval) {
963                         Config->set_meter_falloff (fval);
964                 }
965         }
966 }
967
968 void
969 ARDOUR_UI::parameter_changed (const char* parameter_name)
970 {
971         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
972
973 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
974         
975         if (PARAM_IS ("slave-source")) {
976
977                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
978                 
979                 switch (Config->get_slave_source()) {
980                 case None:
981                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
982                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
983                         break;
984
985                 default:
986                         /* XXX need to make auto-play is off as well as insensitive */
987                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
988                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
989                         break;
990                 }
991
992         } else if (PARAM_IS ("send-mtc")) {
993
994                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
995
996         } else if (PARAM_IS ("send-mmc")) {
997
998                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
999
1000         } else if (PARAM_IS ("use-osc")) {
1001
1002 #ifdef HAVE_LIBLO
1003                 if (Config->get_use_osc()) {
1004                         osc->start ();
1005                 } else {
1006                         osc->stop ();
1007                 }
1008 #endif
1009
1010                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
1011                 
1012         } else if (PARAM_IS ("mmc-control")) {
1013                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
1014         } else if (PARAM_IS ("midi-feedback")) {
1015                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
1016         } else if (PARAM_IS ("do-not-record-plugins")) {
1017                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
1018         } else if (PARAM_IS ("latched-record-enable")) {
1019                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1020         } else if (PARAM_IS ("solo-latched")) {
1021                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
1022         } else if (PARAM_IS ("show-solo-mutes")) {
1023                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
1024         } else if (PARAM_IS ("solo-model")) {
1025                 map_solo_model ();
1026         } else if (PARAM_IS ("auto-play")) {
1027                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
1028         } else if (PARAM_IS ("auto-return")) {
1029                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
1030         } else if (PARAM_IS ("auto-input")) {
1031                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
1032         } else if (PARAM_IS ("punch-out")) {
1033                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
1034         } else if (PARAM_IS ("punch-in")) {
1035                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
1036         } else if (PARAM_IS ("clicking")) {
1037                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
1038         } else if (PARAM_IS ("jack-time-master")) {
1039                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
1040         } else if (PARAM_IS ("plugins-stop-with-transport")) {
1041                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
1042         } else if (PARAM_IS ("latched-record-enable")) {
1043                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1044         } else if (PARAM_IS ("verify-remove-last-capture")) {
1045                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
1046         } else if (PARAM_IS ("periodic-safety-backups")) {
1047                 ActionManager::map_some_state ("options",  "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
1048         } else if (PARAM_IS ("stop-recording-on-xrun")) {
1049                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
1050         } else if (PARAM_IS ("sync-all-route-ordering")) {
1051                 ActionManager::map_some_state ("options",  "SyncEditorAndMixerTrackOrder", &Configuration::get_sync_all_route_ordering);
1052         } else if (PARAM_IS ("stop-at-session-end")) {
1053                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
1054         } else if (PARAM_IS ("monitoring-model")) {
1055                 map_monitor_model ();
1056         } else if (PARAM_IS ("denormal-model")) {
1057                 map_denormal_model ();
1058         } else if (PARAM_IS ("denormal-protection")) {
1059                 map_denormal_protection ();
1060         } else if (PARAM_IS ("remote-model")) {
1061                 map_remote_model ();
1062         } else if (PARAM_IS ("use-video-sync")) {
1063                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
1064         } else if (PARAM_IS ("quieten-at-speed")) {
1065                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
1066         } else if (PARAM_IS ("shuttle-behaviour")) {
1067
1068                 switch (Config->get_shuttle_behaviour ()) {
1069                 case Sprung:
1070                         shuttle_style_button.set_active_text (_("sprung"));
1071                         shuttle_fract = 0.0;
1072                         shuttle_box.queue_draw ();
1073                         if (session) {
1074                                 if (session->transport_rolling()) {
1075                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
1076                                         session->request_transport_speed (1.0);
1077                                 }
1078                         }
1079                         break;
1080                 case Wheel:
1081                         shuttle_style_button.set_active_text (_("wheel"));
1082                         break;
1083                 }
1084
1085         } else if (PARAM_IS ("shuttle-units")) {
1086                 
1087                 switch (Config->get_shuttle_units()) {
1088                 case Percentage:
1089                         shuttle_units_button.set_label("% ");
1090                         break;
1091                 case Semitones:
1092                         shuttle_units_button.set_label(_("ST"));
1093                         break;
1094                 }
1095         } else if (PARAM_IS ("input-auto-connect")) {
1096                 map_input_auto_connect ();
1097         } else if (PARAM_IS ("output-auto-connect")) {
1098                 map_output_auto_connect ();
1099         } else if (PARAM_IS ("native-file-header-format")) {
1100                 map_file_header_format ();
1101         } else if (PARAM_IS ("native-file-data-format")) {
1102                 map_file_data_format ();
1103         } else if (PARAM_IS ("meter-hold")) {
1104                 map_meter_hold ();
1105         } else if (PARAM_IS ("meter-falloff")) {
1106                 map_meter_falloff ();
1107         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
1108                 if (session) {
1109                         primary_clock.set (session->audible_frame(), true);
1110                         secondary_clock.set (session->audible_frame(), true);
1111                 } else {
1112                         primary_clock.set (0, true);
1113                         secondary_clock.set (0, true);
1114                 }
1115         } else if (PARAM_IS ("use-overlap-equivalency")) {
1116                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
1117         } else if (PARAM_IS ("primary-clock-delta-edit-cursor")) {
1118                 ActionManager::map_some_state ("options",  "PrimaryClockDeltaEditCursor", &Configuration::get_primary_clock_delta_edit_cursor);
1119         } else if (PARAM_IS ("secondary-clock-delta-edit-cursor")) {
1120                 ActionManager::map_some_state ("options",  "SecondaryClockDeltaEditCursor", &Configuration::get_secondary_clock_delta_edit_cursor);
1121         } else if (PARAM_IS ("only-copy-imported-files")) {
1122                 map_only_copy_imported_files ();
1123         } else if (PARAM_IS ("show-track-meters")) {
1124                 ActionManager::map_some_state ("options",  "ShowTrackMeters", &Configuration::get_show_track_meters);
1125                 editor->toggle_meter_updating();
1126         } else if (PARAM_IS ("default-narrow_ms")) {
1127                 ActionManager::map_some_state ("options",  "DefaultNarrowMS", &Configuration::get_default_narrow_ms);
1128         }
1129                            
1130
1131 #undef PARAM_IS
1132 }