remove all tearoffs except the monitor section.
[ardour.git] / gtk2_ardour / ardour_ui_ed.cc
1 /*
2     Copyright (C) 20002-2004 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 #ifdef WAF_BUILD
21 #include "gtk2ardour-config.h"
22 #endif
23
24 /* This file contains any ARDOUR_UI methods that require knowledge of
25    the editor, and exists so that no compilation dependency exists
26    between the main ARDOUR_UI modules and the PublicEditor class. This
27    is to cut down on the nasty compile times for both these classes.
28 */
29
30 #include <cmath>
31
32 #include <glibmm/miscutils.h>
33 #include <gtk/gtk.h>
34
35 #include "gtkmm2ext/cairo_packer.h"
36 #include "gtkmm2ext/tearoff.h"
37 #include "gtkmm2ext/utils.h"
38 #include "gtkmm2ext/window_title.h"
39
40 #include "pbd/file_utils.h"
41 #include "pbd/fpu.h"
42 #include "pbd/convert.h"
43
44 #include "ardour_ui.h"
45 #include "public_editor.h"
46 #include "audio_clock.h"
47 #include "keyboard.h"
48 #include "monitor_section.h"
49 #include "engine_dialog.h"
50 #include "editor.h"
51 #include "actions.h"
52 #include "meterbridge.h"
53 #include "mixer_ui.h"
54 #include "startup.h"
55 #include "window_manager.h"
56 #include "global_port_matrix.h"
57 #include "location_ui.h"
58 #include "main_clock.h"
59
60 #include <gtkmm2ext/application.h>
61
62 #include "ardour/session.h"
63 #include "ardour/profile.h"
64 #include "ardour/audioengine.h"
65
66 #include "control_protocol/control_protocol.h"
67
68 #include "i18n.h"
69
70 using namespace std;
71 using namespace ARDOUR;
72 using namespace PBD;
73 using namespace Gtkmm2ext;
74 using namespace Gtk;
75 using namespace Glib;
76
77 int
78 ARDOUR_UI::create_editor ()
79 {
80         try {
81                 editor = new Editor ();
82                 editor->StateChange.connect (sigc::mem_fun (*this, &ARDOUR_UI::tabbable_state_change));
83         }
84
85         catch (failed_constructor& err) {
86                 return -1;
87         }
88
89         editor->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), editor));
90
91         return 0;
92 }
93
94 void
95 ARDOUR_UI::install_actions ()
96 {
97         Glib::RefPtr<ActionGroup> main_actions = ActionGroup::create (X_("Main"));
98         Glib::RefPtr<ActionGroup> main_menu_actions = ActionGroup::create (X_("Main_menu"));
99         Glib::RefPtr<Action> act;
100
101         /* menus + submenus that need action items */
102
103         ActionManager::register_action (main_menu_actions, X_("Session"), _("Session"));
104         act = ActionManager::register_action (main_menu_actions, X_("Cleanup"), _("Clean-up"));
105         ActionManager::write_sensitive_actions.push_back (act);
106         ActionManager::register_action (main_menu_actions, X_("Sync"), _("Sync"));
107         ActionManager::register_action (main_menu_actions, X_("TransportOptions"), _("Options"));
108         ActionManager::register_action (main_menu_actions, X_("WindowMenu"), _("Window"));
109         ActionManager::register_action (main_menu_actions, X_("MixerMenu"), _("Mixer"));
110         ActionManager::register_action (main_menu_actions, X_("EditorMenu"), _("Editor"));
111         ActionManager::register_action (main_menu_actions, X_("PrefsMenu"), _("Preferences"));
112         ActionManager::register_action (main_menu_actions, X_("DetachMenu"), _("Detach"));
113         ActionManager::register_action (main_menu_actions, X_("Help"), _("Help"));
114         ActionManager::register_action (main_menu_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
115         ActionManager::register_action (main_menu_actions, X_("AudioFileFormat"), _("Audio File Format"));
116         ActionManager::register_action (main_menu_actions, X_("AudioFileFormatHeader"), _("File Type"));
117         ActionManager::register_action (main_menu_actions, X_("AudioFileFormatData"), _("Sample Format"));
118         ActionManager::register_action (main_menu_actions, X_("ControlSurfaces"), _("Control Surfaces"));
119         ActionManager::register_action (main_menu_actions, X_("Plugins"), _("Plugins"));
120         ActionManager::register_action (main_menu_actions, X_("Metering"), _("Metering"));
121         ActionManager::register_action (main_menu_actions, X_("MeteringFallOffRate"), _("Fall Off Rate"));
122         ActionManager::register_action (main_menu_actions, X_("MeteringHoldTime"), _("Hold Time"));
123         ActionManager::register_action (main_menu_actions, X_("Denormals"), _("Denormal Handling"));
124
125         /* the real actions */
126
127         act = ActionManager::register_action (main_actions, X_("New"), _("New..."),  hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true, "")));
128
129         ActionManager::register_action (main_actions, X_("Open"), _("Open..."),  sigc::mem_fun(*this, &ARDOUR_UI::open_session));
130         ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."),  sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
131         act = ActionManager::register_action (main_actions, X_("Close"), _("Close"),  sigc::mem_fun(*this, &ARDOUR_UI::close_session));
132         ActionManager::session_sensitive_actions.push_back (act);
133
134         act = ActionManager::register_action (main_actions, X_("AddTrackBus"), _("Add Track or Bus..."),
135                                               sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_route), (Gtk::Window*) 0));
136         ActionManager::session_sensitive_actions.push_back (act);
137         ActionManager::write_sensitive_actions.push_back (act);
138
139         act = ActionManager::register_action (main_actions, X_("duplicate-routes"), _("Duplicate Tracks/Busses..."),
140                                               sigc::mem_fun(*this, &ARDOUR_UI::start_duplicate_routes));
141         ActionManager::session_sensitive_actions.push_back (act);
142         ActionManager::write_sensitive_actions.push_back (act);
143         ActionManager::track_selection_sensitive_actions.push_back (act);
144
145         act = ActionManager::register_action (main_actions, X_("cancel-solo"), _("Cancel Solo"), sigc::mem_fun(*this, &ARDOUR_UI::cancel_solo));
146         ActionManager::session_sensitive_actions.push_back (act);
147         ActionManager::write_sensitive_actions.push_back (act);
148
149
150         act = ActionManager::register_action (main_actions, X_("OpenVideo"), _("Open Video"),
151                                               sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_video), (Gtk::Window*) 0));
152         ActionManager::session_sensitive_actions.push_back (act);
153         act = ActionManager::register_action (main_actions, X_("CloseVideo"), _("Remove Video"),
154                                               sigc::mem_fun (*this, &ARDOUR_UI::remove_video));
155         act->set_sensitive (false);
156         act = ActionManager::register_action (main_actions, X_("ExportVideo"), _("Export to Video File"),
157                         hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::export_video), false)));
158         ActionManager::session_sensitive_actions.push_back (act);
159
160         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));
161         ActionManager::session_sensitive_actions.push_back (act);
162         ActionManager::write_sensitive_actions.push_back (act);
163
164         act = ActionManager::register_action (main_actions, X_("SnapshotSwitch"), _("Snapshot (& switch to new version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), true));
165         ActionManager::session_sensitive_actions.push_back (act);
166         ActionManager::write_sensitive_actions.push_back (act);
167
168         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));
169         ActionManager::session_sensitive_actions.push_back (act);
170         ActionManager::write_sensitive_actions.push_back (act);
171
172         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));
173         ActionManager::session_sensitive_actions.push_back (act);
174         ActionManager::write_sensitive_actions.push_back (act);
175
176         act = ActionManager::register_action (main_actions, X_("SaveAs"), _("Save As..."), sigc::mem_fun(*this, &ARDOUR_UI::save_session_as));
177         ActionManager::session_sensitive_actions.push_back (act);
178         ActionManager::write_sensitive_actions.push_back (act);
179
180         act = ActionManager::register_action (main_actions, X_("Rename"), _("Rename..."), sigc::mem_fun(*this, &ARDOUR_UI::rename_session));
181         ActionManager::session_sensitive_actions.push_back (act);
182         ActionManager::write_sensitive_actions.push_back (act);
183
184         act = ActionManager::register_action (main_actions, X_("SaveTemplate"), _("Save Template..."),  sigc::mem_fun(*this, &ARDOUR_UI::save_template));
185         ActionManager::session_sensitive_actions.push_back (act);
186
187         act = ActionManager::register_action (main_actions, X_("Metadata"), _("Metadata"));
188         ActionManager::session_sensitive_actions.push_back (act);
189
190         act = ActionManager::register_action (main_actions, X_("EditMetadata"), _("Edit Metadata..."),  sigc::mem_fun(*this, &ARDOUR_UI::edit_metadata));
191         ActionManager::session_sensitive_actions.push_back (act);
192
193         act = ActionManager::register_action (main_actions, X_("ImportMetadata"), _("Import Metadata..."),  sigc::mem_fun(*this, &ARDOUR_UI::import_metadata));
194         ActionManager::session_sensitive_actions.push_back (act);
195
196         act = ActionManager::register_action (main_actions, X_("ExportAudio"), _("Export to Audio File(s)..."),  sigc::mem_fun (*editor, &PublicEditor::export_audio));
197         ActionManager::session_sensitive_actions.push_back (act);
198
199         act = ActionManager::register_action (main_actions, X_("StemExport"), _("Stem export..."),  sigc::mem_fun (*editor, &PublicEditor::stem_export));
200         ActionManager::session_sensitive_actions.push_back (act);
201
202         act = ActionManager::register_action (main_actions, X_("Export"), _("Export"));
203         ActionManager::session_sensitive_actions.push_back (act);
204
205         act = ActionManager::register_action (main_actions, X_("CleanupUnused"), _("Clean-up Unused Sources..."),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup));
206         ActionManager::session_sensitive_actions.push_back (act);
207         ActionManager::write_sensitive_actions.push_back (act);
208
209         act = ActionManager::register_action (main_actions, X_("CleanupPeakFiles"), _("Reset Peak Files"),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup_peakfiles));
210         ActionManager::session_sensitive_actions.push_back (act);
211         ActionManager::write_sensitive_actions.push_back (act);
212
213         act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"),  sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
214         ActionManager::write_sensitive_actions.push_back (act);
215         ActionManager::session_sensitive_actions.push_back (act);
216
217         /* these actions are intended to be shared across all windows */
218
219         common_actions = ActionGroup::create (X_("Common"));
220         ActionManager::register_action (common_actions, X_("Quit"), _("Quit"), (hide_return (sigc::mem_fun(*this, &ARDOUR_UI::finish))));
221         ActionManager::register_action (common_actions, X_("Hide"), _("Hide"), sigc::mem_fun (*this, &ARDOUR_UI::hide_application));
222
223         ActionManager::register_action (common_actions, X_("show-editor"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), editor));
224         ActionManager::register_action (common_actions, X_("show-mixer"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), mixer));
225         ActionManager::register_action (common_actions, X_("show-preferences"), _("Show"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::show_tabbable), rc_option_editor));
226
227         ActionManager::register_action (common_actions, X_("hide-editor"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), editor));
228         ActionManager::register_action (common_actions, X_("hide-mixer"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), mixer));
229         ActionManager::register_action (common_actions, X_("hide-preferences"), _("Hide"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::hide_tabbable), rc_option_editor));
230         
231         ActionManager::register_action (common_actions, X_("attach-editor"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), editor));
232         ActionManager::register_action (common_actions, X_("attach-mixer"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), mixer));
233         ActionManager::register_action (common_actions, X_("attach-preferences"), _("Attach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::attach_tabbable), rc_option_editor));
234         
235         ActionManager::register_action (common_actions, X_("detach-editor"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), editor));
236         ActionManager::register_action (common_actions, X_("detach-mixer"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), mixer));
237         ActionManager::register_action (common_actions, X_("detach-preferences"), _("Detach"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::detach_tabbable), rc_option_editor));
238
239         /* windows visibility actions */
240
241         ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalEditor"), _("Maximise Editor Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_editing_space));
242         ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalMixer"), _("Maximise Mixer Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_mixer_space));
243         ActionManager::session_sensitive_actions.push_back (act);
244
245         act = ActionManager::register_toggle_action (common_actions, X_("ToggleMixerList"), _("Toggle Mixer List"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_mixer_list));
246         ActionManager::session_sensitive_actions.push_back (act);
247
248         act = ActionManager::register_toggle_action (common_actions, X_("ToggleMonitorSection"), _("Toggle Monitor Section Visibility"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_monitor_section_visibility));
249         act->set_sensitive (false);
250
251 if (Profile->get_mixbus())
252         ActionManager::register_action (common_actions, X_("show-ui-prefs"), _("Show more UI preferences"), sigc::mem_fun (*this, &ARDOUR_UI::show_ui_prefs));
253
254         ActionManager::register_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"),  sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge));
255
256         act = ActionManager::register_action (common_actions, X_("NewMIDITracer"), _("MIDI Tracer"), sigc::mem_fun(*this, &ARDOUR_UI::new_midi_tracer_window));
257         ActionManager::session_sensitive_actions.push_back (act);
258         ActionManager::register_action (common_actions, X_("chat"), _("Chat"),  sigc::mem_fun(*this, &ARDOUR_UI::launch_chat));
259         /** TRANSLATORS: This is `Manual' in the sense of an instruction book that tells a user how to use Ardour */
260         ActionManager::register_action (common_actions, X_("manual"), S_("Help|Manual"),  mem_fun(*this, &ARDOUR_UI::launch_manual));
261         ActionManager::register_action (common_actions, X_("reference"), S_("Manual|Reference"),  mem_fun(*this, &ARDOUR_UI::launch_reference));
262         ActionManager::register_action (common_actions, X_("tracker"), _("Report a Bug"), mem_fun(*this, &ARDOUR_UI::launch_tracker));
263         ActionManager::register_action (common_actions, X_("cheat-sheet"), _("Cheat Sheet"), mem_fun(*this, &ARDOUR_UI::launch_cheat_sheet));
264         ActionManager::register_action (common_actions, X_("website"), _("Ardour Website"), mem_fun(*this, &ARDOUR_UI::launch_website));
265         ActionManager::register_action (common_actions, X_("website-dev"), _("Ardour Development"), mem_fun(*this, &ARDOUR_UI::launch_website_dev));
266         ActionManager::register_action (common_actions, X_("forums"), _("User Forums"), mem_fun(*this, &ARDOUR_UI::launch_forums));
267         ActionManager::register_action (common_actions, X_("howto-report"), _("How to Report a Bug"), mem_fun(*this, &ARDOUR_UI::launch_howto_report));
268
269         act = ActionManager::register_action (common_actions, X_("Save"), _("Save"),  sigc::hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""), false)));
270         ActionManager::session_sensitive_actions.push_back (act);
271         ActionManager::write_sensitive_actions.push_back (act);
272
273         Glib::RefPtr<ActionGroup> transport_actions = ActionGroup::create (X_("Transport"));
274
275         /* do-nothing action for the "transport" menu bar item */
276
277         ActionManager::register_action (transport_actions, X_("Transport"), _("Transport"));
278
279         /* these two are not used by key bindings, instead use ToggleRoll for that. these two do show up in
280            menus and via button proxies.
281         */
282
283         act = ActionManager::register_action (transport_actions, X_("Stop"), _("Stop"), sigc::mem_fun(*this, &ARDOUR_UI::transport_stop));
284         ActionManager::session_sensitive_actions.push_back (act);
285         ActionManager::transport_sensitive_actions.push_back (act);
286         act = ActionManager::register_action (transport_actions, X_("Roll"), _("Roll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_roll));
287         ActionManager::session_sensitive_actions.push_back (act);
288         ActionManager::transport_sensitive_actions.push_back (act);
289
290         act = ActionManager::register_action (transport_actions, X_("ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
291         ActionManager::session_sensitive_actions.push_back (act);
292         ActionManager::transport_sensitive_actions.push_back (act);
293         act = ActionManager::register_action (transport_actions, X_("alternate-ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
294         ActionManager::session_sensitive_actions.push_back (act);
295         ActionManager::transport_sensitive_actions.push_back (act);
296         act = ActionManager::register_action (transport_actions, X_("ToggleRollMaybe"), _("Start/Continue/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, true));
297         ActionManager::session_sensitive_actions.push_back (act);
298         ActionManager::transport_sensitive_actions.push_back (act);
299         act = ActionManager::register_action (transport_actions, X_("ToggleRollForgetCapture"), _("Stop and Forget Capture"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_roll), true, false));
300         ActionManager::session_sensitive_actions.push_back (act);
301         ActionManager::transport_sensitive_actions.push_back (act);
302
303         /* these two behave as follows:
304
305            - if transport speed != 1.0 or != -1.0, change speed to 1.0 or -1.0 (respectively)
306            - otherwise do nothing
307         */
308
309         act = ActionManager::register_action (transport_actions, X_("TransitionToRoll"), _("Transition to Roll"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), true));
310         ActionManager::session_sensitive_actions.push_back (act);
311         ActionManager::transport_sensitive_actions.push_back (act);
312
313         act = ActionManager::register_action (transport_actions, X_("TransitionToReverse"), _("Transition to Reverse"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), false));
314         ActionManager::session_sensitive_actions.push_back (act);
315         ActionManager::transport_sensitive_actions.push_back (act);
316
317         act = ActionManager::register_action (transport_actions, X_("Loop"), _("Play Loop Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
318         ActionManager::session_sensitive_actions.push_back (act);
319         ActionManager::transport_sensitive_actions.push_back (act);
320         act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selection"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
321         ActionManager::session_sensitive_actions.push_back (act);
322         ActionManager::transport_sensitive_actions.push_back (act);
323         act = ActionManager::register_action (transport_actions, X_("PlayPreroll"), _("Play Selection w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_preroll));
324         ActionManager::session_sensitive_actions.push_back (act);
325         ActionManager::transport_sensitive_actions.push_back (act);
326
327         act = ActionManager::register_action (transport_actions, X_("Record"), _("Enable Record"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), false));
328         ActionManager::session_sensitive_actions.push_back (act);
329         ActionManager::write_sensitive_actions.push_back (act);
330         act = ActionManager::register_action (transport_actions, X_("record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
331         ActionManager::session_sensitive_actions.push_back (act);
332         ActionManager::write_sensitive_actions.push_back (act);
333         ActionManager::transport_sensitive_actions.push_back (act);
334         act = ActionManager::register_action (transport_actions, X_("alternate-record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
335         ActionManager::session_sensitive_actions.push_back (act);
336         ActionManager::write_sensitive_actions.push_back (act);
337         ActionManager::transport_sensitive_actions.push_back (act);
338         act = ActionManager::register_action (transport_actions, X_("Rewind"), _("Rewind"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 0));
339         ActionManager::session_sensitive_actions.push_back (act);
340         ActionManager::transport_sensitive_actions.push_back (act);
341         act = ActionManager::register_action (transport_actions, X_("RewindSlow"), _("Rewind (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), -1));
342         ActionManager::session_sensitive_actions.push_back (act);
343         ActionManager::transport_sensitive_actions.push_back (act);
344         act = ActionManager::register_action (transport_actions, X_("RewindFast"), _("Rewind (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 1));
345         ActionManager::session_sensitive_actions.push_back (act);
346         ActionManager::transport_sensitive_actions.push_back (act);
347         act = ActionManager::register_action (transport_actions, X_("Forward"), _("Forward"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 0));
348         ActionManager::session_sensitive_actions.push_back (act);
349         ActionManager::transport_sensitive_actions.push_back (act);
350         act = ActionManager::register_action (transport_actions, X_("ForwardSlow"), _("Forward (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), -1));
351         ActionManager::session_sensitive_actions.push_back (act);
352         ActionManager::transport_sensitive_actions.push_back (act);
353         act = ActionManager::register_action (transport_actions, X_("ForwardFast"), _("Forward (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 1));
354         ActionManager::session_sensitive_actions.push_back (act);
355         ActionManager::transport_sensitive_actions.push_back (act);
356         act = ActionManager::register_action (transport_actions, X_("GotoZero"), _("Go to Zero"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_zero));
357         ActionManager::session_sensitive_actions.push_back (act);
358         ActionManager::transport_sensitive_actions.push_back (act);
359         act = ActionManager::register_action (transport_actions, X_("GotoStart"), _("Go to Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
360         ActionManager::session_sensitive_actions.push_back (act);
361         ActionManager::transport_sensitive_actions.push_back (act);
362         act = ActionManager::register_action (transport_actions, X_("alternate-GotoStart"), _("Go to Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
363         ActionManager::session_sensitive_actions.push_back (act);
364         ActionManager::transport_sensitive_actions.push_back (act);
365         act = ActionManager::register_action (transport_actions, X_("GotoEnd"), _("Go to End"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_end));
366         ActionManager::session_sensitive_actions.push_back (act);
367         ActionManager::transport_sensitive_actions.push_back (act);
368         act = ActionManager::register_action (transport_actions, X_("GotoWallClock"), _("Go to Wall Clock"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_wallclock));
369         ActionManager::session_sensitive_actions.push_back (act);
370         ActionManager::transport_sensitive_actions.push_back (act);
371
372         //these actions handle the numpad events, ProTools style
373         act = ActionManager::register_action (transport_actions, X_("numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
374         ActionManager::session_sensitive_actions.push_back (act);
375         ActionManager::transport_sensitive_actions.push_back (act);
376         act = ActionManager::register_action (transport_actions, X_("alternate-numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
377         ActionManager::session_sensitive_actions.push_back (act);
378         ActionManager::transport_sensitive_actions.push_back (act);
379         act = ActionManager::register_action (transport_actions, X_("numpad-0"), _("Numpad 0"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 0));
380         ActionManager::session_sensitive_actions.push_back (act);
381         ActionManager::transport_sensitive_actions.push_back (act);
382         act = ActionManager::register_action (transport_actions, X_("numpad-1"), _("Numpad 1"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 1));
383         ActionManager::session_sensitive_actions.push_back (act);
384         ActionManager::transport_sensitive_actions.push_back (act);
385         act = ActionManager::register_action (transport_actions, X_("numpad-2"), _("Numpad 2"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 2));
386         ActionManager::session_sensitive_actions.push_back (act);
387         ActionManager::transport_sensitive_actions.push_back (act);
388         act = ActionManager::register_action (transport_actions, X_("numpad-3"), _("Numpad 3"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 3));
389         ActionManager::session_sensitive_actions.push_back (act);
390         ActionManager::transport_sensitive_actions.push_back (act);
391         act = ActionManager::register_action (transport_actions, X_("numpad-4"), _("Numpad 4"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 4));
392         ActionManager::session_sensitive_actions.push_back (act);
393         ActionManager::transport_sensitive_actions.push_back (act);
394         act = ActionManager::register_action (transport_actions, X_("numpad-5"), _("Numpad 5"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 5));
395         ActionManager::session_sensitive_actions.push_back (act);
396         ActionManager::transport_sensitive_actions.push_back (act);
397         act = ActionManager::register_action (transport_actions, X_("numpad-6"), _("Numpad 6"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 6));
398         ActionManager::session_sensitive_actions.push_back (act);
399         ActionManager::transport_sensitive_actions.push_back (act);
400         act = ActionManager::register_action (transport_actions, X_("numpad-7"), _("Numpad 7"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 7));
401         ActionManager::session_sensitive_actions.push_back (act);
402         ActionManager::transport_sensitive_actions.push_back (act);
403         act = ActionManager::register_action (transport_actions, X_("numpad-8"), _("Numpad 8"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 8));
404         ActionManager::session_sensitive_actions.push_back (act);
405         ActionManager::transport_sensitive_actions.push_back (act);
406         act = ActionManager::register_action (transport_actions, X_("numpad-9"), _("Numpad 9"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 9));
407         ActionManager::session_sensitive_actions.push_back (act);
408         ActionManager::transport_sensitive_actions.push_back (act);
409
410         act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(*this, &ARDOUR_UI::focus_on_clock));
411         ActionManager::session_sensitive_actions.push_back (act);
412         ActionManager::transport_sensitive_actions.push_back (act);
413
414         act = ActionManager::register_action (transport_actions, X_("primary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Timecode));
415         ActionManager::session_sensitive_actions.push_back (act);
416         act = ActionManager::register_action (transport_actions, X_("primary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::BBT));
417         ActionManager::session_sensitive_actions.push_back (act);
418         act = ActionManager::register_action (transport_actions, X_("primary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::MinSec));
419         ActionManager::session_sensitive_actions.push_back (act);
420         act = ActionManager::register_action (transport_actions, X_("primary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Frames));
421         ActionManager::session_sensitive_actions.push_back (act);
422
423         act = ActionManager::register_action (transport_actions, X_("secondary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Timecode));
424         ActionManager::session_sensitive_actions.push_back (act);
425         act = ActionManager::register_action (transport_actions, X_("secondary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::BBT));
426         ActionManager::session_sensitive_actions.push_back (act);
427         act = ActionManager::register_action (transport_actions, X_("secondary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::MinSec));
428         ActionManager::session_sensitive_actions.push_back (act);
429         act = ActionManager::register_action (transport_actions, X_("secondary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Frames));
430         ActionManager::session_sensitive_actions.push_back (act);
431
432         act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
433         act->set_short_label (_("In"));
434         ActionManager::session_sensitive_actions.push_back (act);
435         ActionManager::transport_sensitive_actions.push_back (act);
436         act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchOut"), _("Punch Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_out));
437         act->set_short_label (_("Out"));
438         ActionManager::session_sensitive_actions.push_back (act);
439         ActionManager::transport_sensitive_actions.push_back (act);
440         act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunch"), _("Punch In/Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch));
441         act->set_short_label (_("In/Out"));
442         ActionManager::session_sensitive_actions.push_back (act);
443         ActionManager::transport_sensitive_actions.push_back (act);
444         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleClick"), _("Click"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_click));
445         ActionManager::session_sensitive_actions.push_back (act);
446         ActionManager::transport_sensitive_actions.push_back (act);
447         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoInput"), _("Auto Input"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_input));
448         ActionManager::session_sensitive_actions.push_back (act);
449         ActionManager::transport_sensitive_actions.push_back (act);
450         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoPlay"), _("Auto Play"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_play));
451         ActionManager::session_sensitive_actions.push_back (act);
452         ActionManager::transport_sensitive_actions.push_back (act);
453         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoReturn"), _("Auto Return"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_return));
454         ActionManager::session_sensitive_actions.push_back (act);
455         ActionManager::transport_sensitive_actions.push_back (act);
456         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleFollowEdits"), _("Follow Edits"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_follow_edits));
457         ActionManager::session_sensitive_actions.push_back (act);
458         ActionManager::transport_sensitive_actions.push_back (act);
459
460
461         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync Startup to Video"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_video_sync));
462         ActionManager::session_sensitive_actions.push_back (act);
463         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleTimeMaster"), _("Time Master"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_time_master));
464         ActionManager::session_sensitive_actions.push_back (act);
465         act = ActionManager::register_toggle_action (transport_actions, X_("ToggleExternalSync"), _("Use External Positional Sync Source"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_external_sync));
466         ActionManager::session_sensitive_actions.push_back (act);
467
468         for (int i = 1; i <= 32; ++i) {
469                 string const a = string_compose (X_("ToggleRecordEnableTrack%1"), i);
470                 string const n = string_compose (_("Toggle Record Enable Track %1"), i);
471                 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));
472                 ActionManager::session_sensitive_actions.push_back (act);
473         }
474
475         Glib::RefPtr<ActionGroup> shuttle_actions = ActionGroup::create ("ShuttleActions");
476
477         shuttle_actions->add (Action::create (X_("SetShuttleUnitsPercentage"), _("Percentage")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Percentage)));
478         shuttle_actions->add (Action::create (X_("SetShuttleUnitsSemitones"), _("Semitones")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Semitones)));
479
480         Glib::RefPtr<ActionGroup> option_actions = ActionGroup::create ("options");
481
482         act = ActionManager::register_toggle_action (option_actions, X_("SendMTC"), _("Send MTC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mtc));
483         ActionManager::session_sensitive_actions.push_back (act);
484         act = ActionManager::register_toggle_action (option_actions, X_("SendMMC"), _("Send MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mmc));
485         ActionManager::session_sensitive_actions.push_back (act);
486         act = ActionManager::register_toggle_action (option_actions, X_("UseMMC"), _("Use MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_use_mmc));
487         ActionManager::session_sensitive_actions.push_back (act);
488         act = ActionManager::register_toggle_action (option_actions, X_("SendMidiClock"), _("Send MIDI Clock"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_clock));
489         ActionManager::session_sensitive_actions.push_back (act);
490         act = ActionManager::register_toggle_action (option_actions, X_("SendMIDIfeedback"), _("Send MIDI Feedback"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_feedback));
491         ActionManager::session_sensitive_actions.push_back (act);
492
493         /* MIDI */
494
495         Glib::RefPtr<ActionGroup> midi_actions = ActionGroup::create (X_("MIDI"));
496         ActionManager::register_action (midi_actions, X_("panic"), _("Panic"), sigc::mem_fun(*this, &ARDOUR_UI::midi_panic));
497
498         ActionManager::add_action_group (shuttle_actions);
499         ActionManager::add_action_group (option_actions);
500         ActionManager::add_action_group (transport_actions);
501         ActionManager::add_action_group (main_actions);
502         ActionManager::add_action_group (main_menu_actions);
503         ActionManager::add_action_group (common_actions);
504         ActionManager::add_action_group (midi_actions);
505 }
506
507 void
508 ARDOUR_UI::build_menu_bar ()
509 {
510         menu_bar = dynamic_cast<MenuBar*> (ActionManager::get_widget (X_("/Main")));
511         menu_bar->set_name ("MainMenuBar");
512
513         /*
514          * This is needed because this property does not get installed
515          * until the Menu GObject class is registered, which happens
516          * when the first menu instance is created.
517          */
518         // XXX bug in gtkmm causes this to popup an error message
519         // Gtk::Settings::get_default()->property_gtk_can_change_accels() = true;
520         // so use this instead ...
521         gtk_settings_set_long_property (gtk_settings_get_default(), "gtk-can-change-accels", 1, "Ardour:designers");
522
523         EventBox* ev = manage (new EventBox);
524         ev->show ();
525         CairoHPacker* hbox = manage (new CairoHPacker);
526         hbox->set_name (X_("StatusBarBox"));
527         hbox->show ();
528         hbox->set_border_width (3);
529
530         VBox* vbox = manage (new VBox);
531         vbox->pack_start (*hbox, true, false);
532         vbox->show();
533
534         ev->add (*vbox);
535
536         wall_clock_label.set_name ("WallClock");
537         wall_clock_label.set_use_markup ();
538         disk_space_label.set_name ("WallClock");
539         disk_space_label.set_use_markup ();
540         timecode_format_label.set_name ("WallClock");
541         timecode_format_label.set_use_markup ();
542         cpu_load_label.set_name ("CPULoad");
543         cpu_load_label.set_use_markup ();
544         xrun_label.set_name ("XrunLabel");
545         xrun_label.set_use_markup ();
546         peak_thread_work_label.set_name ("PeakThreadWork");
547         peak_thread_work_label.set_use_markup ();
548         buffer_load_label.set_name ("BufferLoad");
549         buffer_load_label.set_use_markup ();
550         sample_rate_label.set_name ("SampleRate");
551         sample_rate_label.set_use_markup ();
552         format_label.set_name ("Format");
553         format_label.set_use_markup ();
554
555 #ifndef TOP_MENUBAR
556         menu_hbox.pack_start (*menu_bar, false, false);
557 #else
558         use_menubar_as_top_menubar ();
559 #endif
560
561         bool wall_clock = false;
562         bool disk_space = false;
563
564         if (!Profile->get_small_screen()) {
565 #ifndef GTKOSX
566                 // OSX provides its own wallclock, thank you very much
567                 wall_clock = true;
568 #endif
569                 disk_space = true;
570         }
571
572         hbox->pack_end (error_alert_button, false, false, 2);
573
574         hbox->pack_end (wall_clock_label, false, false, 2);
575         hbox->pack_end (disk_space_label, false, false, 4);
576         hbox->pack_end (xrun_label, false, false, 4);
577         hbox->pack_end (peak_thread_work_label, false, false, 4);
578         hbox->pack_end (cpu_load_label, false, false, 4);
579         hbox->pack_end (buffer_load_label, false, false, 4);
580         hbox->pack_end (sample_rate_label, false, false, 4);
581         hbox->pack_end (timecode_format_label, false, false, 4);
582         hbox->pack_end (format_label, false, false, 4);
583
584         menu_hbox.pack_end (*ev, false, false, 2);
585
586         menu_bar_base.set_name ("MainMenuBar");
587         menu_bar_base.add (menu_hbox);
588
589 #ifndef GTKOSX
590         _status_bar_visibility.add (&wall_clock_label,      X_("WallClock"), _("Wall Clock"), wall_clock);
591 #endif
592         _status_bar_visibility.add (&disk_space_label,      X_("Disk"),      _("Disk Space"), disk_space);
593         _status_bar_visibility.add (&cpu_load_label,        X_("DSP"),       _("DSP"), true);
594         _status_bar_visibility.add (&xrun_label,            X_("XRun"),      _("X-run"), false);
595         _status_bar_visibility.add (&peak_thread_work_label,X_("Peakfile"),  _("Active Peak-file Work"), false);
596         _status_bar_visibility.add (&buffer_load_label,     X_("Buffers"),   _("Buffers"), true);
597         _status_bar_visibility.add (&sample_rate_label,     X_("Audio"),     _("Audio"), true);
598         _status_bar_visibility.add (&timecode_format_label, X_("TCFormat"),  _("Timecode Format"), true);
599         _status_bar_visibility.add (&format_label,          X_("Format"),    _("File Format"), true);
600
601         ev->signal_button_press_event().connect (sigc::mem_fun (_status_bar_visibility, &VisibilityGroup::button_press_event));
602         ev->signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::xrun_button_release));
603 }
604
605 void
606 ARDOUR_UI::use_menubar_as_top_menubar ()
607 {
608         Gtk::Widget* widget;
609         Application* app = Application::instance ();
610
611         /* the addresses ("/ui/Main...") used below are based on the menu definitions in the menus file
612          */
613
614         /* Quit will be taken care of separately */
615
616         if ((widget = ActionManager::get_widget ("/ui/Main/Session/Quit"))) {
617                 widget->hide ();
618         }
619
620         /* Put items for About and Preferences into App menu (the
621          * ardour.menus.in file does not list them for OS X)
622          */
623
624         GtkApplicationMenuGroup* group = app->add_app_menu_group ();
625
626         if ((widget = ActionManager::get_widget ("/ui/Main/Session/toggle-about"))) {
627                 app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
628         }
629
630         if ((widget = ActionManager::get_widget ("/ui/Main/Session/toggle-rc-options-editor"))) {
631                 app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
632         }
633
634         app->set_menu_bar (*menu_bar);
635 }
636
637 void
638 ARDOUR_UI::save_ardour_state ()
639 {
640         if (!keyboard || !mixer || !editor || !meterbridge) {
641                 return;
642         }
643
644         /* XXX this is all a bit dubious. add_extra_xml() uses
645            a different lifetime model from add_instant_xml().
646         */
647
648         XMLNode* node = new XMLNode (keyboard->get_state());
649         Config->add_extra_xml (*node);
650         Config->add_extra_xml (get_transport_controllable_state());
651
652         XMLNode* window_node = new XMLNode (X_("UI"));
653         window_node->add_property (_status_bar_visibility.get_state_name().c_str(), _status_bar_visibility.get_state_value ());
654
655         /* main window */
656
657         gint mx, my, mw, mh;
658         _main_window.get_position (mx, my);
659         _main_window.get_size (mw, mh);
660
661         XMLNode main_window_node (X_("Main"));
662         main_window_node.add_property (X_("x"), PBD::to_string (mx, std::dec));
663         main_window_node.add_property (X_("y"), PBD::to_string (my, std::dec));
664         main_window_node.add_property (X_("w"), PBD::to_string (mw, std::dec));
665         main_window_node.add_property (X_("h"), PBD::to_string (mh, std::dec));
666
667         string current_tab;
668         int current_page_number = _tabs.get_current_page ();
669         if (editor && (current_page_number == _tabs.page_num (editor->contents()))) {
670                 current_tab = "editor";
671         } else if (mixer && (current_page_number == _tabs.page_num (mixer->contents()))) {
672                 current_tab = "mixer";
673         } else if (rc_option_editor && (current_page_number == _tabs.page_num (rc_option_editor->contents()))) {
674                 current_tab == "preferences";
675         }
676
677         main_window_node.add_property (X_("current-tab"), current_tab);
678         
679         /* Windows */
680
681         WM::Manager::instance().add_state (*window_node);
682
683         XMLNode* tearoff_node = new XMLNode (X_("Tearoffs"));
684
685         if (mixer->monitor_section()) {
686                 XMLNode* t = new XMLNode (X_("monitor-section"));
687                 mixer->monitor_section()->tearoff().add_state (*t);
688                 tearoff_node->add_child_nocopy (*t);
689         }
690
691         window_node->add_child_nocopy (*tearoff_node);
692
693         XMLNode& enode (editor->get_state());
694         XMLNode& mnode (mixer->get_state());
695         XMLNode& bnode (meterbridge->get_state());
696
697         Config->add_extra_xml (*window_node);
698         Config->add_extra_xml (audio_midi_setup->get_state());
699
700         Config->save_state();
701
702         UIConfiguration::instance().save_state ();
703
704         if (_session) {
705                 _session->add_instant_xml (main_window_node);
706                 _session->add_instant_xml (enode);
707                 _session->add_instant_xml (mnode);
708                 _session->add_instant_xml (bnode);
709                 if (location_ui) {
710                         _session->add_instant_xml (location_ui->ui().get_state ());
711                 }
712         } else {
713                 Config->add_instant_xml (main_window_node);
714                 Config->add_instant_xml (enode);
715                 Config->add_instant_xml (mnode);
716                 Config->add_instant_xml (bnode);
717                 if (location_ui) {
718                         Config->add_instant_xml (location_ui->ui().get_state ());
719                 }
720         }
721         delete &enode;
722
723         Keyboard::save_keybindings ();
724 }
725
726 void
727 ARDOUR_UI::resize_text_widgets ()
728 {
729         set_size_request_to_display_given_text (cpu_load_label, "DSP: 100.0%", 2, 2);
730         set_size_request_to_display_given_text (buffer_load_label, "Buffers: p:100% c:100%", 2, 2);
731         set_size_request_to_display_given_text (xrun_label, "X: 9999", 2, 2);
732 }
733
734 void
735 ARDOUR_UI::focus_on_clock ()
736 {
737         if (editor && primary_clock) {
738                 editor->present ();
739                 primary_clock->focus ();
740         }
741 }
742
743 bool
744 ARDOUR_UI::xrun_button_release (GdkEventButton* ev)
745 {
746         if (ev->button != 1 || !Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
747                 return false;
748         }
749
750         if (_session) {
751                 _session->reset_xrun_count ();
752                 update_xrun_count ();
753         }
754         return true;
755 }
756
757 Gtk::Notebook&
758 ARDOUR_UI::tabs()
759 {
760         return _tabs;
761 }