merged with 1697 revision of trunk (which is post-rc1 but pre-rc2
[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::set_native_file_header_format (HeaderFormat hf)
80 {
81         const char *action = 0;
82
83         switch (hf) {
84         case BWF:
85                 action = X_("FileHeaderFormatBWF");
86                 break;
87         case WAVE:
88                 action = X_("FileHeaderFormatWAVE");
89                 break;
90         case WAVE64:
91                 action = X_("FileHeaderFormatWAVE64");
92                 break;
93         case iXML:
94                 action = X_("FileHeaderFormatiXML");
95                 break;
96         case RF64:
97                 action = X_("FileHeaderFormatRF64");
98                 break;
99         case CAF:
100                 action = X_("FileHeaderFormatCAF");
101                 break;
102         case AIFF:
103                 action = X_("FileHeaderFormatAIFF");
104                 break;
105         default:
106                 fatal << string_compose (_("programming error: %1"), "illegal file header format in ::set_native_file_header_format") << endmsg;
107                 /*NOTREACHED*/  
108         }
109
110         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
111
112         if (act) {
113                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
114                 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
115                         Config->set_native_file_header_format (hf);
116                 }
117         }
118 }
119
120 void
121 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
122 {
123         const char* action = 0;
124
125         switch (sf) {
126         case FormatFloat:
127                 action = X_("FileDataFormatFloat");
128                 break;
129         case FormatInt24:
130                 action = X_("FileDataFormat24bit");
131                 break;
132         default:
133                 fatal << string_compose (_("programming error: %1"), "illegal file data format in ::set_native_file_data_format") << endmsg;
134                 /*NOTREACHED*/
135         }
136
137         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
138
139         if (act) {
140                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
141                 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
142                         Config->set_native_file_data_format (sf);
143                 }
144         }
145 }
146
147 void
148 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
149 {
150         const char* action;
151         
152         switch (option) {
153         case AutoConnectPhysical:
154                 action = X_("InputAutoConnectPhysical");
155                 break;
156         default:
157                 action = X_("InputAutoConnectManual");
158         }
159
160         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
161
162         if (act) {
163                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
164
165                 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
166                         Config->set_input_auto_connect (option);
167                 }
168         }
169 }
170
171 void
172 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
173 {
174         const char* action;
175         
176         switch (option) {
177         case AutoConnectPhysical:
178                 action = X_("OutputAutoConnectPhysical");
179                 break;
180         case AutoConnectMaster:
181                 action = X_("OutputAutoConnectMaster");
182                 break;
183         default:
184                 action = X_("OutputAutoConnectManual");
185         }
186
187         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
188
189         if (act) {
190                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
191
192                 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
193                         Config->set_output_auto_connect (option);
194                 }
195         }
196 }
197
198 void
199 ARDOUR_UI::set_solo_model (SoloModel model)
200 {
201         const char* action = 0;
202
203         switch (model) {
204         case SoloBus:
205                 action = X_("SoloViaBus");
206                 break;
207                 
208         case InverseMute:
209                 action = X_("SoloInPlace");
210                 break;
211         default:
212                 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
213                 /*NOTREACHED*/
214         }
215
216         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
217
218         if (act) {
219                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
220
221                 if (ract && ract->get_active() && Config->get_solo_model() != model) {
222                         Config->set_solo_model (model);
223                 }
224         }
225
226 }
227
228 void
229 ARDOUR_UI::set_remote_model (RemoteModel model)
230 {
231         const char* action = 0;
232
233         switch (model) {
234         case UserOrdered:
235                 action = X_("RemoteUserDefined");
236                 break;
237         case MixerOrdered:
238                 action = X_("RemoteMixerDefined");
239                 break;
240         case EditorOrdered:
241                 action = X_("RemoteEditorDefined");
242                 break;
243
244         default:
245                 fatal << string_compose (_("programming error: unknown remote model in ARDOUR_UI::set_remote_model: %1"), model) << endmsg;
246                 /*NOTREACHED*/
247         }
248
249         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
250
251         if (act) {
252                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
253
254                 if (ract && ract->get_active() && Config->get_remote_model() != model) {
255                         Config->set_remote_model (model);
256                 }
257         }
258
259 }
260
261 void
262 ARDOUR_UI::set_monitor_model (MonitorModel model)
263 {
264         const char* action = 0;
265
266         switch (model) {
267         case HardwareMonitoring:
268                 action = X_("UseHardwareMonitoring");
269                 break;
270                 
271         case SoftwareMonitoring:
272                 action = X_("UseSoftwareMonitoring");
273                 break;
274         case ExternalMonitoring:
275                 action = X_("UseExternalMonitoring");
276                 break;
277
278         default:
279                 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
280                 /*NOTREACHED*/
281         }
282
283         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
284
285         if (act) {
286                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
287
288                 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
289                         Config->set_monitoring_model (model);
290                 }
291         }
292
293 }
294
295 void
296 ARDOUR_UI::toggle_auto_input ()
297 {
298         ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
299 }
300
301 void
302 ARDOUR_UI::toggle_auto_play ()
303 {
304         ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
305 }
306
307 void
308 ARDOUR_UI::toggle_auto_return ()
309 {
310         ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
311 }
312
313 void
314 ARDOUR_UI::toggle_click ()
315 {
316         ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
317 }
318
319 void
320 ARDOUR_UI::toggle_session_auto_loop ()
321 {
322         if (session) {
323                 if (session->get_play_loop()) {
324                         if (session->transport_rolling()) {
325                                 transport_roll();
326                         } else {
327                                 session->request_play_loop (false);
328                         }
329                 } else {
330                         session->request_play_loop (true);
331                 }
332         }
333 }
334
335 void
336 ARDOUR_UI::toggle_punch_in ()
337 {
338         ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
339 }
340
341 void
342 ARDOUR_UI::toggle_punch_out ()
343 {
344         ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
345 }
346
347 void
348 ARDOUR_UI::toggle_video_sync()
349 {
350         Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
351         if (act) {
352                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
353                 Config->set_use_video_sync (tact->get_active());
354         }
355 }
356
357 void
358 ARDOUR_UI::toggle_editing_space()
359 {
360         Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
361         if (act) {
362                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
363                 if (tact->get_active()) {
364                         maximise_editing_space ();
365                 } else {
366                         restore_editing_space ();
367                 }
368         }
369 }
370
371 void
372 ARDOUR_UI::toggle_StopPluginsWithTransport()
373 {
374         ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
375 }
376
377 void
378 ARDOUR_UI::toggle_LatchedRecordEnable()
379 {
380         ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
381 }
382
383 void
384 ARDOUR_UI::toggle_RegionEquivalentsOverlap()
385 {
386         ActionManager::toggle_config_state ("options", "RegionEquivalentsOverlap", &Configuration::set_use_overlap_equivalency, &Configuration::get_use_overlap_equivalency);
387 }
388
389 void
390 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
391 {
392         ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
393 }
394
395 void
396 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
397 {
398         ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
399 }
400
401 void
402 ARDOUR_UI::toggle_StopRecordingOnXrun()
403 {
404         ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
405 }
406
407 void
408 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
409 {
410         ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
411 }
412
413 void
414 ARDOUR_UI::toggle_GainReduceFastTransport()
415 {
416         ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
417 }
418
419 void
420 ARDOUR_UI::toggle_LatchedSolo()
421 {
422         ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
423 }
424
425 void
426 ARDOUR_UI::toggle_ShowSoloMutes()
427 {
428         ActionManager::toggle_config_state ("options", "ShowSoloMutes", &Configuration::set_show_solo_mutes, &Configuration::get_show_solo_mutes);
429 }
430
431 void
432 ARDOUR_UI::mtc_port_changed ()
433 {
434         bool have_mtc;
435
436         if (session) {
437                 if (session->mtc_port()) {
438                         have_mtc = true;
439                 } else {
440                         have_mtc = false;
441                 }
442         } else {
443                 have_mtc = false;
444         }
445
446         positional_sync_strings.clear ();
447         positional_sync_strings.push_back (slave_source_to_string (None));
448         if (have_mtc) {
449                 positional_sync_strings.push_back (slave_source_to_string (MTC));
450         }
451         positional_sync_strings.push_back (slave_source_to_string (JACK));
452         
453         set_popdown_strings (sync_option_combo, positional_sync_strings);
454 }
455
456 void
457 ARDOUR_UI::setup_session_options ()
458 {
459         mtc_port_changed ();
460
461         Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
462 }
463
464
465 void
466 ARDOUR_UI::map_solo_model ()
467 {
468         const char* on;
469
470         if (Config->get_solo_model() == InverseMute) {
471                 on = X_("SoloInPlace");
472         } else {
473                 on = X_("SoloViaBus");
474         }
475
476         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
477         if (act) {
478                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
479
480                 if (tact && !tact->get_active()) {
481                         tact->set_active (true);
482                 }
483         }
484 }
485
486 void
487 ARDOUR_UI::map_monitor_model ()
488 {
489         const char* on = 0;
490
491         switch (Config->get_monitoring_model()) {
492         case HardwareMonitoring:
493                 on = X_("UseHardwareMonitoring");
494                 break;
495         case SoftwareMonitoring:
496                 on = X_("UseSoftwareMonitoring");
497                 break;
498         case ExternalMonitoring:
499                 on = X_("UseExternalMonitoring");
500                 break;
501         }
502
503         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
504         if (act) {
505                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
506
507                 if (tact && !tact->get_active()) {
508                         tact->set_active (true);
509                 }
510         }
511 }
512
513 void
514 ARDOUR_UI::map_remote_model ()
515 {
516         const char* on = 0;
517
518         switch (Config->get_remote_model()) {
519         case UserOrdered:
520                 on = X_("RemoteUserDefined");
521                 break;
522         case MixerOrdered:
523                 on = X_("RemoteMixerDefined");
524                 break;
525         case EditorOrdered:
526                 on = X_("RemoteEditorDefined");
527                 break;
528         }
529
530         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
531         if (act) {
532                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
533
534                 if (tact && !tact->get_active()) {
535                         tact->set_active (true);
536                 }
537         }
538 }
539
540 void
541 ARDOUR_UI::map_file_header_format ()
542 {
543         const char* action = 0;
544
545         switch (Config->get_native_file_header_format()) {
546         case BWF:
547                 action = X_("FileHeaderFormatBWF");
548                 break;
549
550         case WAVE:
551                 action = X_("FileHeaderFormatWAVE");
552                 break;
553
554         case WAVE64:
555                 action = X_("FileHeaderFormatWAVE64");
556                 break;
557
558         case iXML:
559                 action = X_("FileHeaderFormatiXML");
560                 break;
561
562         case RF64:
563                 action = X_("FileHeaderFormatRF64");
564                 break;
565
566         case CAF:
567                 action = X_("FileHeaderFormatCAF");
568                 break;
569
570         default:
571                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
572                                          Config->get_native_file_header_format()) << endmsg;
573                 /*NOTREACHED*/
574         }
575
576
577         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
578
579         if (act) {
580                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
581
582                 if (tact && !tact->get_active()) {
583                         tact->set_active (true);
584                 }
585         }
586 }
587
588 void
589 ARDOUR_UI::map_file_data_format ()
590 {
591         const char* action = 0;
592
593         switch (Config->get_native_file_data_format()) {
594         case FormatFloat:
595                 action = X_("FileDataFormatFloat");
596                 break;
597
598         case FormatInt24:
599                 action = X_("FileDataFormat24bit");
600                 break;
601
602         default:
603                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
604                                          Config->get_native_file_data_format()) << endmsg;
605                 /*NOTREACHED*/
606         }
607
608
609         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
610
611         if (act) {
612                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
613
614                 if (tact && !tact->get_active()) {
615                         tact->set_active (true);
616                 }
617         }
618 }
619
620 void
621 ARDOUR_UI::map_input_auto_connect ()
622 {
623         const char* on;
624
625         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
626                 on = "InputAutoConnectManual";
627         } else {
628                 on = "InputAutoConnectPhysical";
629         }
630
631         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
632         if (act) {
633                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
634
635                 if (tact && !tact->get_active()) {
636                         tact->set_active (true);
637                 }
638         }
639 }
640
641 void
642 ARDOUR_UI::map_output_auto_connect ()
643 {
644         const char* on;
645
646         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
647                 on = "OutputAutoConnectManual";
648         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
649                 on = "OutputAutoConnectPhysical";
650         } else {
651                 on = "OutputAutoConnectMaster";
652         }
653
654         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
655         if (act) {
656                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
657                 
658                 if (tact && !tact->get_active()) {
659                         tact->set_active (true);
660                 }
661         }
662 }
663
664 void
665 ARDOUR_UI::map_meter_falloff ()
666 {
667         const char* action = X_("MeterFalloffMedium");
668
669         float val = Config->get_meter_falloff ();
670         MeterFalloff code = meter_falloff_from_float(val);
671
672         switch (code) {
673         case MeterFalloffOff:
674                 action = X_("MeterFalloffOff");
675                 break;
676         case MeterFalloffSlowest:
677                 action = X_("MeterFalloffSlowest");
678                 break;
679         case MeterFalloffSlow:
680                 action = X_("MeterFalloffSlow");
681                 break;
682         case MeterFalloffMedium:
683                 action = X_("MeterFalloffMedium");
684                 break;
685         case MeterFalloffFast:
686                 action = X_("MeterFalloffFast");
687                 break;
688         case MeterFalloffFaster:
689                 action = X_("MeterFalloffFaster");
690                 break;
691         case MeterFalloffFastest:
692                 action = X_("MeterFalloffFastest");
693                 break;
694         }
695
696         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
697
698         if (act) {
699                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
700                 if (ract && !ract->get_active()) {
701                         ract->set_active (true);
702                 }
703         }
704 }
705
706 void
707 ARDOUR_UI::map_meter_hold ()
708 {
709         const char* action = X_("MeterHoldMedium");
710
711         /* XXX hack alert. Fix this. Please */
712
713         float val = Config->get_meter_hold ();
714         MeterHold code = (MeterHold) (int) (floor (val));
715
716         switch (code) {
717         case MeterHoldOff:
718                 action = X_("MeterHoldOff");
719                 break;
720         case MeterHoldShort:
721                 action = X_("MeterHoldShort");
722                 break;
723         case MeterHoldMedium:
724                 action = X_("MeterHoldMedium");
725                 break;
726         case MeterHoldLong:
727                 action = X_("MeterHoldLong");
728                 break;
729         }
730
731         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
732
733         if (act) {
734                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
735                 if (ract && !ract->get_active()) {
736                         ract->set_active (true);
737                 }
738         }
739 }
740
741 void 
742 ARDOUR_UI::set_meter_hold (MeterHold val)
743 {
744         const char* action = 0;
745         float fval;
746
747         fval = meter_hold_to_float (val);
748
749         switch (val) {
750         case MeterHoldOff:
751                 action = X_("MeterHoldOff");
752                 break;
753         case MeterHoldShort:
754                 action = X_("MeterHoldShort");
755                 break;
756         case MeterHoldMedium:
757                 action = X_("MeterHoldMedium");
758                 break;
759         case MeterHoldLong:
760                 action = X_("MeterHoldLong");
761                 break;
762         }
763
764         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
765         
766         if (act) {
767                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
768                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
769                         Config->set_meter_hold (fval);
770                 }
771         }
772 }
773
774 void
775 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
776 {
777         const char* action = 0;
778         float fval;
779
780         fval = meter_falloff_to_float (val);
781
782         switch (val) {
783         case MeterFalloffOff:
784                 action = X_("MeterFalloffOff");
785                 break;
786         case MeterFalloffSlowest:
787                 action = X_("MeterFalloffSlowest");
788                 break;
789         case MeterFalloffSlow:
790                 action = X_("MeterFalloffSlow");
791                 break;
792         case MeterFalloffMedium:
793                 action = X_("MeterFalloffMedium");
794                 break;
795         case MeterFalloffFast:
796                 action = X_("MeterFalloffFast");
797                 break;
798         case MeterFalloffFaster:
799                 action = X_("MeterFalloffFaster");
800                 break;
801         case MeterFalloffFastest:
802                 action = X_("MeterFalloffFastest");
803                 break;
804         }
805
806         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
807
808         if (act) {
809                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
810                 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
811                         Config->set_meter_falloff (fval);
812                 }
813         }
814 }
815
816 void
817 ARDOUR_UI::parameter_changed (const char* parameter_name)
818 {
819         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
820
821 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
822         
823         if (PARAM_IS ("slave-source")) {
824
825                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
826                 
827                 switch (Config->get_slave_source()) {
828                 case None:
829                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
830                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
831                         break;
832
833                 default:
834                         /* XXX need to make auto-play is off as well as insensitive */
835                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
836                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
837                         break;
838                 }
839
840         } else if (PARAM_IS ("send-mtc")) {
841
842                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
843
844         } else if (PARAM_IS ("send-mmc")) {
845
846                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
847
848         } else if (PARAM_IS ("use-osc")) {
849
850 #ifdef HAVE_LIBLO
851                 if (Config->get_use_osc()) {
852                         osc->start ();
853                 } else {
854                         osc->stop ();
855                 }
856 #endif
857
858                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
859                 
860         } else if (PARAM_IS ("mmc-control")) {
861                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
862         } else if (PARAM_IS ("midi-feedback")) {
863                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
864         } else if (PARAM_IS ("do-not-record-plugins")) {
865                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
866         } else if (PARAM_IS ("latched-record-enable")) {
867                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
868         } else if (PARAM_IS ("solo-latched")) {
869                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
870         } else if (PARAM_IS ("show-solo-mutes")) {
871                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
872         } else if (PARAM_IS ("solo-model")) {
873                 map_solo_model ();
874         } else if (PARAM_IS ("auto-play")) {
875                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
876         } else if (PARAM_IS ("auto-return")) {
877                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
878         } else if (PARAM_IS ("auto-input")) {
879                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
880         } else if (PARAM_IS ("punch-out")) {
881                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
882         } else if (PARAM_IS ("punch-in")) {
883                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
884         } else if (PARAM_IS ("clicking")) {
885                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
886         } else if (PARAM_IS ("jack-time-master")) {
887                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
888         } else if (PARAM_IS ("plugins-stop-with-transport")) {
889                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
890         } else if (PARAM_IS ("latched-record-enable")) {
891                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
892         } else if (PARAM_IS ("verify-remove-last-capture")) {
893                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
894         } else if (PARAM_IS ("stop-recording-on-xrun")) {
895                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
896         } else if (PARAM_IS ("stop-at-session-end")) {
897                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
898         } else if (PARAM_IS ("monitoring-model")) {
899                 map_monitor_model ();
900         } else if (PARAM_IS ("remote-model")) {
901                 map_remote_model ();
902         } else if (PARAM_IS ("use-video-sync")) {
903                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
904         } else if (PARAM_IS ("quieten-at-speed")) {
905                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
906         } else if (PARAM_IS ("shuttle-behaviour")) {
907
908                 switch (Config->get_shuttle_behaviour ()) {
909                 case Sprung:
910                         shuttle_style_button.set_active_text (_("sprung"));
911                         shuttle_fract = 0.0;
912                         shuttle_box.queue_draw ();
913                         if (session) {
914                                 if (session->transport_rolling()) {
915                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
916                                         session->request_transport_speed (1.0);
917                                 }
918                         }
919                         break;
920                 case Wheel:
921                         shuttle_style_button.set_active_text (_("wheel"));
922                         break;
923                 }
924
925         } else if (PARAM_IS ("shuttle-units")) {
926                 
927                 switch (Config->get_shuttle_units()) {
928                 case Percentage:
929                         shuttle_units_button.set_label("% ");
930                         break;
931                 case Semitones:
932                         shuttle_units_button.set_label(_("ST"));
933                         break;
934                 }
935         } else if (PARAM_IS ("input-auto-connect")) {
936                 map_input_auto_connect ();
937         } else if (PARAM_IS ("output-auto-connect")) {
938                 map_output_auto_connect ();
939         } else if (PARAM_IS ("native-file-header-format")) {
940                 map_file_header_format ();
941         } else if (PARAM_IS ("native-file-data-format")) {
942                 map_file_data_format ();
943         } else if (PARAM_IS ("meter-hold")) {
944                 map_meter_hold ();
945         } else if (PARAM_IS ("meter-falloff")) {
946                 map_meter_falloff ();
947         } else if (PARAM_IS ("verify-remove-last-capture")) {
948                 ActionManager::map_some_state ("options", "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
949         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
950                 if (session) {
951                         primary_clock.set (session->audible_frame(), true);
952                         secondary_clock.set (session->audible_frame(), true);
953                 } else {
954                         primary_clock.set (0, true);
955                         secondary_clock.set (0, true);
956                 }
957         } else if (PARAM_IS ("use-overlap-equivalency")) {
958                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
959         }
960                            
961
962 #undef PARAM_IS
963 }