1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2005-2016 Tim Mayberry <mojofunk@gmail.com>
4  * Copyright (C) 2005-2019 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2006-2007 Doug McLain <doug@nostar.net>
6  * Copyright (C) 2006-2012 David Robillard <d@drobilla.net>
7  * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
8  * Copyright (C) 2008 Hans Baier <hansfbaier@googlemail.com>
9  * Copyright (C) 2013-2020 Robin Gareus <robin@gareus.org>
10  * Copyright (C) 2014-2019 Ben Loftis <ben@harrisonconsoles.com>
11  * Copyright (C) 2015 André Nusser <andre.nusser@googlemail.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 /* This file contains any ARDOUR_UI methods that require knowledge of
33    the editor, and exists so that no compilation dependency exists
34    between the main ARDOUR_UI modules and the PublicEditor class. This
35    is to cut down on the nasty compile times for both these classes.
36 */
37 
38 #include <cmath>
39 
40 #include <glibmm/miscutils.h>
41 #include <gtkmm/accelmap.h>
42 #include <gtk/gtk.h>
43 
44 #include "pbd/file_utils.h"
45 #include "pbd/fpu.h"
46 #include "pbd/convert.h"
47 #include "pbd/openuri.h"
48 
49 #include "gtkmm2ext/cairo_packer.h"
50 #include "gtkmm2ext/utils.h"
51 #include "gtkmm2ext/window_title.h"
52 
53 #include "widgets/tearoff.h"
54 #include "widgets/tooltips.h"
55 
56 #include "ardour_ui.h"
57 #include "public_editor.h"
58 #include "audio_clock.h"
59 #include "keyboard.h"
60 #include "monitor_section.h"
61 #include "engine_dialog.h"
62 #include "editor.h"
63 #include "editing.h"
64 #include "actions.h"
65 #include "meterbridge.h"
66 #include "luawindow.h"
67 #include "mixer_ui.h"
68 #include "recorder_ui.h"
69 #include "window_manager.h"
70 #include "global_port_matrix.h"
71 #include "location_ui.h"
72 #include "main_clock.h"
73 #include "rc_option_editor.h"
74 #include "virtual_keyboard_window.h"
75 
76 #include <gtkmm2ext/application.h>
77 
78 #include "ardour/session.h"
79 #include "ardour/profile.h"
80 #include "ardour/audioengine.h"
81 #include "ardour/lv2_plugin.h"
82 
83 #include "control_protocol/control_protocol.h"
84 
85 #include "pbd/i18n.h"
86 
87 using namespace std;
88 using namespace ARDOUR;
89 using namespace PBD;
90 using namespace Gtkmm2ext;
91 using namespace Gtk;
92 using namespace Glib;
93 
94 int
create_editor()95 ARDOUR_UI::create_editor ()
96 {
97 	try {
98 		editor = new Editor ();
99 		editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
100 	}
101 
102 	catch (failed_constructor& err) {
103 		return -1;
104 	}
105 
106 	// editor->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), editor));
107 
108 	return 0;
109 }
110 
111 int
create_luawindow()112 ARDOUR_UI::create_luawindow ()
113 
114 {
115 	try {
116 		luawindow = LuaWindow::instance ();
117 	}
118 	catch (failed_constructor& err) {
119 		return -1;
120 	}
121 
122 	return 0;
123 }
124 
125 int
create_recorder()126 ARDOUR_UI::create_recorder ()
127 {
128 	try {
129 		recorder = new RecorderUI ();
130 		recorder->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
131 	} catch (failed_constructor& err) {
132 		return -1;
133 	}
134 	return 0;
135 }
136 
137 void
escape()138 ARDOUR_UI::escape ()
139 {
140 	Escape (); /* EMIT SIGNAL */
141 }
142 
143 void
close_current_dialog()144 ARDOUR_UI::close_current_dialog ()
145 {
146 	Keyboard::close_current_dialog ();
147 }
148 
149 void
install_actions()150 ARDOUR_UI::install_actions ()
151 {
152 	Glib::RefPtr<ActionGroup> main_actions = ActionManager::create_action_group (global_bindings, X_("Main"));
153 	Glib::RefPtr<ActionGroup> main_menu_actions = ActionManager::create_action_group (global_bindings, X_("Main Menu"));
154 	Glib::RefPtr<Action> act;
155 
156 	ActionManager::register_action (main_actions, X_("Escape"), _("Escape (deselect all)"), sigc::mem_fun (*this, &ARDOUR_UI::escape));
157 	/* This is hard-wired into the Keyboard code as "Primary-w". Maybe it
158 	   doesn't need to be. This action makes it possible to do this from a
159 	   control surface.
160 	*/
161 	ActionManager::register_action (main_actions, X_("close-current-dialog"), _("Close Current Dialog"), sigc::mem_fun (*this, &ARDOUR_UI::close_current_dialog));
162 
163 	/* menus + submenus that need action items */
164 
165 	ActionManager::register_action (main_menu_actions, X_("Session"), _("Session"));
166 	act = ActionManager::register_action (main_menu_actions, X_("Cleanup"), _("Clean-up"));
167 	ActionManager::write_sensitive_actions.push_back (act);
168 	ActionManager::register_action (main_menu_actions, X_("Sync"), _("Sync"));
169 	ActionManager::register_action (main_menu_actions, X_("TransportOptions"), _("Options"));
170 	ActionManager::register_action (main_menu_actions, X_("WindowMenu"), _("Window"));
171 	ActionManager::register_action (main_menu_actions, X_("MixerMenu"), _("Mixer"));
172 	ActionManager::register_action (main_menu_actions, X_("EditorMenu"), _("Editor"));
173 	ActionManager::register_action (main_menu_actions, X_("PrefsMenu"), _("Preferences"));
174 	ActionManager::register_action (main_menu_actions, X_("RecorderMenu"), _("Recorder"));
175 	ActionManager::register_action (main_menu_actions, X_("DetachMenu"), _("Detach"));
176 	ActionManager::register_action (main_menu_actions, X_("Help"), _("Help"));
177 	ActionManager::register_action (main_menu_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
178 	ActionManager::register_action (main_menu_actions, X_("AudioFileFormat"), _("Audio File Format"));
179 	ActionManager::register_action (main_menu_actions, X_("AudioFileFormatHeader"), _("File Type"));
180 	ActionManager::register_action (main_menu_actions, X_("AudioFileFormatData"), _("Sample Format"));
181 	ActionManager::register_action (main_menu_actions, X_("ControlSurfaces"), _("Control Surfaces"));
182 	ActionManager::register_action (main_menu_actions, X_("Plugins"), _("Plugins"));
183 	ActionManager::register_action (main_menu_actions, X_("Metering"), _("Metering"));
184 	ActionManager::register_action (main_menu_actions, X_("MeteringFallOffRate"), _("Fall Off Rate"));
185 	ActionManager::register_action (main_menu_actions, X_("MeteringHoldTime"), _("Hold Time"));
186 	ActionManager::register_action (main_menu_actions, X_("Denormals"), _("Denormal Handling"));
187 
188 	/* the real actions */
189 
190 	act = ActionManager::register_action (main_actions, X_("New"), _("New..."),  hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::start_session_load), true)));
191 
192 	ActionManager::register_action (main_actions, X_("Open"), _("Open..."),  sigc::mem_fun(*this, &ARDOUR_UI::open_session));
193 	ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."),  sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
194 	act = ActionManager::register_action (main_actions, X_("Close"), _("Close"),  sigc::mem_fun(*this, &ARDOUR_UI::close_session));
195 	ActionManager::session_sensitive_actions.push_back (act);
196 
197 	act = ActionManager::register_action (main_actions, X_("AddTrackBus"), _("Add Track, Bus or VCA..."), sigc::mem_fun(*this, &ARDOUR_UI::add_route));
198 	ActionManager::session_sensitive_actions.push_back (act);
199 	ActionManager::write_sensitive_actions.push_back (act);
200 	ActionManager::rec_sensitive_actions.push_back (act);
201 
202 	act = ActionManager::register_action (main_actions, X_("duplicate-routes"), _("Duplicate Tracks/Busses..."),
203 	                                      sigc::mem_fun(*this, &ARDOUR_UI::start_duplicate_routes));
204 	ActionManager::session_sensitive_actions.push_back (act);
205 	ActionManager::write_sensitive_actions.push_back (act);
206 	ActionManager::route_selection_sensitive_actions.push_back (act);
207 
208 	act = ActionManager::register_action (main_actions, X_("cancel-solo"), _("Cancel Solo"), sigc::mem_fun(*this, &ARDOUR_UI::cancel_solo));
209 	ActionManager::session_sensitive_actions.push_back (act);
210 	ActionManager::write_sensitive_actions.push_back (act);
211 
212 	act = ActionManager::register_action (main_actions, X_("Scripting"), S_("Session|Scripting"));
213 	ActionManager::session_sensitive_actions.push_back (act);
214 
215 	act = ActionManager::register_action (main_actions, X_("OpenVideo"), _("Open Video..."),
216 	                                      sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_video), (Gtk::Window*) 0));
217 	ActionManager::session_sensitive_actions.push_back (act);
218 	act = ActionManager::register_action (main_actions, X_("CloseVideo"), _("Remove Video"),
219 	                                      sigc::mem_fun (*this, &ARDOUR_UI::remove_video));
220 	act->set_sensitive (false);
221 	act = ActionManager::register_action (main_actions, X_("ExportVideo"), _("Export to Video File..."),
222 	                                      hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::export_video), false)));
223 	ActionManager::session_sensitive_actions.push_back (act);
224 
225 	act = ActionManager::register_action (main_actions, X_("SnapshotStay"), _("Snapshot (& keep working on current version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), false));
226 	ActionManager::session_sensitive_actions.push_back (act);
227 
228 	act = ActionManager::register_action (main_actions, X_("SnapshotSwitch"), _("Snapshot (& switch to new version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), true));
229 	ActionManager::session_sensitive_actions.push_back (act);
230 
231 	act = ActionManager::register_action (main_actions, X_("QuickSnapshotStay"), _("Quick Snapshot (& keep working on current version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::quick_snapshot_session), false));
232 	ActionManager::session_sensitive_actions.push_back (act);
233 
234 	act = ActionManager::register_action (main_actions, X_("QuickSnapshotSwitch"), _("Quick Snapshot (& switch to new version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::quick_snapshot_session), true));
235 	ActionManager::session_sensitive_actions.push_back (act);
236 	ActionManager::write_sensitive_actions.push_back (act);
237 
238 	act = ActionManager::register_action (main_actions, X_("SaveAs"), _("Save As..."), sigc::mem_fun(*this, &ARDOUR_UI::save_session_as));
239 	ActionManager::session_sensitive_actions.push_back (act);
240 
241 	act = ActionManager::register_action (main_actions, X_("Archive"), _("Archive..."), sigc::mem_fun(*this, &ARDOUR_UI::archive_session));
242 	ActionManager::session_sensitive_actions.push_back (act);
243 
244 	act = ActionManager::register_action (main_actions, X_("Rename"), _("Rename..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::rename_session), false));
245 	ActionManager::session_sensitive_actions.push_back (act);
246 	ActionManager::write_sensitive_actions.push_back (act);
247 
248 	act = ActionManager::register_action (main_actions, X_("SaveTemplate"), _("Save Template..."),  sigc::mem_fun(*this, &ARDOUR_UI::save_template));
249 	ActionManager::session_sensitive_actions.push_back (act);
250 
251 	act = ActionManager::register_action (main_actions, X_("ManageTemplates"), _("Templates"), sigc::mem_fun(*this, &ARDOUR_UI::manage_templates));
252 	ActionManager::session_sensitive_actions.push_back (act);
253 
254 	act = ActionManager::register_action (main_actions, X_("Metadata"), _("Metadata"));
255 	ActionManager::session_sensitive_actions.push_back (act);
256 
257 	act = ActionManager::register_action (main_actions, X_("EditMetadata"), _("Edit Metadata..."),  sigc::mem_fun(*this, &ARDOUR_UI::edit_metadata));
258 	ActionManager::session_sensitive_actions.push_back (act);
259 
260 	act = ActionManager::register_action (main_actions, X_("ImportMetadata"), _("Import Metadata..."),  sigc::mem_fun(*this, &ARDOUR_UI::import_metadata));
261 	ActionManager::session_sensitive_actions.push_back (act);
262 
263 	act = ActionManager::register_action (main_actions, X_("Export"), _("Export"));
264 	ActionManager::session_sensitive_actions.push_back (act);
265 
266 	act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
267 
268 	ActionManager::write_sensitive_actions.push_back (act);
269 	ActionManager::session_sensitive_actions.push_back (act);
270 
271 	/* these actions are intended to be shared across all windows */
272 
273 	common_actions = ActionManager::create_action_group (global_bindings, X_("Common"));
274 	ActionManager::register_action (common_actions, X_("Quit"), _("Quit"), (hide_return (sigc::mem_fun(*this, &ARDOUR_UI::finish))));
275 	ActionManager::register_action (common_actions, X_("Hide"), _("Hide"), sigc::mem_fun (*this, &ARDOUR_UI::hide_application));
276 
277 	if (Profile->get_mixbus()) {
278 		ActionManager::register_action (common_actions, X_("show-ui-prefs"), _("Show more UI preferences"), sigc::mem_fun (*this, &ARDOUR_UI::show_ui_prefs));
279 	}
280 
281 	ActionManager::register_action (common_actions, X_("toggle-luawindow"), S_("Window|Scripting"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_luawindow));
282 	ActionManager::register_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge));
283 
284 	act = ActionManager::register_action (common_actions, X_("NewMIDITracer"), _("MIDI Tracer"), sigc::mem_fun(*this, &ARDOUR_UI::new_midi_tracer_window));
285 	ActionManager::session_sensitive_actions.push_back (act);
286 
287 	ActionManager::register_action (common_actions, X_("chat"), _("Chat"),  sigc::mem_fun(*this, &ARDOUR_UI::launch_chat));
288 	ActionManager::register_action (common_actions, X_("tutorial"), S_("Help|Tutorial"),  mem_fun(*this, &ARDOUR_UI::launch_tutorial));
289 	ActionManager::register_action (common_actions, X_("reference"), S_("Manual|Reference"),  mem_fun(*this, &ARDOUR_UI::launch_reference));
290 	ActionManager::register_action (common_actions, X_("tracker"), _("Report a Bug"), mem_fun(*this, &ARDOUR_UI::launch_tracker));
291 	ActionManager::register_action (common_actions, X_("cheat-sheet"), _("Cheat Sheet"), mem_fun(*this, &ARDOUR_UI::launch_cheat_sheet));
292 	ActionManager::register_action (common_actions, X_("website"), _("Website"), mem_fun(*this, &ARDOUR_UI::launch_website));
293 	ActionManager::register_action (common_actions, X_("website-dev"), _("Development"), mem_fun(*this, &ARDOUR_UI::launch_website_dev));
294 	ActionManager::register_action (common_actions, X_("forums"), _("User Forums"), mem_fun(*this, &ARDOUR_UI::launch_forums));
295 	ActionManager::register_action (common_actions, X_("howto-report"), _("How to Report a Bug"), mem_fun(*this, &ARDOUR_UI::launch_howto_report));
296 
297 	act = ActionManager::register_action (common_actions, X_("Save"), _("Save"),  sigc::hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""), false)));
298 	ActionManager::session_sensitive_actions.push_back (act);
299 	ActionManager::write_sensitive_actions.push_back (act);
300 
301 	/* this is used by the monitor section to create global equivalents of
302 	 * some of its "local" actions. It will be used when Monitor/... actions
303 	 * are created.
304 	 */
305 
306 	(void) ActionManager::create_action_group (global_bindings, X_("Monitor Section"));
307 
308 	Glib::RefPtr<ActionGroup> transport_actions = ActionManager::create_action_group (global_bindings, X_("Transport"));
309 
310 	/* do-nothing action for the "transport" menu bar item */
311 
312 	ActionManager::register_action (transport_actions, X_("Transport"), _("Transport"));
313 
314 	/* these two are not used by key bindings, instead use ToggleRoll for that. these two do show up in
315 	   menus and via button proxies.
316 	*/
317 
318 	act = ActionManager::register_action (transport_actions, X_("Stop"), _("Stop"), sigc::mem_fun(*this, &ARDOUR_UI::transport_stop));
319 	ActionManager::session_sensitive_actions.push_back (act);
320 	ActionManager::transport_sensitive_actions.push_back (act);
321 	act = ActionManager::register_action (transport_actions, X_("Roll"), _("Roll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_roll));
322 	ActionManager::session_sensitive_actions.push_back (act);
323 	ActionManager::transport_sensitive_actions.push_back (act);
324 
325 	act = ActionManager::register_action (transport_actions, X_("ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
326 	ActionManager::session_sensitive_actions.push_back (act);
327 	ActionManager::transport_sensitive_actions.push_back (act);
328 	act = ActionManager::register_action (transport_actions, X_("alternate-ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
329 	ActionManager::session_sensitive_actions.push_back (act);
330 	ActionManager::transport_sensitive_actions.push_back (act);
331 	act = ActionManager::register_action (transport_actions, X_("ToggleRollMaybe"), _("Start/Continue/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, true));
332 	ActionManager::session_sensitive_actions.push_back (act);
333 	ActionManager::transport_sensitive_actions.push_back (act);
334 	act = ActionManager::register_action (transport_actions, X_("ToggleRollForgetCapture"), _("Stop and Forget Capture"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_roll), true, false));
335 	ActionManager::session_sensitive_actions.push_back (act);
336 	ActionManager::transport_sensitive_actions.push_back (act);
337 
338 	act = ActionManager::register_action (transport_actions, X_("Loop"), _("Play Loop Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
339 	ActionManager::session_sensitive_actions.push_back (act);
340 	ActionManager::transport_sensitive_actions.push_back (act);
341 	act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selection"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
342 	ActionManager::session_sensitive_actions.push_back (act);
343 	ActionManager::transport_sensitive_actions.push_back (act);
344 	act = ActionManager::register_action (transport_actions, X_("PlayPreroll"), _("Play w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_preroll));
345 	ActionManager::session_sensitive_actions.push_back (act);
346 	ActionManager::transport_sensitive_actions.push_back (act);
347 
348 
349 	act = ActionManager::register_action (transport_actions, X_("RecordPreroll"), _("Record w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_preroll));
350 	ActionManager::session_sensitive_actions.push_back (act);
351 	ActionManager::write_sensitive_actions.push_back (act);
352 
353 	act = ActionManager::register_action (transport_actions, X_("RecordCountIn"), _("Record w/Count-In"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rec_count_in));
354 	ActionManager::session_sensitive_actions.push_back (act);
355 	ActionManager::write_sensitive_actions.push_back (act);
356 
357 	act = ActionManager::register_action (transport_actions, X_("Record"), _("Enable Record"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), false));
358 	ActionManager::session_sensitive_actions.push_back (act);
359 	ActionManager::write_sensitive_actions.push_back (act);
360 	act = ActionManager::register_action (transport_actions, X_("record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
361 	ActionManager::session_sensitive_actions.push_back (act);
362 	ActionManager::write_sensitive_actions.push_back (act);
363 	ActionManager::transport_sensitive_actions.push_back (act);
364 	act = ActionManager::register_action (transport_actions, X_("alternate-record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
365 	ActionManager::session_sensitive_actions.push_back (act);
366 	ActionManager::write_sensitive_actions.push_back (act);
367 	ActionManager::transport_sensitive_actions.push_back (act);
368 	act = ActionManager::register_action (transport_actions, X_("Rewind"), _("Rewind"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind));
369 	ActionManager::session_sensitive_actions.push_back (act);
370 	ActionManager::transport_sensitive_actions.push_back (act);
371 	act = ActionManager::register_action (transport_actions, X_("RewindSlow"), _("Rewind (Slow)"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind));
372 	ActionManager::session_sensitive_actions.push_back (act);
373 	ActionManager::transport_sensitive_actions.push_back (act);
374 	act = ActionManager::register_action (transport_actions, X_("RewindFast"), _("Rewind (Fast)"), sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind));
375 	ActionManager::session_sensitive_actions.push_back (act);
376 	ActionManager::transport_sensitive_actions.push_back (act);
377 	act = ActionManager::register_action (transport_actions, X_("Forward"), _("Forward"), sigc::mem_fun(*this, &ARDOUR_UI::transport_forward));
378 	ActionManager::session_sensitive_actions.push_back (act);
379 	ActionManager::transport_sensitive_actions.push_back (act);
380 	act = ActionManager::register_action (transport_actions, X_("ForwardSlow"), _("Forward (Slow)"), sigc::mem_fun(*this, &ARDOUR_UI::transport_forward));
381 	ActionManager::session_sensitive_actions.push_back (act);
382 	ActionManager::transport_sensitive_actions.push_back (act);
383 	act = ActionManager::register_action (transport_actions, X_("ForwardFast"), _("Forward (Fast)"), sigc::mem_fun(*this, &ARDOUR_UI::transport_forward));
384 	ActionManager::session_sensitive_actions.push_back (act);
385 	ActionManager::transport_sensitive_actions.push_back (act);
386 	act = ActionManager::register_action (transport_actions, X_("GotoZero"), _("Go to Zero"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_zero));
387 	ActionManager::session_sensitive_actions.push_back (act);
388 	ActionManager::transport_sensitive_actions.push_back (act);
389 	act = ActionManager::register_action (transport_actions, X_("GotoStart"), _("Go to Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
390 	ActionManager::session_sensitive_actions.push_back (act);
391 	ActionManager::transport_sensitive_actions.push_back (act);
392 	act = ActionManager::register_action (transport_actions, X_("alternate-GotoStart"), _("Go to Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
393 	ActionManager::session_sensitive_actions.push_back (act);
394 	ActionManager::transport_sensitive_actions.push_back (act);
395 	act = ActionManager::register_action (transport_actions, X_("GotoEnd"), _("Go to End"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_end));
396 	ActionManager::session_sensitive_actions.push_back (act);
397 	ActionManager::transport_sensitive_actions.push_back (act);
398 	act = ActionManager::register_action (transport_actions, X_("GotoWallClock"), _("Go to Wall Clock"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_wallclock));
399 	ActionManager::session_sensitive_actions.push_back (act);
400 	ActionManager::transport_sensitive_actions.push_back (act);
401 
402 	//these actions handle the numpad events, ProTools style
403 	act = ActionManager::register_action (transport_actions, X_("numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
404 	ActionManager::session_sensitive_actions.push_back (act);
405 	ActionManager::transport_sensitive_actions.push_back (act);
406 	act = ActionManager::register_action (transport_actions, X_("alternate-numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
407 	ActionManager::session_sensitive_actions.push_back (act);
408 	ActionManager::transport_sensitive_actions.push_back (act);
409 	act = ActionManager::register_action (transport_actions, X_("numpad-0"), _("Numpad 0"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 0));
410 	ActionManager::session_sensitive_actions.push_back (act);
411 	ActionManager::transport_sensitive_actions.push_back (act);
412 	act = ActionManager::register_action (transport_actions, X_("numpad-1"), _("Numpad 1"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 1));
413 	ActionManager::session_sensitive_actions.push_back (act);
414 	ActionManager::transport_sensitive_actions.push_back (act);
415 	act = ActionManager::register_action (transport_actions, X_("numpad-2"), _("Numpad 2"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 2));
416 	ActionManager::session_sensitive_actions.push_back (act);
417 	ActionManager::transport_sensitive_actions.push_back (act);
418 	act = ActionManager::register_action (transport_actions, X_("numpad-3"), _("Numpad 3"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 3));
419 	ActionManager::session_sensitive_actions.push_back (act);
420 	ActionManager::transport_sensitive_actions.push_back (act);
421 	act = ActionManager::register_action (transport_actions, X_("numpad-4"), _("Numpad 4"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 4));
422 	ActionManager::session_sensitive_actions.push_back (act);
423 	ActionManager::transport_sensitive_actions.push_back (act);
424 	act = ActionManager::register_action (transport_actions, X_("numpad-5"), _("Numpad 5"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 5));
425 	ActionManager::session_sensitive_actions.push_back (act);
426 	ActionManager::transport_sensitive_actions.push_back (act);
427 	act = ActionManager::register_action (transport_actions, X_("numpad-6"), _("Numpad 6"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 6));
428 	ActionManager::session_sensitive_actions.push_back (act);
429 	ActionManager::transport_sensitive_actions.push_back (act);
430 	act = ActionManager::register_action (transport_actions, X_("numpad-7"), _("Numpad 7"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 7));
431 	ActionManager::session_sensitive_actions.push_back (act);
432 	ActionManager::transport_sensitive_actions.push_back (act);
433 	act = ActionManager::register_action (transport_actions, X_("numpad-8"), _("Numpad 8"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 8));
434 	ActionManager::session_sensitive_actions.push_back (act);
435 	ActionManager::transport_sensitive_actions.push_back (act);
436 	act = ActionManager::register_action (transport_actions, X_("numpad-9"), _("Numpad 9"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 9));
437 	ActionManager::session_sensitive_actions.push_back (act);
438 	ActionManager::transport_sensitive_actions.push_back (act);
439 
440 	act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(*this, &ARDOUR_UI::focus_on_clock));
441 	ActionManager::session_sensitive_actions.push_back (act);
442 	ActionManager::transport_sensitive_actions.push_back (act);
443 
444 	act = ActionManager::register_action (transport_actions, X_("primary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Timecode, false));
445 	ActionManager::session_sensitive_actions.push_back (act);
446 	act = ActionManager::register_action (transport_actions, X_("primary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::BBT, false));
447 	ActionManager::session_sensitive_actions.push_back (act);
448 	act = ActionManager::register_action (transport_actions, X_("primary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::MinSec, false));
449 	ActionManager::session_sensitive_actions.push_back (act);
450 	act = ActionManager::register_action (transport_actions, X_("primary-clock-seconds"), _("Seconds"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Seconds, false));
451 	ActionManager::session_sensitive_actions.push_back (act);
452 	act = ActionManager::register_action (transport_actions, X_("primary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Samples, false));
453 	ActionManager::session_sensitive_actions.push_back (act);
454 
455 	act = ActionManager::register_action (transport_actions, X_("secondary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Timecode, false));
456 	ActionManager::session_sensitive_actions.push_back (act);
457 	act = ActionManager::register_action (transport_actions, X_("secondary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::BBT, false));
458 	ActionManager::session_sensitive_actions.push_back (act);
459 	act = ActionManager::register_action (transport_actions, X_("secondary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::MinSec, false));
460 	ActionManager::session_sensitive_actions.push_back (act);
461 	act = ActionManager::register_action (transport_actions, X_("secondary-clock-seconds"), _("Seconds"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Seconds, false));
462 	ActionManager::session_sensitive_actions.push_back (act);
463 	act = ActionManager::register_action (transport_actions, X_("secondary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Samples, false));
464 	ActionManager::session_sensitive_actions.push_back (act);
465 
466 	act = ActionManager::register_toggle_action (transport_actions, X_("SessionMonitorIn"), _("All Input"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_monitoring_in));
467 	act->set_short_label (_("All In"));
468 	ActionManager::session_sensitive_actions.push_back (act);
469 	act = ActionManager::register_toggle_action (transport_actions, X_("SessionMonitorDisk"), _("All Disk"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_monitoring_disk));
470 	act->set_short_label (_("All Disk"));
471 	ActionManager::session_sensitive_actions.push_back (act);
472 
473 	act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
474 	act->set_short_label (_("In"));
475 	ActionManager::session_sensitive_actions.push_back (act);
476 	ActionManager::transport_sensitive_actions.push_back (act);
477 	act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchOut"), _("Punch Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_out));
478 	act->set_short_label (_("Out"));
479 	ActionManager::session_sensitive_actions.push_back (act);
480 	ActionManager::transport_sensitive_actions.push_back (act);
481 	act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunch"), _("Punch In/Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch));
482 	act->set_short_label (_("In/Out"));
483 	ActionManager::session_sensitive_actions.push_back (act);
484 	ActionManager::transport_sensitive_actions.push_back (act);
485 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleClick"), _("Click"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_click));
486 	ActionManager::session_sensitive_actions.push_back (act);
487 	ActionManager::transport_sensitive_actions.push_back (act);
488 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoInput"), _("Auto Input"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_input));
489 	ActionManager::session_sensitive_actions.push_back (act);
490 	ActionManager::transport_sensitive_actions.push_back (act);
491 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoPlay"), _("Auto Play"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_play));
492 	ActionManager::session_sensitive_actions.push_back (act);
493 	ActionManager::transport_sensitive_actions.push_back (act);
494 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoReturn"), _("Auto Return"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_return));
495 	ActionManager::session_sensitive_actions.push_back (act);
496 	ActionManager::transport_sensitive_actions.push_back (act);
497 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleFollowEdits"), _("Follow Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_follow_edits));
498 	ActionManager::session_sensitive_actions.push_back (act);
499 	ActionManager::transport_sensitive_actions.push_back (act);
500 
501 	act = ActionManager::register_toggle_action (main_actions, X_("ToggleLatencyCompensation"), _("Disable Latency Compensation"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_latency_switch));
502 	ActionManager::session_sensitive_actions.push_back (act);
503 
504 	act = ActionManager::register_action (main_actions, X_("MonitorMenu"), _("Monitor Section")); /* just the submenu item */
505 	ActionManager::session_sensitive_actions.push_back (act);
506 
507 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync Startup to Video"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_video_sync));
508 	ActionManager::session_sensitive_actions.push_back (act);
509 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleTimeMaster"), _("Time Master"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_time_master));
510 	ActionManager::session_sensitive_actions.push_back (act);
511 	act = ActionManager::register_toggle_action (transport_actions, X_("ToggleExternalSync"), _("Use External Positional Sync Source"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_external_sync));
512 	ActionManager::session_sensitive_actions.push_back (act);
513 
514 	for (int i = 1; i <= 32; ++i) {
515 		string const a = string_compose (X_("ToggleRecordEnableTrack%1"), i);
516 		string const n = string_compose (_("Toggle Record Enable Track %1"), i);
517 		act = ActionManager::register_action (common_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_record_enable), i - 1));
518 		ActionManager::session_sensitive_actions.push_back (act);
519 	}
520 
521 	Glib::RefPtr<ActionGroup> shuttle_actions = ActionManager::create_action_group (global_bindings, "ShuttleActions");
522 
523 	shuttle_actions->add (Action::create (X_("SetShuttleUnitsPercentage"), _("Percentage")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Percentage)));
524 	shuttle_actions->add (Action::create (X_("SetShuttleUnitsSemitones"), _("Semitones")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Semitones)));
525 
526 	Glib::RefPtr<ActionGroup> option_actions = ActionManager::create_action_group (global_bindings, "Options");
527 
528 	act = ActionManager::register_toggle_action (option_actions, X_("SendMTC"), _("Send MTC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mtc));
529 	ActionManager::session_sensitive_actions.push_back (act);
530 	act = ActionManager::register_toggle_action (option_actions, X_("SendMMC"), _("Send MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mmc));
531 	ActionManager::session_sensitive_actions.push_back (act);
532 	act = ActionManager::register_toggle_action (option_actions, X_("UseMMC"), _("Use MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_use_mmc));
533 	ActionManager::session_sensitive_actions.push_back (act);
534 	act = ActionManager::register_toggle_action (option_actions, X_("SendMidiClock"), _("Send MIDI Clock"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_clock));
535 	ActionManager::session_sensitive_actions.push_back (act);
536 
537 	/* MIDI */
538 
539 	Glib::RefPtr<ActionGroup> midi_actions = ActionManager::create_action_group (global_bindings, X_("MIDI"));
540 	act = ActionManager::register_action (midi_actions, X_("panic"), _("Panic (Send MIDI all-notes-off)"), sigc::mem_fun(*this, &ARDOUR_UI::midi_panic));
541 	ActionManager::session_sensitive_actions.push_back (act);
542 	ActionManager::transport_sensitive_actions.push_back (act);
543 }
544 
545 void
install_dependent_actions()546 ARDOUR_UI::install_dependent_actions ()
547 {
548 	using namespace Glib;
549 	using namespace Gtk;
550 
551 	RefPtr<ActionGroup> main_actions = ActionManager::get_action_group (X_("Main"));
552 	assert (main_actions);
553 	RefPtr<ActionGroup> common_actions = ActionManager::get_action_group (X_("Common"));
554 	assert (common_actions);
555 	RefPtr<ActionGroup> transport_actions = ActionManager::get_action_group (X_("Transport"));
556 	assert (transport_actions);
557 
558 	RefPtr<Action> act;
559 
560 	/* these two behave as follows:
561 
562 	   - if transport speed != 1.0 or != -1.0, change speed to 1.0 or -1.0 (respectively)
563 	   - otherwise do nothing
564 	*/
565 
566 	act = ActionManager::register_action (transport_actions, X_("TransitionToRoll"), _("Transition to Roll"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), true));
567 	ActionManager::session_sensitive_actions.push_back (act);
568 	ActionManager::transport_sensitive_actions.push_back (act);
569 
570 	act = ActionManager::register_action (transport_actions, X_("TransitionToReverse"), _("Transition to Reverse"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), false));
571 	ActionManager::session_sensitive_actions.push_back (act);
572 	ActionManager::transport_sensitive_actions.push_back (act);
573 
574 	act = ActionManager::register_action (common_actions, "jump-backward-to-mark", _("Jump to Previous Mark"), sigc::mem_fun(*editor, &PublicEditor::jump_backward_to_mark));
575 	ActionManager::session_sensitive_actions.push_back (act);
576 
577 	act = ActionManager::register_action (common_actions, "jump-forward-to-mark", _("Jump to Next Mark"), sigc::mem_fun(*editor, &PublicEditor::jump_forward_to_mark));
578 	ActionManager::session_sensitive_actions.push_back (act);
579 
580 	for (int i = 1; i <= 9; ++i) {
581 		string const a = string_compose(X_("goto-mark-%1"), i);
582 		string const n = string_compose(_("Locate to Mark %1"), i);
583 		act = ActionManager::register_action (transport_actions, a.c_str(), n.c_str(), sigc::bind(sigc::mem_fun(*editor, &PublicEditor::goto_nth_marker), i-1));
584 		ActionManager::session_sensitive_actions.push_back (act);
585 	}
586 
587 	act = ActionManager::register_action (common_actions, X_("addExistingAudioFiles"), _("Import"), sigc::mem_fun (*editor, &PublicEditor::external_audio_dialog));
588 	ActionManager::session_sensitive_actions.push_back (act);
589 	ActionManager::write_sensitive_actions.push_back (act);
590 
591 	act = ActionManager::register_action (main_actions, X_("StemExport"), _("Stem export..."),  sigc::mem_fun (*editor, &PublicEditor::stem_export));
592 	ActionManager::session_sensitive_actions.push_back (act);
593 
594 	act = ActionManager::register_action (main_actions, X_("ExportAudio"), _("Export to Audio File(s)..."),  sigc::mem_fun (*editor, &PublicEditor::export_audio));
595 	ActionManager::session_sensitive_actions.push_back (act);
596 
597 	act = ActionManager::register_action (main_actions, X_("CleanupUnusedSources"), _("Clean-up Unused Sources..."),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup));
598 	ActionManager::session_sensitive_actions.push_back (act);
599 	ActionManager::write_sensitive_actions.push_back (act);
600 
601 	act = ActionManager::register_action (main_actions, X_("CleanupUnusedRegions"), _("Clean-up Unused Regions..."),  sigc::mem_fun (*editor, &PublicEditor::cleanup_regions));
602 	ActionManager::session_sensitive_actions.push_back (act);
603 	ActionManager::write_sensitive_actions.push_back (act);
604 
605 	act = ActionManager::register_action (main_actions, X_("CleanupPeakFiles"), _("Rebuild Peak Files"),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup_peakfiles));
606 	ActionManager::session_sensitive_actions.push_back (act);
607 	ActionManager::write_sensitive_actions.push_back (act);
608 
609 	/* these actions are all currently implemented by the Editor, but need
610 	 * to be accessible from anywhere as actions.
611 	 */
612 
613 	act = ActionManager::register_action (common_actions, "alternate-jump-forward-to-mark", _("Jump to Next Mark"), sigc::mem_fun(editor, &PublicEditor::jump_forward_to_mark));
614 	ActionManager::session_sensitive_actions.push_back (act);
615 	act = ActionManager::register_action (common_actions, "alternate-jump-backward-to-mark", _("Jump to Previous Mark"), sigc::mem_fun(editor, &PublicEditor::jump_backward_to_mark));
616 	ActionManager::session_sensitive_actions.push_back (act);
617 
618 	act = ActionManager::register_action (common_actions, "set-session-start-from-playhead", _("Set Session Start from Playhead"), sigc::mem_fun(editor, &PublicEditor::set_session_start_from_playhead));
619 	ActionManager::session_sensitive_actions.push_back (act);
620 	act = ActionManager::register_action (common_actions, "set-session-end-from-playhead", _("Set Session End from Playhead"), sigc::mem_fun(editor, &PublicEditor::set_session_end_from_playhead));
621 	ActionManager::session_sensitive_actions.push_back (act);
622 
623 	act = ActionManager::register_action (common_actions, "toggle-location-at-playhead", _("Toggle Mark at Playhead"), sigc::mem_fun(editor, &PublicEditor::toggle_location_at_playhead_cursor));
624 	ActionManager::session_sensitive_actions.push_back (act);
625 	act = ActionManager::register_action (common_actions, "add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(editor, &PublicEditor::add_location_from_playhead_cursor));
626 	ActionManager::session_sensitive_actions.push_back (act);
627 	act = ActionManager::register_action (common_actions, "alternate-add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(editor, &PublicEditor::add_location_from_playhead_cursor));
628 	ActionManager::session_sensitive_actions.push_back (act);
629 
630 	act = ActionManager::register_action (common_actions, "remove-location-from-playhead", _("Remove Mark at Playhead"), sigc::mem_fun(editor, &PublicEditor::remove_location_at_playhead_cursor));
631 	ActionManager::session_sensitive_actions.push_back (act);
632 	act = ActionManager::register_action (common_actions, "alternate-remove-location-from-playhead", _("Remove Mark at Playhead"), sigc::mem_fun(editor, &PublicEditor::remove_location_at_playhead_cursor));
633 	ActionManager::session_sensitive_actions.push_back (act);
634 
635 	act = ActionManager::register_action (common_actions, "nudge-next-forward", _("Nudge Next Later"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_forward), true, false));
636 	ActionManager::session_sensitive_actions.push_back (act);
637 	act = ActionManager::register_action (common_actions, "nudge-next-backward", _("Nudge Next Earlier"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_backward), true, false));
638 	ActionManager::session_sensitive_actions.push_back (act);
639 
640 	act = ActionManager::register_action (common_actions, "nudge-playhead-forward", _("Nudge Playhead Forward"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_forward), false, true));
641 	ActionManager::session_sensitive_actions.push_back (act);
642 	act = ActionManager::register_action (common_actions, "nudge-playhead-backward", _("Nudge Playhead Backward"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::nudge_backward), false, true));
643 	ActionManager::session_sensitive_actions.push_back (act);
644 	act = ActionManager::register_action (common_actions, "playhead-forward-to-grid", _("Playhead to Next Grid"), sigc::mem_fun(editor, &PublicEditor::playhead_forward_to_grid));
645 	ActionManager::session_sensitive_actions.push_back (act);
646 	act = ActionManager::register_action (common_actions, "playhead-backward-to-grid", _("Playhead to Previous Grid"), sigc::mem_fun(editor, &PublicEditor::playhead_backward_to_grid));
647 	ActionManager::session_sensitive_actions.push_back (act);
648 
649 	act = ActionManager::register_action (common_actions, "start-range-from-playhead", _("Start Range from Playhead"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_begin), Editing::EDIT_IGNORE_MOUSE ));
650 	ActionManager::session_sensitive_actions.push_back (act);
651 	act = ActionManager::register_action (common_actions, "finish-range-from-playhead", _("Finish Range from Playhead"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_finish), false, Editing::EDIT_IGNORE_MOUSE ));
652 	ActionManager::session_sensitive_actions.push_back (act);
653 	act = ActionManager::register_action (common_actions, "start-range", _("Start Range"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_begin), Editing::EDIT_IGNORE_NONE));
654 	ActionManager::session_sensitive_actions.push_back (act);
655 	act = ActionManager::register_action (common_actions, "finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_finish), false, Editing::EDIT_IGNORE_NONE));
656 	ActionManager::session_sensitive_actions.push_back (act);
657 	act = ActionManager::register_action (common_actions, "start-punch-range", _("Start Punch Range"), sigc::mem_fun(editor, &PublicEditor::set_punch_start_from_edit_point));
658 	ActionManager::session_sensitive_actions.push_back (act);
659 	act = ActionManager::register_action (common_actions, "finish-punch-range", _("Finish Punch Range"), sigc::mem_fun(editor, &PublicEditor::set_punch_end_from_edit_point));
660 	ActionManager::session_sensitive_actions.push_back (act);
661 	act = ActionManager::register_action (common_actions, "start-loop-range", _("Start Loop Range"), sigc::mem_fun(editor, &PublicEditor::set_loop_start_from_edit_point));
662 	ActionManager::session_sensitive_actions.push_back (act);
663 	act = ActionManager::register_action (common_actions, "finish-loop-range", _("Finish Loop Range"), sigc::mem_fun(editor, &PublicEditor::set_loop_end_from_edit_point));
664 	ActionManager::session_sensitive_actions.push_back (act);
665 	act = ActionManager::register_action (common_actions, "alt-start-range", _("Start Range"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_begin), Editing::EDIT_IGNORE_NONE));
666 	ActionManager::session_sensitive_actions.push_back (act);
667 	act = ActionManager::register_action (common_actions, "alt-finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(editor, &PublicEditor::keyboard_selection_finish), false, Editing::EDIT_IGNORE_NONE));
668 	ActionManager::session_sensitive_actions.push_back (act);
669 
670 	act = ActionManager::register_action (common_actions, "select-all-visible-lanes", _("Select All Visible Lanes"), sigc::mem_fun(editor, &PublicEditor::select_all_visible_lanes));
671 	ActionManager::session_sensitive_actions.push_back (act);
672 	act = ActionManager::register_action (common_actions, "select-all-tracks", _("Select All Tracks"), sigc::mem_fun(editor, &PublicEditor::select_all_tracks));
673 	ActionManager::session_sensitive_actions.push_back (act);
674 	act = ActionManager::register_action (common_actions, "deselect-all", _("Deselect All"), sigc::mem_fun(editor, &PublicEditor::deselect_all));
675 	ActionManager::session_sensitive_actions.push_back (act);
676 	act = ActionManager::register_action (common_actions, "invert-selection", _("Invert Selection"), sigc::mem_fun(editor, &PublicEditor::invert_selection));
677 	ActionManager::session_sensitive_actions.push_back (act);
678 
679 	act = ActionManager::register_action (transport_actions, X_("solo-selection"), _("Solo Selection"), sigc::bind (sigc::mem_fun(*editor, &PublicEditor::play_solo_selection), true));
680 	ActionManager::session_sensitive_actions.push_back (act);
681 	ActionManager::transport_sensitive_actions.push_back (act);
682 
683 	/* XXX */
684 
685 	ActionManager::register_action (common_actions, X_("menu-show-preferences"), _("Preferences"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), rc_option_editor));
686 
687 	ActionManager::register_action (common_actions, X_("hide-editor"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), editor));
688 	ActionManager::register_action (common_actions, X_("hide-mixer"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), mixer));
689 	ActionManager::register_action (common_actions, X_("hide-preferences"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), rc_option_editor));
690 	ActionManager::register_action (common_actions, X_("hide-recorder"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), recorder));
691 
692 	ActionManager::register_action (common_actions, X_("attach-editor"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), editor));
693 	ActionManager::register_action (common_actions, X_("attach-mixer"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), mixer));
694 	ActionManager::register_action (common_actions, X_("attach-preferences"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), rc_option_editor));
695 	ActionManager::register_action (common_actions, X_("attach-recorder"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), recorder));
696 
697 	ActionManager::register_action (common_actions, X_("detach-editor"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), editor));
698 	ActionManager::register_action (common_actions, X_("detach-mixer"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), mixer));
699 	ActionManager::register_action (common_actions, X_("detach-preferences"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), rc_option_editor));
700 	ActionManager::register_action (common_actions, X_("detach-recorder"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), recorder));
701 
702 	ActionManager::register_action (common_actions, X_("show-editor"), _("Show Editor"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), editor));
703 	ActionManager::register_action (common_actions, X_("show-mixer"), _("Show Mixer"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), mixer));
704 	ActionManager::register_action (common_actions, X_("show-preferences"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), rc_option_editor));
705 	ActionManager::register_action (common_actions, X_("show-recorder"), _("Show Recorder"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), recorder));
706 
707 	/* These "change" actions are not intended to be used inside menus, but
708 	   are for the tab/window control buttons, which have somewhat odd
709 	   semantics.
710 	*/
711 	ActionManager::register_action (common_actions, X_("change-editor-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::button_change_tabbable_visibility), editor));
712 	ActionManager::register_action (common_actions, X_("change-mixer-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::button_change_tabbable_visibility), mixer));
713 	ActionManager::register_action (common_actions, X_("change-preferences-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::button_change_tabbable_visibility), rc_option_editor));
714 	ActionManager::register_action (common_actions, X_("change-recorder-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::button_change_tabbable_visibility), recorder));
715 
716 	/* These "change" actions are not intended to be used inside menus, but
717 	   are for the tab/window control key bindings, which have somewhat odd
718 	   semantics.
719 	*/
720 	ActionManager::register_action (common_actions, X_("key-change-editor-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_change_tabbable_visibility), editor));
721 	ActionManager::register_action (common_actions, X_("key-change-mixer-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_change_tabbable_visibility), mixer));
722 	ActionManager::register_action (common_actions, X_("key-change-preferences-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_change_tabbable_visibility), rc_option_editor));
723 	ActionManager::register_action (common_actions, X_("key-change-recorder-visibility"), _("Change"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::key_change_tabbable_visibility), recorder));
724 
725 	ActionManager::register_action (common_actions, X_("previous-tab"), _("Previous Tab"), sigc::mem_fun (*this, &ARDOUR_UI::step_up_through_tabs));
726 	ActionManager::register_action (common_actions, X_("next-tab"), _("Next Tab"), sigc::mem_fun (*this, &ARDOUR_UI::step_down_through_tabs));
727 
728 	ActionManager::register_action (common_actions, X_("toggle-editor-and-mixer"), _("Toggle Editor & Mixer"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_editor_and_mixer));
729 
730 	/* windows visibility actions */
731 
732 	ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalEditor"), _("Maximise Editor Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_editing_space));
733 	ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalMixer"), _("Maximise Mixer Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_mixer_space));
734 	ActionManager::session_sensitive_actions.push_back (act);
735 }
736 
737 void
build_menu_bar()738 ARDOUR_UI::build_menu_bar ()
739 {
740 	menu_bar = dynamic_cast<MenuBar*> (ActionManager::get_widget (X_("/Main")));
741 	menu_bar->set_name ("MainMenuBar");
742 
743 	EventBox* ev = manage (new EventBox);
744 	ev->set_name ("MainMenuBar");
745 	ev->show ();
746 
747 	EventBox* ev_dsp = manage (new EventBox);
748 	EventBox* ev_path = manage (new EventBox);
749 	EventBox* ev_name = manage (new EventBox);
750 	EventBox* ev_audio = manage (new EventBox);
751 	EventBox* ev_format = manage (new EventBox);
752 	EventBox* ev_timecode = manage (new EventBox);
753 
754 	ev_dsp->set_name ("MainMenuBar");
755 	ev_path->set_name ("MainMenuBar");
756 	ev_name->set_name ("MainMenuBar");
757 	ev_audio->set_name ("MainMenuBar");
758 	ev_format->set_name ("MainMenuBar");
759 	ev_timecode->set_name ("MainMenuBar");
760 
761 	Gtk::HBox* hbox = manage (new Gtk::HBox);
762 	hbox->show ();
763 	hbox->set_border_width (2);
764 	ev->add (*hbox);
765 
766 	wall_clock_label.set_name ("WallClock");
767 	wall_clock_label.set_use_markup ();
768 	timecode_format_label.set_name ("WallClock");
769 	timecode_format_label.set_use_markup ();
770 	peak_thread_work_label.set_name ("PeakThreadWork");
771 	peak_thread_work_label.set_use_markup ();
772 	sample_rate_label.set_name ("SampleRate");
773 	sample_rate_label.set_use_markup ();
774 	format_label.set_name ("Format");
775 	session_path_label.set_name ("Path");
776 	snapshot_name_label.set_name ("Name");
777 	format_label.set_use_markup ();
778 
779 	ev_dsp->add (dsp_load_label);
780 	ev_path->add (session_path_label);
781 	ev_name->add (snapshot_name_label);
782 	ev_audio->add (sample_rate_label);
783 	ev_format->add (format_label);
784 	ev_timecode->add (timecode_format_label);
785 
786 	ev_dsp->show ();
787 	ev_path->show ();
788 	ev_audio->show ();
789 	ev_format->show ();
790 	ev_timecode->show ();
791 
792 #ifdef __APPLE__
793 	use_menubar_as_top_menubar ();
794 #else
795 	menu_hbox.pack_start (*menu_bar, false, false);
796 #endif
797 
798 	hbox->pack_end (error_alert_button, false, false, 2);
799 	hbox->pack_end (wall_clock_label, false, false, 10);
800 
801 	hbox->pack_end (*ev_dsp, false, false, 6);
802 	hbox->pack_end (disk_space_label, false, false, 6);
803 	hbox->pack_end (*ev_audio, false, false, 6);
804 	hbox->pack_end (*ev_timecode, false, false, 6);
805 	hbox->pack_end (*ev_format, false, false, 6);
806 	hbox->pack_end (peak_thread_work_label, false, false, 6);
807 	hbox->pack_end (*ev_name, false, false, 6);
808 	hbox->pack_end (*ev_path, false, false, 6);
809 
810 	menu_hbox.pack_end (*ev, true, true, 2);
811 
812 	menu_bar_base.set_name ("MainMenuBar");
813 	menu_bar_base.add (menu_hbox);
814 
815 	_status_bar_visibility.add (&session_path_label    ,X_("Path"),      _("Path to Session"), false);
816 	_status_bar_visibility.add (&snapshot_name_label   ,X_("Name"),      _("Snapshot Name and Modified Indicator"), false);
817 	_status_bar_visibility.add (&peak_thread_work_label,X_("Peakfile"),  _("Active Peak-file Work"), false);
818 	_status_bar_visibility.add (&format_label,          X_("Format"),    _("File Format"), false);
819 	_status_bar_visibility.add (&timecode_format_label, X_("TCFormat"),  _("Timecode Format"), false);
820 	_status_bar_visibility.add (&sample_rate_label,     X_("Audio"),     _("Audio"), true);
821 	_status_bar_visibility.add (&disk_space_label,      X_("Disk"),      _("Disk Space"), !Profile->get_small_screen());
822 	_status_bar_visibility.add (&dsp_load_label,        X_("DSP"),       _("DSP"), true);
823 #ifndef __APPLE__
824 	// OSX provides its own wallclock, thank you very much
825 	_status_bar_visibility.add (&wall_clock_label,      X_("WallClock"), _("Wall Clock"), false);
826 #endif
827 
828 	ev->signal_button_press_event().connect (sigc::mem_fun (_status_bar_visibility, &VisibilityGroup::button_press_event));
829 
830 	ev_dsp->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::xrun_button_press));
831 	ev_dsp->signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::xrun_button_release));
832 	ev_path->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::path_button_press));
833 	ev_name->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::path_button_press));
834 	ev_audio->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::audio_button_press));
835 	ev_format->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::format_button_press));
836 	ev_timecode->signal_button_press_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::timecode_button_press));
837 
838 	ArdourWidgets::set_tooltip (session_path_label, _("Double click to open session folder."));
839 	ArdourWidgets::set_tooltip (format_label, _("Double click to edit audio file format."));
840 	ArdourWidgets::set_tooltip (timecode_format_label, _("Double click to change timecode settings."));
841 	ArdourWidgets::set_tooltip (sample_rate_label, _("Double click to show audio/midi setup."));
842 }
843 
844 void
use_menubar_as_top_menubar()845 ARDOUR_UI::use_menubar_as_top_menubar ()
846 {
847 	Gtk::Widget* widget;
848 	Application* app = Application::instance ();
849 
850 	/* the addresses ("/ui/Main...") used below are based on the menu definitions in the menus file
851 	*/
852 
853 	/* Quit will be taken care of separately */
854 
855 	if ((widget = ActionManager::get_widget ("/ui/Main/Session/Quit"))) {
856 		widget->hide ();
857 	}
858 
859 	/* Put items for About and Preferences into App menu (the
860 	 * ardour.menus.in file does not list them for OS X)
861 	 */
862 
863 	GtkApplicationMenuGroup* group = app->add_app_menu_group ();
864 
865 	if ((widget = ActionManager::get_widget ("/ui/Main/Session/toggle-about"))) {
866 		app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
867 	}
868 
869 	if ((widget = ActionManager::get_widget ("/ui/Main/Edit/menu-show-preferences"))) {
870 		app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
871 	}
872 
873 	app->set_menu_bar (*menu_bar);
874 }
875 
876 void
save_ardour_state()877 ARDOUR_UI::save_ardour_state ()
878 {
879 	if (!keyboard || !mixer || !editor || !meterbridge) {
880 		return;
881 	}
882 
883 	/* XXX this is all a bit dubious. add_extra_xml() uses
884 	   a different lifetime model from add_instant_xml().
885 	*/
886 
887 	XMLNode* node = new XMLNode (keyboard->get_state());
888 	Config->add_extra_xml (*node);
889 
890 	XMLNode* window_node = new XMLNode (X_("UI"));
891 	window_node->set_property (_status_bar_visibility.get_state_name().c_str(), _status_bar_visibility.get_state_value ());
892 
893 	/* main window */
894 
895 	gint mx, my, mw, mh;
896 	_main_window.get_position (mx, my);
897 	_main_window.get_size (mw, mh);
898 
899 	XMLNode main_window_node (X_("Main"));
900 	main_window_node.set_property (X_("x"), mx);
901 	main_window_node.set_property (X_("y"), my);
902 	main_window_node.set_property (X_("w"), mw);
903 	main_window_node.set_property (X_("h"), mh);
904 
905 	string current_tab;
906 	int current_page_number = _tabs.get_current_page ();
907 	if (current_page_number == _tabs.page_num (editor->contents())) {
908 		current_tab = "editor";
909 	} else if (current_page_number == _tabs.page_num (mixer->contents())) {
910 		current_tab = "mixer";
911 	} else if (current_page_number == _tabs.page_num (recorder->contents())) {
912 		current_tab = "recorder";
913 	} else if (current_page_number == _tabs.page_num (rc_option_editor->contents())) {
914 		current_tab = "preferences";
915 	}
916 
917 	main_window_node.set_property (X_("current-tab"), current_tab);
918 
919 	/* Windows */
920 
921 	WM::Manager::instance().add_state (*window_node);
922 
923 	XMLNode* tearoff_node = new XMLNode (X_("Tearoffs"));
924 
925 	XMLNode* t = new XMLNode (X_("monitor-section"));
926 	mixer->monitor_section().tearoff().add_state (*t);
927 	tearoff_node->add_child_nocopy (*t);
928 
929 	window_node->add_child_nocopy (*tearoff_node);
930 
931 	XMLNode& enode (editor->get_state());
932 	XMLNode& mnode (mixer->get_state());
933 	XMLNode& bnode (meterbridge->get_state());
934 	XMLNode& pnode (rc_option_editor->get_state());
935 	XMLNode& rnode (recorder->get_state());
936 
937 	Config->add_extra_xml (*window_node);
938 	Config->add_extra_xml (audio_midi_setup->get_state());
939 
940 	Config->save_state();
941 
942 	mixer->save_plugin_order_file();
943 
944 	UIConfiguration::instance().save_state ();
945 
946 	if (_session) {
947 		_session->add_instant_xml (main_window_node);
948 		_session->add_instant_xml (enode);
949 		_session->add_instant_xml (mnode);
950 		_session->add_instant_xml (pnode);
951 		_session->add_instant_xml (bnode);
952 		_session->add_instant_xml (rnode);
953 		if (location_ui) {
954 			_session->add_instant_xml (location_ui->ui().get_state ());
955 		}
956 		if (virtual_keyboard_window) {
957 			XMLNode& vkstate (virtual_keyboard_window->get_state());
958 			vkstate.add_child_nocopy (virtual_keyboard_window.get_state ());
959 			_session->add_instant_xml (vkstate);
960 		}
961 	} else {
962 		Config->add_instant_xml (main_window_node);
963 		Config->add_instant_xml (enode);
964 		Config->add_instant_xml (mnode);
965 		Config->add_instant_xml (pnode);
966 		Config->add_instant_xml (bnode);
967 		Config->add_instant_xml (rnode);
968 		if (location_ui) {
969 			Config->add_instant_xml (location_ui->ui().get_state ());
970 		}
971 		if (virtual_keyboard_window) {
972 			XMLNode& vkstate (virtual_keyboard_window->get_state());
973 			vkstate.add_child_nocopy (virtual_keyboard_window.get_state ());
974 			_session->add_instant_xml (vkstate);
975 		}
976 	}
977 
978 	delete &enode;
979 	delete &mnode;
980 	delete &bnode;
981 	delete &pnode;
982 	delete &rnode;
983 
984 	Keyboard::save_keybindings ();
985 }
986 
987 void
on_theme_changed()988 ARDOUR_UI::on_theme_changed ()
989 {
990 	LV2Plugin::set_global_ui_background_color (UIConfiguration::instance().color ("gtk_background"));
991 	LV2Plugin::set_global_ui_foreground_color (UIConfiguration::instance().color ("gtk_foreground"));
992 	LV2Plugin::set_global_ui_contrasting_color (UIConfiguration::instance().color ("theme:contrasting clock")); // more contrast that "theme:contrasting"
993 	LV2Plugin::set_global_ui_scale_factor (UIConfiguration::instance().get_ui_scale());
994 	LV2Plugin::set_global_ui_style_boxy (UIConfiguration::instance().get_boxy_buttons());
995 	LV2Plugin::set_global_ui_style_flat (UIConfiguration::instance().get_flat_buttons());
996 }
997 
998 void
focus_on_clock()999 ARDOUR_UI::focus_on_clock ()
1000 {
1001 	if (primary_clock) {
1002 		primary_clock->focus ();
1003 	}
1004 }
1005 
1006 bool
xrun_button_press(GdkEventButton * ev)1007 ARDOUR_UI::xrun_button_press (GdkEventButton* ev)
1008 {
1009 	if (ev->button != 1 || ev->type != GDK_2BUTTON_PRESS) {
1010 		return false;
1011 	}
1012 	if (_session) {
1013 		_session->reset_xrun_count ();
1014 		update_cpu_load ();
1015 	}
1016 	return true;
1017 }
1018 
1019 bool
xrun_button_release(GdkEventButton * ev)1020 ARDOUR_UI::xrun_button_release (GdkEventButton* ev)
1021 {
1022 	if (ev->button != 1 || !Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
1023 		return false;
1024 	}
1025 
1026 	if (_session) {
1027 		_session->reset_xrun_count ();
1028 		update_cpu_load ();
1029 	}
1030 	return true;
1031 }
1032 
1033 bool
audio_button_press(GdkEventButton * ev)1034 ARDOUR_UI::audio_button_press (GdkEventButton* ev)
1035 {
1036   if (ev->button != 1 || ev->type != GDK_2BUTTON_PRESS) {
1037     return false;
1038   }
1039   audio_midi_setup->present ();
1040 	return true;
1041 }
1042 
1043 bool
path_button_press(GdkEventButton * ev)1044 ARDOUR_UI::path_button_press (GdkEventButton* ev)
1045 {
1046 	if (ev->button != 1 || ev->type != GDK_2BUTTON_PRESS) {
1047 		return false;
1048 	}
1049 
1050 	if (_session) {
1051 		PBD::open_folder (_session->path ());
1052 	}
1053 	return true;
1054 }
1055 
1056 Gtk::Notebook&
tabs()1057 ARDOUR_UI::tabs()
1058 {
1059 	return _tabs;
1060 }
1061 
1062 bool
tabbable_visibility_button_press(GdkEventButton * ev,string const & tabbable_name)1063 ARDOUR_UI::tabbable_visibility_button_press (GdkEventButton* ev, string const& tabbable_name)
1064 {
1065 	if (ev->button != 3) {
1066 		return false;
1067 	}
1068 
1069 	/* context menu is defined in *.menus.in
1070 	 */
1071 
1072 	string menu_name = string ("/ui/") + tabbable_name + X_("TabbableButtonMenu");
1073 	Gtk::Menu* menu = dynamic_cast<Gtk::Menu*> (ActionManager::get_widget (menu_name.c_str()));
1074 	if (menu) {
1075 		menu->popup (3, ev->time);
1076 	}
1077 	return true;
1078 }
1079