ardour
ardour_ui_ed.cc
Go to the documentation of this file.
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/utils.h"
36 #include "gtkmm2ext/window_title.h"
37 #include "gtkmm2ext/tearoff.h"
38 #include "gtkmm2ext/cairo_packer.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 "mixer_ui.h"
53 #include "startup.h"
54 #include "window_manager.h"
55 #include "global_port_matrix.h"
56 #include "location_ui.h"
57 #include "main_clock.h"
58 
59 #include <gtkmm2ext/application.h>
60 
61 #include "ardour/session.h"
62 #include "ardour/profile.h"
63 #include "ardour/audioengine.h"
64 
65 #include "control_protocol/control_protocol.h"
66 
67 #include "i18n.h"
68 
69 using namespace std;
70 using namespace ARDOUR;
71 using namespace PBD;
72 using namespace Gtkmm2ext;
73 using namespace Gtk;
74 using namespace Glib;
75 
76 int
78 {
79  try {
80  editor = new Editor ();
81  }
82 
83  catch (failed_constructor& err) {
84  return -1;
85  }
86 
87  editor->Realized.connect (sigc::mem_fun (*this, &ARDOUR_UI::editor_realized));
88  editor->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), true));
89 
90  return 0;
91 }
92 
93 void
95 {
96  Glib::RefPtr<ActionGroup> main_actions = ActionGroup::create (X_("Main"));
97  Glib::RefPtr<ActionGroup> main_menu_actions = ActionGroup::create (X_("Main_menu"));
98  Glib::RefPtr<Action> act;
99 
100  /* menus + submenus that need action items */
101 
102  ActionManager::register_action (main_menu_actions, X_("Session"), _("Session"));
103  act = ActionManager::register_action (main_menu_actions, X_("Cleanup"), _("Clean-up"));
105  ActionManager::register_action (main_menu_actions, X_("Sync"), _("Sync"));
106  ActionManager::register_action (main_menu_actions, X_("TransportOptions"), _("Options"));
107  ActionManager::register_action (main_menu_actions, X_("WindowMenu"), _("Window"));
108  ActionManager::register_action (main_menu_actions, X_("Help"), _("Help"));
109  ActionManager::register_action (main_menu_actions, X_("KeyMouseActions"), _("Misc. Shortcuts"));
110  ActionManager::register_action (main_menu_actions, X_("AudioFileFormat"), _("Audio File Format"));
111  ActionManager::register_action (main_menu_actions, X_("AudioFileFormatHeader"), _("File Type"));
112  ActionManager::register_action (main_menu_actions, X_("AudioFileFormatData"), _("Sample Format"));
113  ActionManager::register_action (main_menu_actions, X_("ControlSurfaces"), _("Control Surfaces"));
114  ActionManager::register_action (main_menu_actions, X_("Plugins"), _("Plugins"));
115  ActionManager::register_action (main_menu_actions, X_("Metering"), _("Metering"));
116  ActionManager::register_action (main_menu_actions, X_("MeteringFallOffRate"), _("Fall Off Rate"));
117  ActionManager::register_action (main_menu_actions, X_("MeteringHoldTime"), _("Hold Time"));
118  ActionManager::register_action (main_menu_actions, X_("Denormals"), _("Denormal Handling"));
119 
120  /* the real actions */
121 
122  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 
124  ActionManager::register_action (main_actions, X_("Open"), _("Open..."), sigc::mem_fun(*this, &ARDOUR_UI::open_session));
125  ActionManager::register_action (main_actions, X_("Recent"), _("Recent..."), sigc::mem_fun(*this, &ARDOUR_UI::open_recent_session));
126  act = ActionManager::register_action (main_actions, X_("Close"), _("Close"), sigc::mem_fun(*this, &ARDOUR_UI::close_session));
128 
129  act = ActionManager::register_action (main_actions, X_("AddTrackBus"), _("Add Track or Bus..."),
130  sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_route), (Gtk::Window*) 0));
133 
134  act = ActionManager::register_action (main_actions, X_("OpenVideo"), _("Open Video"),
135  sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::add_video), (Gtk::Window*) 0));
137  act = ActionManager::register_action (main_actions, X_("CloseVideo"), _("Remove Video"),
138  sigc::mem_fun (*this, &ARDOUR_UI::remove_video));
139  act->set_sensitive (false);
140  act = ActionManager::register_action (main_actions, X_("ExportVideo"), _("Export To Video File"),
141  hide_return (sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::export_video), false)));
143 
144  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));
147 
148  act = ActionManager::register_action (main_actions, X_("SnapshotSwitch"), _("Snapshot (& switch to new version) ..."), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::snapshot_session), true));
151 
152  act = ActionManager::register_action (main_actions, X_("SaveAs"), _("Save As..."), sigc::mem_fun(*this, &ARDOUR_UI::save_session_as));
155 
156  act = ActionManager::register_action (main_actions, X_("Rename"), _("Rename..."), sigc::mem_fun(*this, &ARDOUR_UI::rename_session));
159 
160  act = ActionManager::register_action (main_actions, X_("SaveTemplate"), _("Save Template..."), sigc::mem_fun(*this, &ARDOUR_UI::save_template));
162 
163  act = ActionManager::register_action (main_actions, X_("Metadata"), _("Metadata"));
165 
166  act = ActionManager::register_action (main_actions, X_("EditMetadata"), _("Edit Metadata..."), sigc::mem_fun(*this, &ARDOUR_UI::edit_metadata));
168 
169  act = ActionManager::register_action (main_actions, X_("ImportMetadata"), _("Import Metadata..."), sigc::mem_fun(*this, &ARDOUR_UI::import_metadata));
171 
172  act = ActionManager::register_action (main_actions, X_("ExportAudio"), _("Export To Audio File(s)..."), sigc::mem_fun (*editor, &PublicEditor::export_audio));
174 
175  act = ActionManager::register_action (main_actions, X_("StemExport"), _("Stem export..."), sigc::mem_fun (*editor, &PublicEditor::stem_export));
177 
178  act = ActionManager::register_action (main_actions, X_("Export"), _("Export"));
180 
181  act = ActionManager::register_action (main_actions, X_("CleanupUnused"), _("Clean-up Unused Sources..."), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::cleanup));
184 
185  act = ActionManager::register_action (main_actions, X_("FlushWastebasket"), _("Flush Wastebasket"), sigc::mem_fun (*(ARDOUR_UI::instance()), &ARDOUR_UI::flush_trash));
188 
189  /* these actions are intended to be shared across all windows */
190 
191  common_actions = ActionGroup::create (X_("Common"));
192  ActionManager::register_action (common_actions, X_("Quit"), _("Quit"), (hide_return (sigc::mem_fun(*this, &ARDOUR_UI::finish))));
193 
194  /* windows visibility actions */
195 
196  ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalEditor"), _("Maximise Editor Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_editing_space));
197  ActionManager::register_toggle_action (common_actions, X_("ToggleMaximalMixer"), _("Maximise Mixer Space"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_mixer_space));
198  act = ActionManager::register_toggle_action (common_actions, X_("KeepTearoffs"), _("Show Toolbars"), mem_fun (*this, &ARDOUR_UI::toggle_keep_tearoffs));
200 
201 if (Profile->get_mixbus())
202  ActionManager::register_action (common_actions, X_("show-ui-prefs"), _("Show more UI preferences"), sigc::mem_fun (*this, &ARDOUR_UI::show_ui_prefs));
203 
204  ActionManager::register_toggle_action (common_actions, X_("toggle-mixer"), S_("Window|Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_mixer_window));
205  ActionManager::register_action (common_actions, X_("toggle-editor-mixer"), _("Toggle Editor+Mixer"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_editor_mixer));
206  ActionManager::register_toggle_action (common_actions, X_("toggle-meterbridge"), S_("Window|Meterbridge"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_meterbridge));
207 
208  ActionManager::register_action (common_actions, X_("reattach-all-tearoffs"), _("Reattach All Tearoffs"), sigc::mem_fun (*this, &ARDOUR_UI::reattach_all_tearoffs));
209 
210  act = ActionManager::register_action (common_actions, X_("NewMIDITracer"), _("MIDI Tracer"), sigc::mem_fun(*this, &ARDOUR_UI::new_midi_tracer_window));
212  ActionManager::register_action (common_actions, X_("Chat"), _("Chat"), sigc::mem_fun(*this, &ARDOUR_UI::launch_chat));
214  ActionManager::register_action (common_actions, X_("Manual"), S_("Help|Manual"), mem_fun(*this, &ARDOUR_UI::launch_manual));
215  ActionManager::register_action (common_actions, X_("Reference"), _("Reference"), mem_fun(*this, &ARDOUR_UI::launch_reference));
216  ActionManager::register_action (common_actions, X_("Tracker"), _("Report A Bug"), mem_fun(*this, &ARDOUR_UI::launch_tracker));
217  ActionManager::register_action (common_actions, X_("Cheat_Sheet"), _("Cheat Sheet"), mem_fun(*this, &ARDOUR_UI::launch_cheat_sheet));
218  ActionManager::register_action (common_actions, X_("Website"), _("Ardour Website"), mem_fun(*this, &ARDOUR_UI::launch_website));
219  ActionManager::register_action (common_actions, X_("Website_Dev"), _("Ardour Development"), mem_fun(*this, &ARDOUR_UI::launch_website_dev));
220  ActionManager::register_action (common_actions, X_("Forums"), _("User Forums"), mem_fun(*this, &ARDOUR_UI::launch_forums));
221  ActionManager::register_action (common_actions, X_("Howto_Report"), _("How to report a bug"), mem_fun(*this, &ARDOUR_UI::launch_howto_report));
222 
223  act = ActionManager::register_action (common_actions, X_("Save"), _("Save"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::save_state), string(""), false));
226 
227  Glib::RefPtr<ActionGroup> transport_actions = ActionGroup::create (X_("Transport"));
228 
229  /* do-nothing action for the "transport" menu bar item */
230 
231  ActionManager::register_action (transport_actions, X_("Transport"), _("Transport"));
232 
233  /* these two are not used by key bindings, instead use ToggleRoll for that. these two do show up in
234  menus and via button proxies.
235  */
236 
237  act = ActionManager::register_action (transport_actions, X_("Stop"), _("Stop"), sigc::mem_fun(*this, &ARDOUR_UI::transport_stop));
240  act = ActionManager::register_action (transport_actions, X_("Roll"), _("Roll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_roll));
243 
244  act = ActionManager::register_action (transport_actions, X_("ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
247  act = ActionManager::register_action (transport_actions, X_("alternate-ToggleRoll"), _("Start/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, false));
250  act = ActionManager::register_action (transport_actions, X_("ToggleRollMaybe"), _("Start/Continue/Stop"), sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::toggle_roll), false, true));
253  act = ActionManager::register_action (transport_actions, X_("ToggleRollForgetCapture"), _("Stop and Forget Capture"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::toggle_roll), true, false));
256 
257  /* these two behave as follows:
258 
259  - if transport speed != 1.0 or != -1.0, change speed to 1.0 or -1.0 (respectively)
260  - otherwise do nothing
261  */
262 
263  act = ActionManager::register_action (transport_actions, X_("TransitionToRoll"), _("Transition To Roll"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), true));
266 
267  act = ActionManager::register_action (transport_actions, X_("TransitionToReverse"), _("Transition To Reverse"), sigc::bind (sigc::mem_fun (*editor, &PublicEditor::transition_to_rolling), false));
270 
271  act = ActionManager::register_action (transport_actions, X_("Loop"), _("Play Loop Range"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_session_auto_loop));
274  act = ActionManager::register_action (transport_actions, X_("PlaySelection"), _("Play Selection"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_selection));
277  act = ActionManager::register_action (transport_actions, X_("PlayPreroll"), _("Play Selection w/Preroll"), sigc::mem_fun(*this, &ARDOUR_UI::transport_play_preroll));
280 
281  act = ActionManager::register_action (transport_actions, X_("Record"), _("Enable Record"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), false));
284  act = ActionManager::register_action (transport_actions, X_("record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
288  act = ActionManager::register_action (transport_actions, X_("alternate-record-roll"), _("Start Recording"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_record), true));
292  act = ActionManager::register_action (transport_actions, X_("Rewind"), _("Rewind"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 0));
295  act = ActionManager::register_action (transport_actions, X_("RewindSlow"), _("Rewind (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), -1));
298  act = ActionManager::register_action (transport_actions, X_("RewindFast"), _("Rewind (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_rewind), 1));
301  act = ActionManager::register_action (transport_actions, X_("Forward"), _("Forward"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 0));
304  act = ActionManager::register_action (transport_actions, X_("ForwardSlow"), _("Forward (Slow)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), -1));
307  act = ActionManager::register_action (transport_actions, X_("ForwardFast"), _("Forward (Fast)"), sigc::bind (sigc::mem_fun(*this, &ARDOUR_UI::transport_forward), 1));
310  act = ActionManager::register_action (transport_actions, X_("GotoZero"), _("Goto Zero"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_zero));
313  act = ActionManager::register_action (transport_actions, X_("GotoStart"), _("Goto Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
316  act = ActionManager::register_action (transport_actions, X_("alternate-GotoStart"), _("Goto Start"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_start));
319  act = ActionManager::register_action (transport_actions, X_("GotoEnd"), _("Goto End"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_end));
322  act = ActionManager::register_action (transport_actions, X_("GotoWallClock"), _("Goto Wall Clock"), sigc::mem_fun(*this, &ARDOUR_UI::transport_goto_wallclock));
325 
326  //these actions handle the numpad events, ProTools style
327  act = ActionManager::register_action (transport_actions, X_("numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
330  act = ActionManager::register_action (transport_actions, X_("alternate-numpad-decimal"), _("Numpad Decimal"), mem_fun(*this, &ARDOUR_UI::transport_numpad_decimal));
333  act = ActionManager::register_action (transport_actions, X_("numpad-0"), _("Numpad 0"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 0));
336  act = ActionManager::register_action (transport_actions, X_("numpad-1"), _("Numpad 1"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 1));
339  act = ActionManager::register_action (transport_actions, X_("numpad-2"), _("Numpad 2"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 2));
342  act = ActionManager::register_action (transport_actions, X_("numpad-3"), _("Numpad 3"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 3));
345  act = ActionManager::register_action (transport_actions, X_("numpad-4"), _("Numpad 4"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 4));
348  act = ActionManager::register_action (transport_actions, X_("numpad-5"), _("Numpad 5"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 5));
351  act = ActionManager::register_action (transport_actions, X_("numpad-6"), _("Numpad 6"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 6));
354  act = ActionManager::register_action (transport_actions, X_("numpad-7"), _("Numpad 7"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 7));
357  act = ActionManager::register_action (transport_actions, X_("numpad-8"), _("Numpad 8"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 8));
360  act = ActionManager::register_action (transport_actions, X_("numpad-9"), _("Numpad 9"), bind (mem_fun(*this, &ARDOUR_UI::transport_numpad_event), 9));
363 
364  act = ActionManager::register_action (transport_actions, X_("focus-on-clock"), _("Focus On Clock"), sigc::mem_fun(*this, &ARDOUR_UI::focus_on_clock));
367 
368  act = ActionManager::register_action (transport_actions, X_("primary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Timecode));
370  act = ActionManager::register_action (transport_actions, X_("primary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::BBT));
372  act = ActionManager::register_action (transport_actions, X_("primary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::MinSec));
374  act = ActionManager::register_action (transport_actions, X_("primary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(primary_clock, &AudioClock::set_mode), AudioClock::Frames));
376 
377  act = ActionManager::register_action (transport_actions, X_("secondary-clock-timecode"), _("Timecode"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Timecode));
379  act = ActionManager::register_action (transport_actions, X_("secondary-clock-bbt"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::BBT));
381  act = ActionManager::register_action (transport_actions, X_("secondary-clock-minsec"), _("Minutes & Seconds"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::MinSec));
383  act = ActionManager::register_action (transport_actions, X_("secondary-clock-samples"), _("Samples"), sigc::bind (sigc::mem_fun(secondary_clock, &AudioClock::set_mode), AudioClock::Frames));
385 
386  act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchIn"), _("Punch In"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_in));
387  act->set_short_label (_("In"));
390  act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunchOut"), _("Punch Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch_out));
391  act->set_short_label (_("Out"));
394  act = ActionManager::register_toggle_action (transport_actions, X_("TogglePunch"), _("Punch In/Out"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_punch));
395  act->set_short_label (_("In/Out"));
398  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleClick"), _("Click"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_click));
401  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoInput"), _("Auto Input"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_input));
404  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoPlay"), _("Auto Play"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_play));
407  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleAutoReturn"), _("Auto Return"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_auto_return));
410  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleFollowEdits"), _("Follow Edits"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_follow_edits));
413 
414 
415  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleVideoSync"), _("Sync Startup to Video"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_video_sync));
417  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleTimeMaster"), _("Time Master"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_time_master));
419  act = ActionManager::register_toggle_action (transport_actions, X_("ToggleExternalSync"), "", sigc::mem_fun(*this, &ARDOUR_UI::toggle_external_sync));
421 
422  for (int i = 1; i <= 32; ++i) {
423  string const a = string_compose (X_("ToggleRecordEnableTrack%1"), i);
424  string const n = string_compose (_("Toggle Record Enable Track %1"), i);
425  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));
427  }
428 
429  Glib::RefPtr<ActionGroup> shuttle_actions = ActionGroup::create ("ShuttleActions");
430 
431  shuttle_actions->add (Action::create (X_("SetShuttleUnitsPercentage"), _("Percentage")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Percentage)));
432  shuttle_actions->add (Action::create (X_("SetShuttleUnitsSemitones"), _("Semitones")), hide_return (sigc::bind (sigc::mem_fun (*Config, &RCConfiguration::set_shuttle_units), Semitones)));
433 
434  Glib::RefPtr<ActionGroup> option_actions = ActionGroup::create ("options");
435 
436  act = ActionManager::register_toggle_action (option_actions, X_("SendMTC"), _("Send MTC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mtc));
438  act = ActionManager::register_toggle_action (option_actions, X_("SendMMC"), _("Send MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_mmc));
440  act = ActionManager::register_toggle_action (option_actions, X_("UseMMC"), _("Use MMC"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_use_mmc));
442  act = ActionManager::register_toggle_action (option_actions, X_("SendMidiClock"), _("Send MIDI Clock"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_clock));
444  act = ActionManager::register_toggle_action (option_actions, X_("SendMIDIfeedback"), _("Send MIDI Feedback"), sigc::mem_fun (*this, &ARDOUR_UI::toggle_send_midi_feedback));
446 
447  /* MIDI */
448 
449  Glib::RefPtr<ActionGroup> midi_actions = ActionGroup::create (X_("MIDI"));
450  ActionManager::register_action (midi_actions, X_("panic"), _("Panic"), sigc::mem_fun(*this, &ARDOUR_UI::midi_panic));
451 
452  ActionManager::add_action_group (shuttle_actions);
453  ActionManager::add_action_group (option_actions);
454  ActionManager::add_action_group (transport_actions);
455  ActionManager::add_action_group (main_actions);
456  ActionManager::add_action_group (main_menu_actions);
457  ActionManager::add_action_group (common_actions);
458  ActionManager::add_action_group (midi_actions);
459 }
460 
461 void
463 {
464  menu_bar = dynamic_cast<MenuBar*> (ActionManager::get_widget (X_("/Main")));
465  menu_bar->set_name ("MainMenuBar");
466 
467  /*
468  * This is needed because this property does not get installed
469  * until the Menu GObject class is registered, which happens
470  * when the first menu instance is created.
471  */
472  // XXX bug in gtkmm causes this to popup an error message
473  // Gtk::Settings::get_default()->property_gtk_can_change_accels() = true;
474  // so use this instead ...
475  gtk_settings_set_long_property (gtk_settings_get_default(), "gtk-can-change-accels", 1, "Ardour:designers");
476 
477  EventBox* ev = manage (new EventBox);
478  ev->show ();
479  CairoHPacker* hbox = manage (new CairoHPacker);
480  hbox->set_name (X_("StatusBarBox"));
481  hbox->show ();
482  hbox->set_border_width (3);
483 
484  VBox* vbox = manage (new VBox);
485  vbox->pack_start (*hbox, true, false);
486  vbox->show();
487 
488  ev->add (*vbox);
489 
490  wall_clock_label.set_name ("WallClock");
491  wall_clock_label.set_use_markup ();
492  disk_space_label.set_name ("WallClock");
493  disk_space_label.set_use_markup ();
494  timecode_format_label.set_name ("WallClock");
495  timecode_format_label.set_use_markup ();
496  cpu_load_label.set_name ("CPULoad");
497  cpu_load_label.set_use_markup ();
498  xrun_label.set_name ("XrunLabel");
499  xrun_label.set_use_markup ();
500  buffer_load_label.set_name ("BufferLoad");
501  buffer_load_label.set_use_markup ();
502  sample_rate_label.set_name ("SampleRate");
503  sample_rate_label.set_use_markup ();
504  format_label.set_name ("Format");
505  format_label.set_use_markup ();
506 
507 #ifndef TOP_MENUBAR
508  menu_hbox.pack_start (*menu_bar, false, false);
509 #else
510  use_menubar_as_top_menubar ();
511 #endif
512 
513  bool wall_clock = false;
514  bool disk_space = false;
515 
516  if (!Profile->get_small_screen()) {
517 #ifndef GTKOSX
518  // OSX provides its own wallclock, thank you very much
519  wall_clock = true;
520 #endif
521  disk_space = true;
522  }
523 
524  hbox->pack_end (error_alert_button, false, false, 2);
525 
526  hbox->pack_end (wall_clock_label, false, false, 2);
527  hbox->pack_end (disk_space_label, false, false, 4);
528  hbox->pack_end (xrun_label, false, false, 4);
529  hbox->pack_end (cpu_load_label, false, false, 4);
530  hbox->pack_end (buffer_load_label, false, false, 4);
531  hbox->pack_end (sample_rate_label, false, false, 4);
532  hbox->pack_end (timecode_format_label, false, false, 4);
533  hbox->pack_end (format_label, false, false, 4);
534 
535  menu_hbox.pack_end (*ev, false, false, 2);
536 
537  menu_bar_base.set_name ("MainMenuBar");
538  menu_bar_base.add (menu_hbox);
539 
540 #ifndef GTKOSX
541  _status_bar_visibility.add (&wall_clock_label, X_("WallClock"), _("Wall Clock"), wall_clock);
542 #endif
543  _status_bar_visibility.add (&disk_space_label, X_("Disk"), _("Disk Space"), disk_space);
544  _status_bar_visibility.add (&cpu_load_label, X_("DSP"), _("DSP"), true);
545  _status_bar_visibility.add (&xrun_label, X_("XRun"), _("X-run"), false);
546  _status_bar_visibility.add (&buffer_load_label, X_("Buffers"), _("Buffers"), true);
547  _status_bar_visibility.add (&sample_rate_label, X_("Audio"), _("Audio"), true);
548  _status_bar_visibility.add (&timecode_format_label, X_("TCFormat"), _("Timecode Format"), true);
549  _status_bar_visibility.add (&format_label, X_("Format"), _("File Format"), true);
550 
551  ev->signal_button_press_event().connect (sigc::mem_fun (_status_bar_visibility, &VisibilityGroup::button_press_event));
552  ev->signal_button_release_event().connect (sigc::mem_fun (*this, &ARDOUR_UI::xrun_button_release));
553 }
554 
555 void
557 {
558  Gtk::Widget* widget;
559  Application* app = Application::instance ();
560 
561  /* the addresses ("/ui/Main...") used below are based on the menu definitions in the menus file
562  */
563 
564  /* Quit will be taken care of separately */
565 
566  if ((widget = ActionManager::get_widget ("/ui/Main/Session/Quit"))) {
567  widget->hide ();
568  }
569 
570  /* Put items for About and Preferences into App menu (the
571  * ardour.menus.in file does not list them for OS X)
572  */
573 
575 
576  if ((widget = ActionManager::get_widget ("/ui/Main/Session/toggle-about"))) {
577  app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
578  }
579 
580  if ((widget = ActionManager::get_widget ("/ui/Main/Session/toggle-rc-options-editor"))) {
581  app->add_app_menu_item (group, dynamic_cast<MenuItem*>(widget));
582  }
583 
584  app->set_menu_bar (*menu_bar);
585 }
586 
587 void
589 {
590  if (!keyboard || !mixer || !editor || !meterbridge) {
591  return;
592  }
593 
594  /* XXX this is all a bit dubious. add_extra_xml() uses
595  a different lifetime model from add_instant_xml().
596  */
597 
598  XMLNode* node = new XMLNode (keyboard->get_state());
599  Config->add_extra_xml (*node);
600  Config->add_extra_xml (get_transport_controllable_state());
601 
602  XMLNode* window_node = new XMLNode (X_("UI"));
603  window_node->add_property (_status_bar_visibility.get_state_name().c_str(), _status_bar_visibility.get_state_value ());
604 
605  /* Windows */
606 
607  WM::Manager::instance().add_state (*window_node);
608 
609  /* tearoffs */
610 
611  XMLNode* tearoff_node = new XMLNode (X_("Tearoffs"));
612 
613  if (transport_tearoff) {
614  XMLNode* t = new XMLNode (X_("transport"));
615  transport_tearoff->add_state (*t);
616  tearoff_node->add_child_nocopy (*t);
617  }
618 
619  if (mixer->monitor_section()) {
620  XMLNode* t = new XMLNode (X_("monitor-section"));
621  mixer->monitor_section()->tearoff().add_state (*t);
622  tearoff_node->add_child_nocopy (*t);
623  }
624 
625  if (editor->mouse_mode_tearoff()) {
626  XMLNode* t = new XMLNode (X_("mouse-mode"));
627  editor->mouse_mode_tearoff ()->add_state (*t);
628  tearoff_node->add_child_nocopy (*t);
629  }
630 
631  window_node->add_child_nocopy (*tearoff_node);
632 
633  Config->add_extra_xml (*window_node);
634  Config->add_extra_xml (audio_midi_setup->get_state());
635 
636  Config->save_state();
637 
638  ui_config->save_state ();
639 
640  XMLNode& enode (static_cast<Stateful*>(editor)->get_state());
641  XMLNode& mnode (mixer->get_state());
642  XMLNode& bnode (meterbridge->get_state());
643 
644  if (_session) {
645  _session->add_instant_xml (enode);
646  _session->add_instant_xml (mnode);
647  _session->add_instant_xml (bnode);
648  if (location_ui) {
649  _session->add_instant_xml (location_ui->ui().get_state ());
650  }
651  } else {
652  Config->add_instant_xml (enode);
653  Config->add_instant_xml (mnode);
654  if (location_ui) {
655  Config->add_instant_xml (location_ui->ui().get_state ());
656  }
657  }
658  delete &enode;
659 
660  Keyboard::save_keybindings ();
661 }
662 
663 void
665 {
666  set_size_request_to_display_given_text (cpu_load_label, "DSP: 100.0%", 2, 2);
667  set_size_request_to_display_given_text (buffer_load_label, "Buffers: p:100% c:100%", 2, 2);
668  set_size_request_to_display_given_text (xrun_label, "X: 9999", 2, 2);
669 }
670 
671 void
673 {
674  if (editor && primary_clock) {
675  editor->present ();
676  primary_clock->focus ();
677  }
678 }
679 
680 bool
681 ARDOUR_UI::xrun_button_release (GdkEventButton* ev)
682 {
683  if (ev->button != 1 || !Keyboard::modifier_state_equals (ev->state, Keyboard::TertiaryModifier)) {
684  return false;
685  }
686 
687  if (_session) {
688  _session->reset_xrun_count ();
689  update_xrun_count ();
690  }
691  return true;
692 }
void toggle_mixer_window()
void toggle_video_sync()
bool get_mixbus() const
Definition: profile.h:53
LIBGTKMM2EXT_API Gtk::Widget * get_widget(const char *name)
Definition: actions.cc:366
void transport_roll()
Definition: ardour_ui.cc:2042
void transport_forward(int option)
Definition: ardour_ui.cc:2243
void launch_reference()
Definition: ardour_ui.cc:3302
void launch_forums()
Definition: ardour_ui.cc:3342
int create_editor()
Definition: ardour_ui_ed.cc:77
void launch_website()
Definition: ardour_ui.cc:3330
void launch_chat()
Definition: ardour_ui.cc:3284
LIBGTKMM2EXT_API void set_size_request_to_display_given_text(Gtk::Widget &w, const gchar *text, gint hpadding, gint vpadding)
Definition: utils.cc:70
int get_session_parameters(bool quit_on_cancel, bool should_be_new=false, std::string load_template="")
Definition: ardour_ui.cc:2841
void midi_panic()
Definition: ardour_ui.cc:4680
void transport_record(bool roll)
Definition: ardour_ui.cc:2009
virtual void transition_to_rolling(bool fwd)=0
Definition: ardour_ui.h:130
static ARDOUR_UI * instance()
Definition: ardour_ui.h:187
void launch_manual()
Definition: ardour_ui.cc:3296
void build_menu_bar()
static Manager & instance()
bool button_press_event(GdkEventButton *)
void export_video(bool range=false)
Definition: ardour_ui.cc:4028
void toggle_roll(bool with_abort, bool roll_out_of_bounded_mode)
Definition: ardour_ui.cc:2104
void transport_goto_start()
Definition: ardour_ui.cc:1880
Definition: Beats.hpp:239
void toggle_external_sync()
void toggle_follow_edits()
Definition: ardour_ui2.cc:753
void flush_trash()
Definition: ardour_ui.cc:3588
void toggle_send_midi_clock()
void finish()
Definition: ardour_ui.cc:1051
void transport_play_selection()
Definition: ardour_ui.cc:2197
void toggle_send_midi_feedback()
void toggle_punch_in()
virtual void stem_export()=0
typedefG_BEGIN_DECLS struct _GtkApplicationMenuGroup GtkApplicationMenuGroup
void toggle_auto_return()
void import_metadata()
Definition: ardour_ui.cc:2742
void reattach_all_tearoffs()
Definition: ardour_ui2.cc:509
#define _(Text)
Definition: i18n.h:11
void save_ardour_state()
void editor_realized()
Definition: ardour_ui2.cc:691
bool xrun_button_release(GdkEventButton *ev)
void transport_goto_zero()
Definition: ardour_ui.cc:1896
void new_midi_tracer_window()
void launch_howto_report()
Definition: ardour_ui.cc:3348
void save_state(const std::string &state_name="", bool switch_to_it=false)
Definition: ardour_ui.cc:2615
#define X_(Text)
Definition: i18n.h:13
void close_session()
Definition: ardour_ui.cc:3073
LIBARDOUR_API RCConfiguration * Config
Definition: globals.cc:119
void add_app_menu_item(GtkApplicationMenuGroup *, Gtk::MenuItem *)
void toggle_meterbridge()
void rename_session()
Definition: ardour_ui.cc:2555
Definition: amp.h:29
void use_menubar_as_top_menubar()
void cleanup()
Definition: ardour_ui.cc:3531
void toggle_use_mmc()
void toggle_record_enable(uint32_t)
Definition: ardour_ui.cc:2270
void show_ui_prefs()
Definition: ardour_ui2.cc:724
std::vector< Glib::RefPtr< Gtk::Action > > write_sensitive_actions
Definition: actions.cc:50
std::vector< Glib::RefPtr< Gtk::Action > > session_sensitive_actions
Definition: actions.cc:49
void save_session_as()
Definition: ardour_ui.cc:2409
void install_actions()
Definition: ardour_ui_ed.cc:94
void remove_video()
Definition: ardour_ui.cc:3997
void transport_numpad_decimal()
Definition: ardour_ui.cc:4760
void set_mode(Mode)
void toggle_editor_mixer()
LIBARDOUR_API RuntimeProfile * Profile
Definition: globals.cc:120
void transport_goto_end()
Definition: ardour_ui.cc:1947
void launch_website_dev()
Definition: ardour_ui.cc:3336
void edit_metadata()
Definition: ardour_ui.cc:2733
XMLProperty * add_property(const char *name, const std::string &value)
void transport_stop()
Definition: ardour_ui.cc:1964
void add_child_nocopy(XMLNode &)
Definition: xml++.cc:357
GtkApplicationMenuGroup * add_app_menu_group()
void transport_goto_wallclock()
Definition: ardour_ui.cc:1912
Definition: editor.h:134
void toggle_keep_tearoffs()
Definition: xml++.h:95
LIBGTKMM2EXT_API Glib::RefPtr< Gtk::Action > register_toggle_action(Glib::RefPtr< Gtk::ActionGroup > group, const char *name, const char *label, sigc::slot< void > sl, guint key, Gdk::ModifierType mods)
bool get_small_screen() const
Definition: profile.h:45
void launch_cheat_sheet()
Definition: ardour_ui.cc:3320
void toggle_auto_play()
virtual void export_audio()=0
Definition: debug.h:30
void toggle_punch_out()
void toggle_time_master()
void transport_numpad_event(int num)
Definition: ardour_ui.cc:4775
#define S_(Text)
Definition: i18n.h:18
void transport_rewind(int option)
Definition: ardour_ui.cc:2216
void toggle_editing_space()
void toggle_auto_input()
void toggle_send_mmc()
void open_recent_session()
Definition: ardour_ui.cc:1653
void resize_text_widgets()
void toggle_session_auto_loop()
Definition: ardour_ui.cc:2163
void add_state(XMLNode &) const
void add_extra_xml(XMLNode &)
Definition: stateful.cc:66
void snapshot_session(bool switch_to_it)
Definition: ardour_ui.cc:2479
LIBGTKMM2EXT_API void add_action_group(Glib::RefPtr< Gtk::ActionGroup >)
void add_instant_xml(XMLNode &)
void set_menu_bar(Gtk::MenuShell &)
LIBGTKMM2EXT_API Glib::RefPtr< Gtk::Action > register_action(Glib::RefPtr< Gtk::ActionGroup > group, const char *name, const char *label)
void launch_tracker()
Definition: ardour_ui.cc:3308
void add_route(Gtk::Window *float_window)
Definition: ardour_ui.cc:3660
void open_session()
Definition: ardour_ui.cc:1720
void add_video(Gtk::Window *float_window)
Definition: ardour_ui.cc:3881
std::vector< Glib::RefPtr< Gtk::Action > > transport_sensitive_actions
Definition: actions.cc:63
std::string string_compose(const std::string &fmt, const T1 &o1)
Definition: compose.h:208
void focus_on_clock()
void toggle_mixer_space()
bool main_window_state_event_handler(GdkEventWindowState *, bool window_was_editor)
void transport_play_preroll()
Definition: ardour_ui.cc:2207
void toggle_send_mtc()
void save_template()
Definition: ardour_ui.cc:2703