2 Copyright (C) 20002-2004 Paul Davis
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.
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.
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.
21 #include "gtk2ardour-config.h"
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.
32 #include <glibmm/miscutils.h>
35 #include "gtkmm2ext/utils.h"
36 #include "gtkmm2ext/window_title.h"
37 #include "gtkmm2ext/tearoff.h"
38 #include "gtkmm2ext/cairo_packer.h"
40 #include "pbd/file_utils.h"
42 #include "pbd/convert.h"
44 #include "ardour_ui.h"
45 #include "public_editor.h"
46 #include "audio_clock.h"
48 #include "monitor_section.h"
49 #include "engine_dialog.h"
55 #include "window_proxy.h"
56 #include "global_port_matrix.h"
57 #include "location_ui.h"
59 #include <gtkmm2ext/application.h>
61 #include "ardour/session.h"
62 #include "ardour/profile.h"
63 #include "ardour/audioengine.h"
64 #include "ardour/control_protocol_manager.h"
66 #include "control_protocol/control_protocol.h"
71 using namespace ARDOUR;
73 using namespace Gtkmm2ext;
78 ARDOUR_UI::create_editor ()
81 editor = new Editor ();
84 catch (failed_constructor& err) {
88 editor->Realized.connect (sigc::mem_fun (*this, &ARDOUR_UI::editor_realized));
89 editor->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), true));
95 ARDOUR_UI::install_actions ()
97 Glib::RefPtr<ActionGroup> main_actions = ActionGroup::create (X_("Main"));
98 Glib::RefPtr<Action> act;
100 /* menus + submenus that need action items */
102 ActionManager::register_action (main_actions, X_("Session"), _("Session"));
103 act = ActionManager::register_action (main_actions, X_("Cleanup"), _("Clean-up"));
104 ActionManager::write_sensitive_actions.push_back (act);
105 ActionManager::register_action (main_actions, X_("Sync"), _("Sync"));
106 ActionManager::register_action (main_actions, X_("TransportOptions"), _("Options"));
107 ActionManager::register_action (main_actions, X_("Help"), _("Help"));
108 ActionManager::register_action (main_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
109 ActionManager::register_action (main_actions, X_("AudioFileFormat"), _("Audio File Format"));
110 ActionManager::register_action (main_actions, X_("AudioFileFormatHeader"), _("File Type"));
111 ActionManager::register_action (main_actions, X_("AudioFileFormatData"), _("Sample Format"));
112 ActionManager::register_action (main_actions, X_("ControlSurfaces"), _("Control Surfaces"));
113 ActionManager::register_action (main_actions, X_("Plugins"), _("Plugins"));
114 ActionManager::register_action (main_actions, X_("Metering"), _("Metering"));
115 ActionManager::register_action (main_actions, X_("MeteringFallOffRate"), _("Fall Off Rate"));
116 ActionManager::register_action (main_actions, X_("MeteringHoldTime"), _("Hold Time"));
117 ActionManager::register_action (main_actions, X_("Denormals"), _("Denormal Handling"));
119 /* the real actions */
121 act = ActionManager::register_action (main_actions, X_("New"), _("New..."), hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::get_session_parameters), false, true, "")));
123 ActionManager::register_action (main_actions, X_("Open"), _("Open..."), sigc::mem_fun(*this, &ARDOUR_UI::open_session));
124 ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."), sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
125 act = ActionManager::register_action (main_actions, X_("Close"), _("Close"), sigc::mem_fun(*this, &ARDOUR_UI::close_session));
126 ActionManager::session_sensitive_actions.push_back (act);
128 act = ActionManager::register_action (main_actions, X_("AddTrackBus"), _("Add Track or Bus..."),
129 sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_route), (Gtk::Window*) 0));
130 ActionManager::session_sensitive_actions.push_back (act);
131 ActionManager::write_sensitive_actions.push_back (act);
135 sys::path anicomp_file_path;
137 if (PBD::find_file_in_search_path (Glib::getenv("PATH"), "AniComp", anicomp_file_path)) {
138 act = ActionManager::register_action (main_actions, X_("aniConnect"), _("Connect"), (sigc::mem_fun (*editor, &PublicEditor::connect_to_image_compositor)));
139 ActionManager::session_sensitive_actions.push_back (act);
144 act = ActionManager::register_action (main_actions, X_("Snapshot"), _("Snapshot..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), false));
145 ActionManager::session_sensitive_actions.push_back (act);
146 ActionManager::write_sensitive_actions.push_back (act);
148 act = ActionManager::register_action (main_actions, X_("SaveAs"), _("Save As..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), true));
149 ActionManager::session_sensitive_actions.push_back (act);
150 ActionManager::write_sensitive_actions.push_back (act);
152 act = ActionManager::register_action (main_actions, X_("Rename"), _("Rename..."), sigc::mem_fun(*this, &ARDOUR_UI::rename_session));
153 ActionManager::session_sensitive_actions.push_back (act);
154 ActionManager::write_sensitive_actions.push_back (act);
156 act = ActionManager::register_action (main_actions, X_("SaveTemplate"), _("Save Template..."), sigc::mem_fun(*this, &ARDOUR_UI::save_template));
157 ActionManager::session_sensitive_actions.push_back (act);
159 act = ActionManager::register_action (main_actions, X_("Metadata"), _("Metadata"));
160 ActionManager::session_sensitive_actions.push_back (act);
162 act = ActionManager::register_action (main_actions, X_("EditMetadata"), _("Edit Metadata..."), sigc::mem_fun(*this, &ARDOUR_UI::edit_metadata));
163 ActionManager::session_sensitive_actions.push_back (act);
165 act = ActionManager::register_action (main_actions, X_("ImportMetadata"), _("Import Metadata..."), sigc::mem_fun(*this, &ARDOUR_UI::import_metadata));
166 ActionManager::session_sensitive_actions.push_back (act);
168 act = ActionManager::register_action (main_actions, X_("ExportAudio"), _("Export To Audio File(s)..."), sigc::mem_fun (*editor, &PublicEditor::export_audio));
169 ActionManager::session_sensitive_actions.push_back (act);
171 act = ActionManager::register_action (main_actions, X_("StemExport"), _("Stem export..."), sigc::mem_fun (*editor, &PublicEditor::stem_export));
172 ActionManager::session_sensitive_actions.push_back (act);
174 act = ActionManager::register_action (main_actions, X_("Export"), _("Export"));
175 ActionManager::session_sensitive_actions.push_back (act);
177 act = ActionManager::register_action (main_actions, X_("CleanupUnused"), _("Clean-up Unused Sources..."), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup));
178 ActionManager::session_sensitive_actions.push_back (act);
179 ActionManager::write_sensitive_actions.push_back (act);
181 act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
182 ActionManager::write_sensitive_actions.push_back (act);
183 ActionManager::session_sensitive_actions.push_back (act);
185 /* JACK actions for controlling ... JACK */
187 Glib::RefPtr<ActionGroup> jack_actions = ActionGroup::create (X_("JACK"));
188 ActionManager::register_action (jack_actions, X_("JACK"), _("JACK"));
189 ActionManager::register_action (jack_actions, X_("Latency"), _("Latency"));
191 act = ActionManager::register_action (jack_actions, X_("JACKReconnect"), _("Reconnect"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::reconnect_to_jack));
192 ActionManager::jack_opposite_sensitive_actions.push_back (act);
194 act = ActionManager::register_action (jack_actions, X_("JACKDisconnect"), _("Disconnect"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::disconnect_from_jack));
195 ActionManager::jack_sensitive_actions.push_back (act);
197 RadioAction::Group jack_latency_group;
199 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency32"), X_("32"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 32));
200 ActionManager::jack_sensitive_actions.push_back (act);
201 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency64"), X_("64"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 64));
202 ActionManager::jack_sensitive_actions.push_back (act);
203 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency128"), X_("128"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 128));
204 ActionManager::jack_sensitive_actions.push_back (act);
205 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency256"), X_("256"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 256));
206 ActionManager::jack_sensitive_actions.push_back (act);
207 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency512"), X_("512"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 512));
208 ActionManager::jack_sensitive_actions.push_back (act);
209 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency1024"), X_("1024"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 1024));
210 ActionManager::jack_sensitive_actions.push_back (act);
211 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency2048"), X_("2048"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 2048));
212 ActionManager::jack_sensitive_actions.push_back (act);
213 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency4096"), X_("4096"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 4096));
214 ActionManager::jack_sensitive_actions.push_back (act);
215 act = ActionManager::register_radio_action (jack_actions, jack_latency_group, X_("JACKLatency8192"), X_("8192"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::set_jack_buffer_size), (pframes_t) 8192));
216 ActionManager::jack_sensitive_actions.push_back (act);
218 /* these actions are intended to be shared across all windows */
220 common_actions = ActionGroup::create (X_("Common"));
221 ActionManager::register_action (main_actions, X_("WindowMenu"), _("Window"));
222 ActionManager::register_action (common_actions, X_("Quit"), _("Quit"), (hide_return (sigc::mem_fun(*this, &ARDOUR_UI::finish))));
224 /* windows visibility actions */
226 ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalEditor"), _("Maximise Editor Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_editing_space));
227 act = ActionManager::register_toggle_action (common_actions, X_("KeepTearoffs"), _("Toolbars when Maximised"), mem_fun (*this, &ARDOUR_UI::toggle_keep_tearoffs));
228 ActionManager::session_sensitive_actions.push_back (act);
230 ActionManager::register_toggle_action (common_actions, X_("toggle-mixer"), S_("Window|Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_window));
231 ActionManager::register_toggle_action (common_actions, X_("toggle-mixer-on-top"), _("Mixer on Top"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_on_top));
232 ActionManager::register_toggle_action (common_actions, X_("ToggleRCOptionsEditor"), _("Preferences"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_rc_options_window));
233 ActionManager::register_toggle_action (common_actions, X_("ToggleSessionOptionsEditor"), _("Properties"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_options_window));
234 act = ActionManager::register_toggle_action (common_actions, X_("ToggleInspector"), _("Tracks and Busses"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_route_params_window));
235 ActionManager::session_sensitive_actions.push_back (act);
236 ActionManager::session_sensitive_actions.push_back (act);
237 act = ActionManager::register_toggle_action (common_actions, X_("ToggleLocations"), _("Locations"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_location_window));
238 ActionManager::session_sensitive_actions.push_back (act);
239 act = ActionManager::register_toggle_action (common_actions, X_("ToggleBigClock"), _("Big Clock"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_big_clock_window));
240 ActionManager::session_sensitive_actions.push_back (act);
241 act = ActionManager::register_toggle_action (common_actions, X_("toggle-speaker-config"), _("Speaker Configuration"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_speaker_config_window));
242 ActionManager::session_sensitive_actions.push_back (act);
243 act = ActionManager::register_toggle_action (common_actions, X_("toggle-audio-connection-manager"), _("Audio Connection Manager"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_global_port_matrix), ARDOUR::DataType::AUDIO));
244 ActionManager::session_sensitive_actions.push_back (act);
245 act = ActionManager::register_toggle_action (common_actions, X_("toggle-midi-connection-manager"), _("MIDI Connection Manager"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_global_port_matrix), ARDOUR::DataType::MIDI));
246 ActionManager::session_sensitive_actions.push_back (act);
247 act = ActionManager::register_action (common_actions, X_("NewMIDITracer"), _("MIDI Tracer"), sigc::mem_fun(*this, &ARDOUR_UI::new_midi_tracer_window));
248 ActionManager::session_sensitive_actions.push_back (act);
249 ActionManager::register_action (common_actions, X_("About"), _("About"), sigc::mem_fun(*this, &ARDOUR_UI::show_about));
250 ActionManager::register_action (common_actions, X_("Chat"), _("Chat"), sigc::mem_fun(*this, &ARDOUR_UI::launch_chat));
251 /** TRANSLATORS: This is `Manual' in the sense of an instruction book that tells a user how to use Ardour */
252 ActionManager::register_action (common_actions, X_("Manual"), S_("Help|Manual"), mem_fun(*this, &ARDOUR_UI::launch_manual));
253 ActionManager::register_action (common_actions, X_("Reference"), _("Reference"), mem_fun(*this, &ARDOUR_UI::launch_reference));
254 ActionManager::register_toggle_action (common_actions, X_("ToggleThemeManager"), _("Theme Manager"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_theme_manager));
255 ActionManager::register_toggle_action (common_actions, X_("ToggleKeyEditor"), _("Key Bindings"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_key_editor));
256 ActionManager::register_toggle_action (common_actions, X_("ToggleBundleManager"), _("Bundle Manager"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_bundle_manager));
259 act = ActionManager::register_action (common_actions, X_("AddAudioTrack"), _("Add Audio Track"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::session_add_audio_track), 1, 1, ARDOUR::Normal, (ARDOUR::RouteGroup *) 0, 1));
260 ActionManager::session_sensitive_actions.push_back (act);
261 act = ActionManager::register_action (common_actions, X_("AddAudioBus"), _("Add Audio Bus"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::session_add_audio_bus), 1, 1, (ARDOUR::RouteGroup *) 0, 1));
262 ActionManager::session_sensitive_actions.push_back (act);
263 act = ActionManager::register_action (common_actions, X_("AddMIDITrack"), _("Add MIDI Track"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::session_add_midi_track), (ARDOUR::RouteGroup *) 0, 1));
264 ActionManager::session_sensitive_actions.push_back (act);
265 //act = ActionManager::register_action (common_actions, X_("AddMidiBus"), _("Add Midi Bus"), sigc::mem_fun(*this, &ARDOUR_UI::session_add_midi_bus));
266 //ActionManager::session_sensitive_actions.push_back (act);
268 act = ActionManager::register_action (common_actions, X_("Save"), _("Save"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""), false));
269 ActionManager::session_sensitive_actions.push_back (act);
270 ActionManager::write_sensitive_actions.push_back (act);
271 act = ActionManager::register_action (common_actions, X_("RemoveLastCapture"), _("Remove Last Capture"), sigc::mem_fun(*this, &ARDOUR_UI::remove_last_capture));
272 ActionManager::session_sensitive_actions.push_back (act);
274 Glib::RefPtr<ActionGroup> transport_actions = ActionGroup::create (X_("Transport"));
276 /* do-nothing action for the "transport" menu bar item */
278 ActionManager::register_action (transport_actions, X_("Transport"), _("Transport"));
280 /* these two are not used by key bindings, instead use ToggleRoll for that. these two do show up in
281 menus and via button proxies.
284 act = ActionManager::register_action (transport_actions, X_("Stop"), _("Stop"), sigc::mem_fun(*this, &ARDOUR_UI::transport_stop));
285 ActionManager::session_sensitive_actions.push_back (act);
286 ActionManager::transport_sensitive_actions.push_back (act);
287 act = ActionManager::register_action (transport_actions, X_("Roll"), _("Roll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_roll));
288 ActionManager::session_sensitive_actions.push_back (act);
289 ActionManager::transport_sensitive_actions.push_back (act);
291 act = ActionManager::register_action (transport_actions, X_("ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
292 ActionManager::session_sensitive_actions.push_back (act);
293 ActionManager::transport_sensitive_actions.push_back (act);
294 act = ActionManager::register_action (transport_actions, X_("ToggleRollMaybe"), _("Start/Continue/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, true));
295 ActionManager::session_sensitive_actions.push_back (act);
296 ActionManager::transport_sensitive_actions.push_back (act);
297 act = ActionManager::register_action (transport_actions, X_("ToggleRollForgetCapture"), _("Stop and Forget Capture"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_roll), true, false));
298 ActionManager::session_sensitive_actions.push_back (act);
299 ActionManager::transport_sensitive_actions.push_back (act);
301 /* these two behave as follows:
303 - if transport speed != 1.0 or != -1.0, change speed to 1.0 or -1.0 (respectively)
304 - otherwise do nothing
307 act = ActionManager::register_action (transport_actions, X_("TransitionToRoll"), _("Transition To Roll"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), true));
308 ActionManager::session_sensitive_actions.push_back (act);
309 ActionManager::transport_sensitive_actions.push_back (act);
311 act = ActionManager::register_action (transport_actions, X_("TransitionToReverse"), _("Transition To Reverse"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), false));
312 ActionManager::session_sensitive_actions.push_back (act);
313 ActionManager::transport_sensitive_actions.push_back (act);
315 act = ActionManager::register_action (transport_actions, X_("Loop"), _("Play Loop Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
316 ActionManager::session_sensitive_actions.push_back (act);
317 ActionManager::transport_sensitive_actions.push_back (act);
318 act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selected Range"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
319 ActionManager::session_sensitive_actions.push_back (act);
320 ActionManager::transport_sensitive_actions.push_back (act);
322 act = ActionManager::register_action (transport_actions, X_("Record"), _("Enable Record"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), false));
323 ActionManager::session_sensitive_actions.push_back (act);
324 ActionManager::write_sensitive_actions.push_back (act);
325 act = ActionManager::register_action (transport_actions, X_("record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
326 ActionManager::session_sensitive_actions.push_back (act);
327 ActionManager::write_sensitive_actions.push_back (act);
328 ActionManager::transport_sensitive_actions.push_back (act);
329 act = ActionManager::register_action (transport_actions, X_("Rewind"), _("Rewind"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 0));
330 ActionManager::session_sensitive_actions.push_back (act);
331 ActionManager::transport_sensitive_actions.push_back (act);
332 act = ActionManager::register_action (transport_actions, X_("RewindSlow"), _("Rewind (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), -1));
333 ActionManager::session_sensitive_actions.push_back (act);
334 ActionManager::transport_sensitive_actions.push_back (act);
335 act = ActionManager::register_action (transport_actions, X_("RewindFast"), _("Rewind (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 1));
336 ActionManager::session_sensitive_actions.push_back (act);
337 ActionManager::transport_sensitive_actions.push_back (act);
338 act = ActionManager::register_action (transport_actions, X_("Forward"), _("Forward"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 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_("ForwardSlow"), _("Forward (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), -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_("ForwardFast"), _("Forward (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 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_("GotoZero"), _("Goto Zero"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_zero));
348 ActionManager::session_sensitive_actions.push_back (act);
349 ActionManager::transport_sensitive_actions.push_back (act);
350 act = ActionManager::register_action (transport_actions, X_("GotoStart"), _("Goto Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
351 ActionManager::session_sensitive_actions.push_back (act);
352 ActionManager::transport_sensitive_actions.push_back (act);
353 act = ActionManager::register_action (transport_actions, X_("GotoEnd"), _("Goto End"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_end));
354 ActionManager::session_sensitive_actions.push_back (act);
355 ActionManager::transport_sensitive_actions.push_back (act);
356 act = ActionManager::register_action (transport_actions, X_("GotoWallClock"), _("Goto Wall Clock"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_wallclock));
357 ActionManager::session_sensitive_actions.push_back (act);
358 ActionManager::transport_sensitive_actions.push_back (act);
360 act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(*this, &ARDOUR_UI::focus_on_clock));
361 ActionManager::session_sensitive_actions.push_back (act);
362 ActionManager::transport_sensitive_actions.push_back (act);
364 act = ActionManager::register_action (transport_actions, X_("primary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Timecode));
365 ActionManager::session_sensitive_actions.push_back (act);
366 act = ActionManager::register_action (transport_actions, X_("primary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::BBT));
367 ActionManager::session_sensitive_actions.push_back (act);
368 act = ActionManager::register_action (transport_actions, X_("primary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::MinSec));
369 ActionManager::session_sensitive_actions.push_back (act);
370 act = ActionManager::register_action (transport_actions, X_("primary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Frames));
371 ActionManager::session_sensitive_actions.push_back (act);
373 act = ActionManager::register_action (transport_actions, X_("secondary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Timecode));
374 ActionManager::session_sensitive_actions.push_back (act);
375 act = ActionManager::register_action (transport_actions, X_("secondary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::BBT));
376 ActionManager::session_sensitive_actions.push_back (act);
377 act = ActionManager::register_action (transport_actions, X_("secondary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::MinSec));
378 ActionManager::session_sensitive_actions.push_back (act);
379 act = ActionManager::register_action (transport_actions, X_("secondary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Frames));
380 ActionManager::session_sensitive_actions.push_back (act);
382 act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
383 act->set_short_label (_("In"));
384 ActionManager::session_sensitive_actions.push_back (act);
385 ActionManager::transport_sensitive_actions.push_back (act);
386 act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchOut"), _("Punch Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_out));
387 act->set_short_label (_("Out"));
388 ActionManager::session_sensitive_actions.push_back (act);
389 ActionManager::transport_sensitive_actions.push_back (act);
390 act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunch"), _("Punch In/Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch));
391 act->set_short_label (_("In/Out"));
392 ActionManager::session_sensitive_actions.push_back (act);
393 ActionManager::transport_sensitive_actions.push_back (act);
394 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleClick"), _("Click"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_click));
395 ActionManager::session_sensitive_actions.push_back (act);
396 ActionManager::transport_sensitive_actions.push_back (act);
397 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoInput"), _("Auto Input"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_input));
398 ActionManager::session_sensitive_actions.push_back (act);
399 ActionManager::transport_sensitive_actions.push_back (act);
400 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoPlay"), _("Auto Play"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_play));
401 ActionManager::session_sensitive_actions.push_back (act);
402 ActionManager::transport_sensitive_actions.push_back (act);
403 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoReturn"), _("Auto Return"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_return));
404 ActionManager::session_sensitive_actions.push_back (act);
405 ActionManager::transport_sensitive_actions.push_back (act);
407 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync Startup to Video"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_video_sync));
408 ActionManager::session_sensitive_actions.push_back (act);
409 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleTimeMaster"), _("Time Master"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_time_master));
410 ActionManager::session_sensitive_actions.push_back (act);
411 act = ActionManager::register_toggle_action (transport_actions, X_("ToggleExternalSync"), "", sigc::mem_fun(*this, &ARDOUR_UI::toggle_external_sync));
412 ActionManager::session_sensitive_actions.push_back (act);
414 for (int i = 1; i <= 32; ++i) {
415 string const a = string_compose (X_("ToggleRecordEnableTrack%1"), i);
416 string const n = string_compose (_("Toggle Record Enable Track %1"), i);
417 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));
418 ActionManager::session_sensitive_actions.push_back (act);
421 Glib::RefPtr<ActionGroup> shuttle_actions = ActionGroup::create ("ShuttleActions");
423 shuttle_actions->add (Action::create (X_("SetShuttleUnitsPercentage"), _("Percentage")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Percentage)));
424 shuttle_actions->add (Action::create (X_("SetShuttleUnitsSemitones"), _("Semitones")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Semitones)));
426 Glib::RefPtr<ActionGroup> option_actions = ActionGroup::create ("options");
428 act = ActionManager::register_toggle_action (option_actions, X_("SendMTC"), _("Send MTC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mtc));
429 ActionManager::session_sensitive_actions.push_back (act);
430 act = ActionManager::register_toggle_action (option_actions, X_("SendMMC"), _("Send MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mmc));
431 ActionManager::session_sensitive_actions.push_back (act);
432 act = ActionManager::register_toggle_action (option_actions, X_("UseMMC"), _("Use MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_use_mmc));
433 ActionManager::session_sensitive_actions.push_back (act);
434 act = ActionManager::register_toggle_action (option_actions, X_("SendMidiClock"), _("Send MIDI Clock"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_clock));
435 ActionManager::session_sensitive_actions.push_back (act);
436 act = ActionManager::register_toggle_action (option_actions, X_("SendMIDIfeedback"), _("Send MIDI Feedback"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_feedback));
437 ActionManager::session_sensitive_actions.push_back (act);
440 if (getenv ("ARDOUR_BUNDLED")) {
441 act = ActionManager::register_toggle_action (main_actions, X_("EnableTranslation"), _("Enable Translations"), mem_fun (*this, &ARDOUR_UI::toggle_translations));
443 RefPtr<ToggleAction> ract = RefPtr<ToggleAction>::cast_dynamic (act);
445 ract->set_active (!ARDOUR::translations_are_disabled());
452 Glib::RefPtr<ActionGroup> midi_actions = ActionGroup::create (X_("MIDI"));
453 ActionManager::register_action (midi_actions, X_("panic"), _("Panic"), sigc::mem_fun(*this, &ARDOUR_UI::midi_panic));
455 ActionManager::add_action_group (shuttle_actions);
456 ActionManager::add_action_group (option_actions);
457 ActionManager::add_action_group (jack_actions);
458 ActionManager::add_action_group (transport_actions);
459 ActionManager::add_action_group (main_actions);
460 ActionManager::add_action_group (common_actions);
461 ActionManager::add_action_group (midi_actions);
465 ARDOUR_UI::set_jack_buffer_size (pframes_t nframes)
467 Glib::RefPtr<Action> action;
468 const char* action_name = 0;
472 action_name = X_("JACKLatency32");
475 action_name = X_("JACKLatency64");
478 action_name = X_("JACKLatency128");
481 action_name = X_("JACKLatency256");
484 action_name = X_("JACKLatency512");
487 action_name = X_("JACKLatency1024");
490 action_name = X_("JACKLatency2048");
493 action_name = X_("JACKLatency4096");
496 action_name = X_("JACKLatency8192");
499 /* XXX can we do anything useful ? */
505 action = ActionManager::get_action (X_("JACK"), action_name);
508 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (action);
510 if (ract && ract->get_active()) {
511 engine->request_buffer_size (nframes);
512 update_sample_rate (0);
519 ARDOUR_UI::build_menu_bar ()
521 menu_bar = dynamic_cast<MenuBar*> (ActionManager::get_widget (X_("/Main")));
522 menu_bar->set_name ("MainMenuBar");
525 * This is needed because this property does not get installed
526 * until the Menu GObject class is registered, which happens
527 * when the first menu instance is created.
529 // XXX bug in gtkmm causes this to popup an error message
530 // Gtk::Settings::get_default()->property_gtk_can_change_accels() = true;
531 // so use this instead ...
532 gtk_settings_set_long_property (gtk_settings_get_default(), "gtk-can-change-accels", 1, "Ardour:designers");
534 EventBox* ev = manage (new EventBox);
536 CairoHPacker* hbox = manage (new CairoHPacker);
541 wall_clock_label.set_name ("WallClock");
542 wall_clock_label.set_use_markup ();
543 disk_space_label.set_name ("WallClock");
544 disk_space_label.set_use_markup ();
545 cpu_load_label.set_name ("CPULoad");
546 cpu_load_label.set_use_markup ();
547 buffer_load_label.set_name ("BufferLoad");
548 buffer_load_label.set_use_markup ();
549 sample_rate_label.set_name ("SampleRate");
550 sample_rate_label.set_use_markup ();
551 format_label.set_name ("Format");
552 format_label.set_use_markup ();
555 menu_hbox.pack_start (*menu_bar, false, false);
557 use_menubar_as_top_menubar ();
560 bool wall_clock = false;
561 bool disk_space = false;
563 if (!Profile->get_small_screen()) {
565 // OSX provides its own wallclock, thank you very much
571 hbox->pack_end (wall_clock_label, false, false, 2);
572 hbox->pack_end (disk_space_label, false, false, 4);
573 hbox->pack_end (cpu_load_label, false, false, 4);
574 hbox->pack_end (buffer_load_label, false, false, 4);
575 hbox->pack_end (sample_rate_label, false, false, 4);
576 hbox->pack_end (format_label, false, false, 4);
578 menu_hbox.pack_end (*ev, false, false);
580 menu_bar_base.set_name ("MainMenuBar");
581 menu_bar_base.add (menu_hbox);
583 _status_bar_visibility.add (&wall_clock_label, X_("WallClock"), _("Wall Clock"), wall_clock);
584 _status_bar_visibility.add (&disk_space_label, X_("Disk"), _("Disk Space"), disk_space);
585 _status_bar_visibility.add (&cpu_load_label, X_("DSP"), _("DSP"), true);
586 _status_bar_visibility.add (&buffer_load_label, X_("Buffers"), _("Buffers"), true);
587 _status_bar_visibility.add (&sample_rate_label, X_("JACK"), _("JACK Sampling Rate and Latency"), true);
588 _status_bar_visibility.add (&format_label, X_("Format"), _("File Format"), true);
590 ev->signal_button_press_event().connect (sigc::mem_fun (_status_bar_visibility, &VisibilityGroup::button_press_event));
594 ARDOUR_UI::use_menubar_as_top_menubar ()
597 Application* app = Application::instance ();
599 /* Quit will be taken of separately */
601 if ((widget = ActionManager::get_widget ("/ui/Main/Session/Quit"))) {
605 GtkApplicationMenuGroup* group = app->add_app_menu_group ();
607 if ((widget = ActionManager::get_widget ("/ui/Main/Session/About"))) {
608 app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
611 if ((widget = ActionManager::get_widget ("/ui/Main/Session/ToggleRCOptionsEditor"))) {
612 app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
615 app->set_menu_bar (*menu_bar);
619 ARDOUR_UI::big_clock_catch_focus ()
621 PublicEditor::instance().reset_focus ();
625 ARDOUR_UI::setup_clock ()
627 ARDOUR_UI::Clock.connect (sigc::mem_fun (big_clock, &AudioClock::set));
629 big_clock->set_corner_radius (0.0);
630 big_clock->set_fixed_width (false);
631 big_clock->mode_changed.connect (sigc::mem_fun (*this, &ARDOUR_UI::big_clock_reset_aspect_ratio));
633 big_clock_window->set (new Window (WINDOW_TOPLEVEL), false);
635 big_clock_window->get()->set_keep_above (true);
636 big_clock_window->get()->set_border_width (0);
637 big_clock_window->get()->add (*big_clock);
639 big_clock_window->get()->set_title (_("Big Clock"));
640 big_clock_window->get()->signal_realize().connect (sigc::mem_fun (*this, &ARDOUR_UI::big_clock_realized));
641 big_clock_window->get()->signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), big_clock_window->get()), false);
642 big_clock_window->get()->signal_size_allocate().connect (sigc::mem_fun (*this, &ARDOUR_UI::big_clock_size_allocate));
644 big_clock_window->get()->signal_unmap().connect (sigc::bind (sigc::ptr_fun(&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/ToggleBigClock")));
645 big_clock_window->get()->signal_unmap().connect (sigc::mem_fun (*this, &ARDOUR_UI::big_clock_catch_focus));
647 manage_window (*big_clock_window->get());
651 ARDOUR_UI::big_clock_reset_aspect_ratio ()
653 Gtk::Requisition req;
654 big_clock->size_request (req);
655 float aspect = req.width/(float)req.height;
658 geom.min_aspect = aspect;
659 geom.max_aspect = aspect;
661 big_clock_window->get()->set_geometry_hints (*big_clock, geom, Gdk::HINT_ASPECT);
665 ARDOUR_UI::big_clock_realized ()
669 set_decoration (big_clock_window->get(), (Gdk::DECOR_BORDER|Gdk::DECOR_RESIZEH));
670 big_clock_window->get()->get_window()->get_geometry (x, y, w, big_clock_height, d);
672 big_clock_reset_aspect_ratio ();
674 original_big_clock_height = big_clock_height;
675 original_big_clock_width = w;
677 Pango::FontDescription fd (big_clock->get_style()->get_font());
678 original_big_clock_font_size = fd.get_size ();
680 if (!fd.get_size_is_absolute ()) {
681 original_big_clock_font_size /= PANGO_SCALE;
684 big_clock_window->setup ();
688 ARDOUR_UI::float_big_clock (Gtk::Window* parent)
690 if (big_clock_window->get()) {
692 big_clock_window->get()->set_transient_for (*parent);
694 gtk_window_set_transient_for (big_clock_window->get()->gobj(), (GtkWindow*) 0);
700 ARDOUR_UI::big_clock_size_allocate (Gtk::Allocation& alloc)
702 if (!big_clock_resize_in_progress) {
703 Glib::signal_idle().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::idle_big_clock_text_resizer), 0, 0));
704 big_clock_resize_in_progress = true;
709 ARDOUR_UI::idle_big_clock_text_resizer (int, int)
711 big_clock_resize_in_progress = false;
713 Glib::RefPtr<Gdk::Window> win = big_clock_window->get()->get_window();
714 Pango::FontDescription fd (big_clock->get_style()->get_font());
715 int current_size = fd.get_size ();
718 if (!fd.get_size_is_absolute ()) {
719 current_size /= PANGO_SCALE;
722 win->get_geometry (x, y, w, h, d);
724 double scale = min (((double) w / (double) original_big_clock_width),
725 ((double) h / (double) original_big_clock_height));
727 int size = (int) lrintf (original_big_clock_font_size * scale);
729 if (size != current_size) {
731 string family = fd.get_family();
732 char buf[family.length()+16];
733 snprintf (buf, family.length()+16, "%s %d", family.c_str(), size);
736 Pango::FontDescription fd (buf);
737 Glib::RefPtr<Gtk::RcStyle> rcstyle = big_clock->get_modifier_style ();
738 rcstyle->set_font (fd);
739 big_clock->modify_style (rcstyle);
743 /* oh well, do nothing */
751 ARDOUR_UI::save_ardour_state ()
753 if (!keyboard || !mixer || !editor) {
757 /* XXX this is all a bit dubious. add_extra_xml() uses
758 a different lifetime model from add_instant_xml().
761 XMLNode* node = new XMLNode (keyboard->get_state());
762 Config->add_extra_xml (*node);
763 Config->add_extra_xml (get_transport_controllable_state());
765 XMLNode* window_node = new XMLNode (X_("UI"));
766 window_node->add_property (_status_bar_visibility.get_state_name().c_str(), _status_bar_visibility.get_state_value ());
768 for (list<WindowProxyBase*>::iterator i = _window_proxies.begin(); i != _window_proxies.end(); ++i) {
769 if ((*i)->rc_configured()) {
770 window_node->add_child_nocopy (*((*i)->get_state ()));
776 XMLNode* tearoff_node = new XMLNode (X_("Tearoffs"));
778 if (transport_tearoff) {
779 XMLNode* t = new XMLNode (X_("transport"));
780 transport_tearoff->add_state (*t);
781 tearoff_node->add_child_nocopy (*t);
784 if (mixer && mixer->monitor_section()) {
785 XMLNode* t = new XMLNode (X_("monitor-section"));
786 mixer->monitor_section()->tearoff().add_state (*t);
787 tearoff_node->add_child_nocopy (*t);
790 if (editor && editor->mouse_mode_tearoff()) {
791 XMLNode* t = new XMLNode (X_("mouse-mode"));
792 editor->mouse_mode_tearoff ()->add_state (*t);
793 tearoff_node->add_child_nocopy (*t);
796 window_node->add_child_nocopy (*tearoff_node);
798 Config->add_extra_xml (*window_node);
800 if (_startup && _startup->engine_control() && _startup->engine_control()->was_used()) {
801 Config->add_extra_xml (_startup->engine_control()->get_state());
803 Config->save_state();
804 if (ui_config->dirty()) {
805 ui_config->save_state ();
808 XMLNode& enode (static_cast<Stateful*>(editor)->get_state());
809 XMLNode& mnode (mixer->get_state());
812 _session->add_instant_xml (enode);
813 _session->add_instant_xml (mnode);
814 if (location_ui->get ()) {
815 _session->add_instant_xml (location_ui->get()->ui().get_state ());
818 Config->add_instant_xml (enode);
819 Config->add_instant_xml (mnode);
820 if (location_ui->get ()) {
821 Config->add_instant_xml (location_ui->get()->ui().get_state ());
825 Keyboard::save_keybindings ();
829 ARDOUR_UI::toggle_global_port_matrix (ARDOUR::DataType t)
831 std::string const action = string_compose ("toggle-%1-connection-manager", t.to_string ());
833 if (_global_port_matrix[t]->get() == 0) {
834 _global_port_matrix[t]->set (new GlobalPortMatrixWindow (_session, t));
835 _global_port_matrix[t]->get()->signal_unmap().connect(sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), string_compose (X_("<Actions>/Common/%1"), action)));
838 RefPtr<Action> act = ActionManager::get_action (X_("Common"), action.c_str());
840 RefPtr<ToggleAction> tact = RefPtr<ToggleAction>::cast_dynamic (act);
842 if (tact->get_active()) {
843 _global_port_matrix[t]->get()->present ();
845 _global_port_matrix[t]->get()->hide ();
851 ARDOUR_UI::resize_text_widgets ()
853 set_size_request_to_display_given_text (cpu_load_label, "DSP: 100.0%", 2, 2);
854 set_size_request_to_display_given_text (buffer_load_label, "Buffers: p:100% c:100%", 2, 2);
858 ARDOUR_UI::focus_on_clock ()
860 if (editor && primary_clock) {
862 primary_clock->focus ();