1 /*
2  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
4  * Copyright (C) 2006-2007 Nick Mainsbridge <mainsbridge@gmail.com>
5  * Copyright (C) 2006 Sampo Savolainen <v2@iki.fi>
6  * Copyright (C) 2007-2015 Tim Mayberry <mojofunk@gmail.com>
7  * Copyright (C) 2008-2012 David Robillard <d@drobilla.net>
8  * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
9  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
10  * Copyright (C) 2012-2019 Robin Gareus <robin@gareus.org>
11  * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with this program; if not, write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26  */
27 
28 #ifdef WAF_BUILD
29 #include "gtk2ardour-config.h"
30 #endif
31 
32 #include "pbd/convert.h"
33 #include "pbd/unwind.h"
34 
35 #include "ardour/lv2_plugin.h"
36 #include "ardour/rc_configuration.h"
37 #include "ardour/session.h"
38 #include "ardour/transport_master_manager.h"
39 
40 #include "gtkmm2ext/utils.h"
41 #include "waveview/wave_view.h"
42 
43 #include "ardour_message.h"
44 #include "audio_clock.h"
45 #include "ardour_ui.h"
46 #include "actions.h"
47 #include "gui_thread.h"
48 #include "public_editor.h"
49 #include "main_clock.h"
50 
51 #include "pbd/i18n.h"
52 
53 using namespace Gtk;
54 using namespace Gtkmm2ext;
55 using namespace ARDOUR;
56 using namespace PBD;
57 using namespace ArdourWidgets;
58 
59 void
toggle_external_sync()60 ARDOUR_UI::toggle_external_sync()
61 {
62 	if (_session) {
63 		if (_session->config.get_video_pullup() != 0.0f && (TransportMasterManager::instance().current()->type() == Engine)) {
64 			ArdourMessageDialog msg (_("It is not possible to use JACK as the sync source\n when the pull up/down setting is non-zero."));
65 			msg.run ();
66 			return;
67 		}
68 
69 		ActionManager::toggle_config_state_foo ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::set_external_sync), sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
70 
71 		/* activating a slave is a session-property.
72 		 * The slave type is a RC property.
73 		 * When the slave is active is must not be reconfigured.
74 		 * This is a UI limitation, imposed by audio-clock and
75 		 * status displays which combine RC-config & session-properties.
76 		 *
77 		 * Notify RCOptionEditor by emitting a signal if the active
78 		 * status changed:
79 		 */
80 		Config->ParameterChanged("sync-source");
81 	}
82 }
83 
84 void
toggle_time_master()85 ARDOUR_UI::toggle_time_master ()
86 {
87 	ActionManager::toggle_config_state_foo ("Transport", "ToggleTimeMaster", sigc::mem_fun (_session->config, &SessionConfiguration::set_jack_time_master), sigc::mem_fun (_session->config, &SessionConfiguration::get_jack_time_master));
88 }
89 
90 void
toggle_send_mtc()91 ARDOUR_UI::toggle_send_mtc ()
92 {
93 	ActionManager::toggle_config_state ("Options", "SendMTC", &RCConfiguration::set_send_mtc, &RCConfiguration::get_send_mtc);
94 }
95 
96 void
toggle_send_mmc()97 ARDOUR_UI::toggle_send_mmc ()
98 {
99 	ActionManager::toggle_config_state ("Options", "SendMMC", &RCConfiguration::set_send_mmc, &RCConfiguration::get_send_mmc);
100 }
101 
102 void
toggle_send_midi_clock()103 ARDOUR_UI::toggle_send_midi_clock ()
104 {
105 	ActionManager::toggle_config_state ("Options", "SendMidiClock", &RCConfiguration::set_send_midi_clock, &RCConfiguration::get_send_midi_clock);
106 }
107 
108 void
toggle_use_mmc()109 ARDOUR_UI::toggle_use_mmc ()
110 {
111 	ActionManager::toggle_config_state ("Options", "UseMMC", &RCConfiguration::set_mmc_control, &RCConfiguration::get_mmc_control);
112 }
113 
114 void
toggle_auto_input()115 ARDOUR_UI::toggle_auto_input ()
116 {
117 	ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_input), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
118 }
119 
120 void
toggle_auto_play()121 ARDOUR_UI::toggle_auto_play ()
122 {
123 	ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_play), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
124 }
125 
126 void
toggle_auto_return()127 ARDOUR_UI::toggle_auto_return ()
128 {
129 	ActionManager::toggle_config_state_foo ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::set_auto_return), sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
130 }
131 
132 void
toggle_click()133 ARDOUR_UI::toggle_click ()
134 {
135 	ActionManager::toggle_config_state ("Transport", "ToggleClick", &RCConfiguration::set_clicking, &RCConfiguration::get_clicking);
136 }
137 
138 void
toggle_session_monitoring_in()139 ARDOUR_UI::toggle_session_monitoring_in ()
140 {
141 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Transport"), X_("SessionMonitorIn"));
142 	MonitorChoice mc = _session->config.get_session_monitoring ();
143 
144 	if (tact->get_active() == (0 != (mc & MonitorInput))) {
145 		return;
146 	}
147 
148 	if (tact->get_active()) {
149 		mc = MonitorChoice (mc | MonitorInput);
150 	} else {
151 		mc = MonitorChoice (mc & ~MonitorInput);
152 	}
153 	_session->config.set_session_monitoring (mc);
154 }
155 
156 void
toggle_session_monitoring_disk()157 ARDOUR_UI::toggle_session_monitoring_disk ()
158 {
159 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Transport"), X_("SessionMonitorDisk"));
160 	MonitorChoice mc = _session->config.get_session_monitoring ();
161 	if (tact->get_active() == (0 != (mc & MonitorDisk))) {
162 		return;
163 	}
164 
165 	if (tact->get_active()) {
166 		mc = MonitorChoice (mc | MonitorDisk);
167 	} else {
168 		mc = MonitorChoice (mc & ~MonitorDisk);
169 	}
170 	_session->config.set_session_monitoring (mc);
171 }
172 
173 void
unset_dual_punch()174 ARDOUR_UI::unset_dual_punch ()
175 {
176 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Transport", "TogglePunch");
177 	if (tact) {
178 		ignore_dual_punch = true;
179 		tact->set_active (false);
180 		ignore_dual_punch = false;
181 	}
182 }
183 
184 void
toggle_punch()185 ARDOUR_UI::toggle_punch ()
186 {
187 	if (ignore_dual_punch) {
188 		return;
189 	}
190 
191 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Transport", "TogglePunch");
192 
193 	/* drive the other two actions from this one */
194 	Glib::RefPtr<ToggleAction> in_action = ActionManager::get_toggle_action ("Transport", "TogglePunchIn");
195 	Glib::RefPtr<ToggleAction> out_action = ActionManager::get_toggle_action ("Transport", "TogglePunchOut");
196 
197 	in_action->set_active (tact->get_active());
198 	out_action->set_active (tact->get_active());
199 }
200 
201 void
toggle_punch_in()202 ARDOUR_UI::toggle_punch_in ()
203 {
204 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Transport"), X_("TogglePunchIn"));
205 
206 	if (tact->get_active() != _session->config.get_punch_in()) {
207 		_session->config.set_punch_in (tact->get_active ());
208 	}
209 
210 	if (tact->get_active()) {
211 		/* if punch-in is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
212 		   to avoid confusing the user */
213 		show_loop_punch_ruler_and_disallow_hide ();
214 	}
215 
216 	reenable_hide_loop_punch_ruler_if_appropriate ();
217 }
218 
219 void
toggle_punch_out()220 ARDOUR_UI::toggle_punch_out ()
221 {
222 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Transport"), X_("TogglePunchOut"));
223 
224 	if (tact->get_active() != _session->config.get_punch_out()) {
225 		_session->config.set_punch_out (tact->get_active ());
226 	}
227 
228 	if (tact->get_active()) {
229 		/* if punch-out is turned on, make sure the loop/punch ruler is visible, and stop it being hidden,
230 		   to avoid confusing the user */
231 		show_loop_punch_ruler_and_disallow_hide ();
232 	}
233 
234 	reenable_hide_loop_punch_ruler_if_appropriate ();
235 }
236 
237 void
show_loop_punch_ruler_and_disallow_hide()238 ARDOUR_UI::show_loop_punch_ruler_and_disallow_hide ()
239 {
240 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Rulers"), "toggle-loop-punch-ruler");
241 
242 	tact->set_sensitive (false);
243 
244 	if (!tact->get_active()) {
245 		tact->set_active ();
246 	}
247 }
248 
249 /* This is a bit of a silly name for a method */
250 void
reenable_hide_loop_punch_ruler_if_appropriate()251 ARDOUR_UI::reenable_hide_loop_punch_ruler_if_appropriate ()
252 {
253 	if (!_session->config.get_punch_in() && !_session->config.get_punch_out()) {
254 		/* if punch in/out are now both off, reallow hiding of the loop/punch ruler */
255 		Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), "toggle-loop-punch-ruler");
256 		if (act) {
257 			act->set_sensitive (true);
258 		}
259 	}
260 }
261 
262 void
toggle_video_sync()263 ARDOUR_UI::toggle_video_sync()
264 {
265 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Transport", "ToggleVideoSync");
266 	_session->config.set_use_video_sync (tact->get_active());
267 }
268 
269 void
toggle_editing_space()270 ARDOUR_UI::toggle_editing_space()
271 {
272 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Common", "ToggleMaximalEditor");
273 	if (tact->get_active()) {
274 		maximise_editing_space ();
275 	} else {
276 		restore_editing_space ();
277 	}
278 }
279 
280 void
toggle_latency_switch()281 ARDOUR_UI::toggle_latency_switch ()
282 {
283 	Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action ("Main", "ToggleLatencyCompensation");
284 	ARDOUR::Latent::force_zero_latency (tact->get_active());
285 }
286 
287 void
setup_session_options()288 ARDOUR_UI::setup_session_options ()
289 {
290 	_session->config.ParameterChanged.connect (_session_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
291 	boost::function<void (std::string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
292 	_session->config.map_parameters (pc);
293 }
294 
295 void
parameter_changed(std::string p)296 ARDOUR_UI::parameter_changed (std::string p)
297 {
298 	if (p == "external-sync") {
299 
300 		/* session parameter */
301 
302 		ActionManager::map_some_state ("Transport", "ToggleExternalSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_external_sync));
303 
304 		if (!_session->config.get_external_sync()) {
305 			sync_button.set_text (S_("SyncSource|Int."));
306 			ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
307 			ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
308 			ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (true);
309 		} else {
310 			/* XXX we need to make sure that auto-play is off as well as insensitive */
311 			ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
312 			ActionManager::get_action ("Transport", "ToggleFollowEdits")->set_sensitive (false);
313 			if (!_session->synced_to_engine()) {
314 				/* JACK transport allows auto-return */
315 				ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
316 			}
317 		}
318 
319 	} else if (p == "sync-source") {
320 
321 		/* app parameter (RC config) */
322 
323 		if (_session) {
324 			if (!_session->config.get_external_sync()) {
325 				sync_button.set_text (S_("SyncSource|Int."));
326 			} else {
327 				sync_button.set_text (TransportMasterManager::instance().current()->display_name());
328 			}
329 		} else {
330 			/* changing sync source without a session is unlikely/impossible , except during startup */
331 			sync_button.set_text (TransportMasterManager::instance().current()->display_name());
332 		}
333 
334 	} else if (p == "follow-edits") {
335 
336 		ActionManager::map_some_state ("Transport", "ToggleFollowEdits", &UIConfiguration::get_follow_edits);
337 
338 	} else if (p == "send-mtc") {
339 
340 		ActionManager::map_some_state ("Options", "SendMTC", &RCConfiguration::get_send_mtc);
341 
342 	} else if (p == "send-mmc") {
343 
344 		ActionManager::map_some_state ("Options", "SendMMC", &RCConfiguration::get_send_mmc);
345 
346 	} else if (p == "mmc-control") {
347 		ActionManager::map_some_state ("Options", "UseMMC", &RCConfiguration::get_mmc_control);
348 	} else if (p == "auto-play") {
349 		ActionManager::map_some_state ("Transport", "ToggleAutoPlay", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_play));
350 	} else if (p == "auto-return") {
351 		ActionManager::map_some_state ("Transport", "ToggleAutoReturn", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_return));
352 	} else if (p == "auto-input") {
353 		ActionManager::map_some_state ("Transport", "ToggleAutoInput", sigc::mem_fun (_session->config, &SessionConfiguration::get_auto_input));
354 	} else if (p == "session-monitoring") {
355 		Glib::RefPtr<ToggleAction> tiact = ActionManager::get_toggle_action (X_("Transport"), X_("SessionMonitorIn"));
356 		Glib::RefPtr<ToggleAction> tdact = ActionManager::get_toggle_action (X_("Transport"), X_("SessionMonitorDisk"));
357 		MonitorChoice mc = _session->config.get_session_monitoring ();
358 		tiact->set_active (0 != (mc & MonitorInput));
359 		tdact->set_active (0 != (mc & MonitorDisk));
360 	} else if (p == "punch-out") {
361 		ActionManager::map_some_state ("Transport", "TogglePunchOut", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_out));
362 		if (!_session->config.get_punch_out()) {
363 			unset_dual_punch ();
364 		}
365 	} else if (p == "punch-in") {
366 		ActionManager::map_some_state ("Transport", "TogglePunchIn", sigc::mem_fun (_session->config, &SessionConfiguration::get_punch_in));
367 		if (!_session->config.get_punch_in()) {
368 			unset_dual_punch ();
369 		}
370 	} else if (p == "clicking") {
371 		ActionManager::map_some_state ("Transport", "ToggleClick", &RCConfiguration::get_clicking);
372 	} else if (p == "use-video-sync") {
373 		ActionManager::map_some_state ("Transport",  "ToggleVideoSync", sigc::mem_fun (_session->config, &SessionConfiguration::get_use_video_sync));
374 	} else if (p == "sync-source") {
375 
376 		synchronize_sync_source_and_video_pullup ();
377 		set_fps_timeout_connection ();
378 
379 	} else if (p == "show-track-meters") {
380 		if (editor) editor->toggle_meter_updating();
381 	} else if (p == "primary-clock-delta-mode") {
382 		if (UIConfiguration::instance().get_primary_clock_delta_mode() != NoDelta) {
383 			primary_clock->set_is_duration (true);
384 			primary_clock->set_editable (false);
385 			primary_clock->set_widget_name ("transport delta");
386 		} else {
387 			primary_clock->set_is_duration (false);
388 			primary_clock->set_editable (true);
389 			primary_clock->set_widget_name ("transport");
390 		}
391 	} else if (p == "secondary-clock-delta-mode") {
392 		if (UIConfiguration::instance().get_secondary_clock_delta_mode() != NoDelta) {
393 			secondary_clock->set_is_duration (true);
394 			secondary_clock->set_editable (false);
395 			secondary_clock->set_widget_name ("secondary delta");
396 		} else {
397 			secondary_clock->set_is_duration (false);
398 			secondary_clock->set_editable (true);
399 			secondary_clock->set_widget_name ("secondary");
400 		}
401 	} else if (p == "super-rapid-clock-update") {
402 		if (_session) {
403 			stop_clocking ();
404 			start_clocking ();
405 		}
406 	} else if (p == "use-tooltips") {
407 		/* this doesn't really belong here but it has to go somewhere */
408 		if (UIConfiguration::instance().get_use_tooltips()) {
409 			Gtkmm2ext::enable_tooltips ();
410 		} else {
411 			Gtkmm2ext::disable_tooltips ();
412 		}
413 	} else if (p == "waveform-gradient-depth") {
414 		ArdourWaveView::WaveView::set_global_gradient_depth (UIConfiguration::instance().get_waveform_gradient_depth());
415 	} else if (p == "show-mini-timeline") {
416 		repack_transport_hbox ();
417 	} else if (p == "show-dsp-load-info") {
418 		repack_transport_hbox ();
419 	} else if (p == "show-disk-space-info") {
420 		repack_transport_hbox ();
421 	} else if (p == "show-toolbar-recpunch") {
422 		repack_transport_hbox ();
423 	} else if (p == "show-toolbar-monitoring") {
424 		repack_transport_hbox ();
425 	} else if (p == "show-toolbar-selclock") {
426 		repack_transport_hbox ();
427 	} else if (p == "show-toolbar-latency") {
428 		repack_transport_hbox ();
429 	} else if (p == "show-toolbar-monitor-info") {
430 		repack_transport_hbox ();
431 	} else if (p == "show-editor-meter") {
432 		repack_transport_hbox ();
433 	} else if (p == "show-secondary-clock") {
434 		update_clock_visibility ();
435 	} else if (p == "waveform-scale") {
436 		ArdourWaveView::WaveView::set_global_logscaled (UIConfiguration::instance().get_waveform_scale() == Logarithmic);
437 	} else if (p == "widget-prelight") {
438 		CairoWidget::set_widget_prelight (UIConfiguration::instance().get_widget_prelight());
439 	} else if (p == "waveform-shape") {
440 		ArdourWaveView::WaveView::set_global_shape (UIConfiguration::instance().get_waveform_shape() == Rectified
441 				? ArdourWaveView::WaveView::Rectified : ArdourWaveView::WaveView::Normal);
442 	} else if (p == "show-waveform-clipping") {
443 		ArdourWaveView::WaveView::set_global_show_waveform_clipping (UIConfiguration::instance().get_show_waveform_clipping());
444 	} else if (p == "waveform-cache-size") {
445 		/* GUI option has units of megabytes; image cache uses units of bytes */
446 		ArdourWaveView::WaveView::set_image_cache_size (UIConfiguration::instance().get_waveform_cache_size() * 1048576);
447 	} else if (p == "use-wm-visibility") {
448 		VisibilityTracker::set_use_window_manager_visibility (UIConfiguration::instance().get_use_wm_visibility());
449 	} else if (p == "action-table-columns") {
450 		const uint32_t cols = UIConfiguration::instance().get_action_table_columns ();
451 		for (int i = 0; i < MAX_LUA_ACTION_BUTTONS; ++i) {
452 			const int col = i / 2;
453 			if (cols & (1<<col)) {
454 				action_script_call_btn[i].show();
455 			} else {
456 				action_script_call_btn[i].hide();
457 			}
458 		}
459 		if (cols == 0) {
460 			scripts_spacer.hide ();
461 		} else {
462 			scripts_spacer.show ();
463 		}
464 	} else if (p == "layered-record-mode") {
465 		layered_button.set_active (_session->config.get_layered_record_mode ());
466 	} else if (p == "flat-buttons") {
467 		bool flat = UIConfiguration::instance().get_flat_buttons();
468 		if (ArdourButton::flat_buttons () != flat) {
469 			ArdourButton::set_flat_buttons (flat);
470 			/* force a redraw */
471 			gtk_rc_reset_styles (gtk_settings_get_default());
472 			LV2Plugin::set_global_ui_style_flat (flat);
473 		}
474 	} else if (p == "boxy-buttons") {
475 		bool boxy = UIConfiguration::instance().get_boxy_buttons();
476 		if (ArdourButton::boxy_buttons () != boxy) {
477 			ArdourButton::set_boxy_buttons (boxy);
478 			/* force a redraw */
479 			gtk_rc_reset_styles (gtk_settings_get_default());
480 			LV2Plugin::set_global_ui_style_boxy (boxy);
481 		}
482 	} else if ( (p == "snap-to-region-sync") || (p == "snap-to-region-start") || (p == "snap-to-region-end") ) {
483 		if (editor) editor->mark_region_boundary_cache_dirty();
484 	} else if (p == "screen-saver-mode") {
485 		switch (UIConfiguration::instance().get_screen_saver_mode ()) {
486 			using namespace ARDOUR_UI_UTILS;
487 			case InhibitWhileRecording:
488 				inhibit_screensaver (_session && _session->actively_recording ());
489 				break;
490 			case InhibitAlways:
491 				inhibit_screensaver (true);
492 				break;
493 			case InhibitNever:
494 				inhibit_screensaver (false);
495 				break;
496 		}
497 	}
498 }
499 
500 void
session_parameter_changed(std::string p)501 ARDOUR_UI::session_parameter_changed (std::string p)
502 {
503 	if (p == "native-file-data-format" || p == "native-file-header-format") {
504 		update_format ();
505 	} else if (p == "timecode-format") {
506 		set_fps_timeout_connection ();
507 	} else if (p == "video-pullup" || p == "timecode-format") {
508 		set_fps_timeout_connection ();
509 
510 		synchronize_sync_source_and_video_pullup ();
511 		reset_main_clocks ();
512 		editor->queue_visual_videotimeline_update();
513 	} else if (p == "track-name-number") {
514 		/* DisplaySuspender triggers _route->redisplay() when going out of scope
515 		 * which eventually calls reset_controls_layout_width() and re-sets the
516 		 * track-header width.
517 		 * see also RouteTimeAxisView::update_track_number_visibility()
518 		 */
519 		DisplaySuspender ds;
520 	}
521 }
522 
523 void
reset_main_clocks()524 ARDOUR_UI::reset_main_clocks ()
525 {
526 	ENSURE_GUI_THREAD (*this, &ARDOUR_UI::reset_main_clocks)
527 
528 	if (_session) {
529 		primary_clock->set (_session->audible_sample(), true);
530 		secondary_clock->set (_session->audible_sample(), true);
531 	} else {
532 		primary_clock->set (0, true);
533 		secondary_clock->set (0, true);
534 	}
535 }
536 
537 void
synchronize_sync_source_and_video_pullup()538 ARDOUR_UI::synchronize_sync_source_and_video_pullup ()
539 {
540 	Glib::RefPtr<Action> act = ActionManager::get_action (X_("Transport"), X_("ToggleExternalSync"));
541 
542 	if (!act) {
543 		return;
544 	}
545 
546 	if (!_session) {
547 		goto just_label;
548 	}
549 
550 	if (_session->config.get_video_pullup() == 0.0f) {
551 		/* with no video pull up/down, any sync source is OK */
552 		act->set_sensitive (true);
553 	} else {
554 		/* can't sync to JACK if video pullup != 0.0 */
555 		if (TransportMasterManager::instance().current()->type() == Engine) {
556 			act->set_sensitive (false);
557 		} else {
558 			act->set_sensitive (true);
559 		}
560 	}
561 
562 	/* XXX should really be able to set the video pull up
563 	   action to insensitive/sensitive, but there is no action.
564 	   FIXME
565 	*/
566 
567   just_label:
568 	if (act->get_sensitive ()) {
569 		set_tip (sync_button, _("Enable/Disable external positional sync"));
570 	} else {
571 		set_tip (sync_button, _("Sync to JACK is not possible: video pull up/down is set"));
572 	}
573 
574 }
575