2 Copyright (C) 1999-2007 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"
37 #include <sys/resource.h>
39 #include <gtkmm/messagedialog.h>
40 #include <gtkmm/accelmap.h>
42 #include "pbd/error.h"
43 #include "pbd/basename.h"
44 #include "pbd/compose.h"
45 #include "pbd/failed_constructor.h"
46 #include "pbd/enumwriter.h"
47 #include "pbd/memento_command.h"
48 #include "pbd/openuri.h"
49 #include "pbd/file_utils.h"
51 #include "gtkmm2ext/application.h"
52 #include "gtkmm2ext/bindings.h"
53 #include "gtkmm2ext/gtk_ui.h"
54 #include "gtkmm2ext/utils.h"
55 #include "gtkmm2ext/click_box.h"
56 #include "gtkmm2ext/fastmeter.h"
57 #include "gtkmm2ext/popup.h"
58 #include "gtkmm2ext/window_title.h"
60 #include "midi++/manager.h"
62 #include "ardour/ardour.h"
63 #include "ardour/audioengine.h"
64 #include "ardour/audiofilesource.h"
65 #include "ardour/diskstream.h"
66 #include "ardour/filename_extensions.h"
67 #include "ardour/port.h"
68 #include "ardour/process_thread.h"
69 #include "ardour/profile.h"
70 #include "ardour/recent_sessions.h"
71 #include "ardour/session_directory.h"
72 #include "ardour/session_route.h"
73 #include "ardour/session_state_utils.h"
74 #include "ardour/session_utils.h"
76 typedef uint64_t microseconds_t;
80 #include "add_route_dialog.h"
81 #include "ambiguous_file_dialog.h"
82 #include "ardour_ui.h"
83 #include "audio_clock.h"
84 #include "bundle_manager.h"
85 #include "engine_dialog.h"
86 #include "gain_meter.h"
87 #include "global_port_matrix.h"
88 #include "gui_object.h"
89 #include "gui_thread.h"
91 #include "location_ui.h"
92 #include "main_clock.h"
93 #include "missing_file_dialog.h"
94 #include "missing_plugin_dialog.h"
97 #include "processor_box.h"
99 #include "public_editor.h"
100 #include "route_time_axis.h"
101 #include "session_metadata_dialog.h"
102 #include "shuttle_control.h"
103 #include "speaker_dialog.h"
106 #include "theme_manager.h"
107 #include "time_axis_view_item.h"
109 #include "window_proxy.h"
113 using namespace ARDOUR;
115 using namespace Gtkmm2ext;
119 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
120 UIConfiguration *ARDOUR_UI::ui_config = 0;
122 sigc::signal<void,bool> ARDOUR_UI::Blink;
123 sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
124 sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
125 sigc::signal<void, framepos_t, bool, framepos_t> ARDOUR_UI::Clock;
127 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[])
129 : Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp)
131 , gui_object_state (new GUIObjectState)
132 , primary_clock (new MainClock (X_("primary"), false, X_("transport"), true, true, true, false, true))
133 , secondary_clock (new MainClock (X_("secondary"), false, X_("secondary"), true, true, false, false, true))
137 , big_clock (new AudioClock (X_("bigclock"), false, "big", true, true, false, false))
141 , roll_controllable (new TransportControllable ("transport roll", *this, TransportControllable::Roll))
142 , stop_controllable (new TransportControllable ("transport stop", *this, TransportControllable::Stop))
143 , goto_start_controllable (new TransportControllable ("transport goto start", *this, TransportControllable::GotoStart))
144 , goto_end_controllable (new TransportControllable ("transport goto end", *this, TransportControllable::GotoEnd))
145 , auto_loop_controllable (new TransportControllable ("transport auto loop", *this, TransportControllable::AutoLoop))
146 , play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection))
147 , rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable))
149 , auto_return_button (ArdourButton::led_default_elements)
150 , auto_play_button (ArdourButton::led_default_elements)
151 , auto_input_button (ArdourButton::led_default_elements)
153 , auditioning_alert_button (_("audition"))
154 , solo_alert_button (_("solo"))
155 , feedback_alert_button (_("feedback"))
157 , error_log_button (_("Errors"))
159 , _status_bar_visibility (X_("status-bar"))
160 , _feedback_exists (false)
169 if (theArdourUI == 0) {
173 ui_config = new UIConfiguration();
174 theme_manager = new ThemeManager();
182 _session_is_new = false;
183 big_clock_window = 0;
184 big_clock_height = 0;
185 big_clock_resize_in_progress = false;
186 session_selector_window = 0;
187 last_key_press_time = 0;
188 add_route_dialog = 0;
191 rc_option_editor = 0;
192 session_option_editor = 0;
194 open_session_selector = 0;
195 have_configure_timeout = false;
196 have_disk_speed_dialog_displayed = false;
197 session_loaded = false;
198 ignore_dual_punch = false;
199 original_big_clock_width = -1;
200 original_big_clock_height = -1;
201 original_big_clock_font_size = 0;
203 roll_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
204 play_selection_button.set_elements (ArdourButton::Element (ArdourButton::Body|ArdourButton::Text));
206 roll_button.set_controllable (roll_controllable);
207 stop_button.set_controllable (stop_controllable);
208 goto_start_button.set_controllable (goto_start_controllable);
209 goto_end_button.set_controllable (goto_end_controllable);
210 auto_loop_button.set_controllable (auto_loop_controllable);
211 play_selection_button.set_controllable (play_selection_controllable);
212 rec_button.set_controllable (rec_controllable);
214 roll_button.set_name ("transport button");
215 stop_button.set_name ("transport button");
216 goto_start_button.set_name ("transport button");
217 goto_end_button.set_name ("transport button");
218 auto_loop_button.set_name ("transport button");
219 play_selection_button.set_name ("transport button");
220 rec_button.set_name ("transport recenable button");
221 midi_panic_button.set_name ("transport button");
223 goto_start_button.set_tweaks (ArdourButton::ShowClick);
224 goto_end_button.set_tweaks (ArdourButton::ShowClick);
225 midi_panic_button.set_tweaks (ArdourButton::ShowClick);
227 last_configure_time= 0;
230 ARDOUR::Diskstream::DiskOverrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
231 ARDOUR::Diskstream::DiskUnderrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
233 /* handle dialog requests */
235 ARDOUR::Session::Dialog.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_dialog, this, _1), gui_context());
237 /* handle pending state with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
239 ARDOUR::Session::AskAboutPendingState.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::pending_state_dialog, this));
241 /* handle sr mismatch with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
243 ARDOUR::Session::AskAboutSampleRateMismatch.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::sr_mismatch_dialog, this, _1, _2));
245 /* handle requests to quit (coming from JACK session) */
247 ARDOUR::Session::Quit.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::finish, this), gui_context ());
249 /* tell the user about feedback */
251 ARDOUR::Session::FeedbackDetected.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::feedback_detected, this), gui_context ());
252 ARDOUR::Session::SuccessfulGraphSort.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::successful_graph_sort, this), gui_context ());
254 /* handle requests to deal with missing files */
256 ARDOUR::Session::MissingFile.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::missing_file, this, _1, _2, _3));
258 /* and ambiguous files */
260 ARDOUR::FileSource::AmbiguousFileName.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::ambiguous_file, this, _1, _2, _3));
262 /* lets get this party started */
265 if (ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization)) {
266 throw failed_constructor ();
269 setup_gtk_ardour_enums ();
272 GainMeter::setup_slider_pix ();
273 RouteTimeAxisView::setup_slider_pix ();
274 ProcessorEntry::setup_slider_pix ();
275 SessionEvent::create_per_thread_pool ("GUI", 512);
277 } catch (failed_constructor& err) {
278 error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg;
283 /* we like keyboards */
285 keyboard = new ArdourKeyboard(*this);
287 XMLNode* node = ARDOUR_UI::instance()->keyboard_settings();
289 keyboard->set_state (*node, Stateful::loading_state_version);
292 /* we don't like certain modifiers */
293 Bindings::set_ignored_state (GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD3_MASK);
297 TimeAxisViewItem::set_constant_heights ();
299 /* The following must happen after ARDOUR::init() so that Config is set up */
301 location_ui = new ActionWindowProxy<LocationUIWindow> (X_("locations"), Config->extra_xml (X_("UI")), X_("ToggleLocations"));
302 big_clock_window = new ActionWindowProxy<Gtk::Window> (X_("bigclock"), Config->extra_xml (X_("UI")), X_("ToggleBigClock"));
303 speaker_config_window = new ActionWindowProxy<SpeakerDialog> (X_("speakerconf"), Config->extra_xml (X_("UI")), X_("toggle-speaker-config"));
305 for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
306 _global_port_matrix[*i] = new ActionWindowProxy<GlobalPortMatrixWindow> (
307 string_compose ("GlobalPortMatrix-%1", (*i).to_string()),
308 Config->extra_xml (X_("UI")),
309 string_compose ("toggle-%1-connection-manager", (*i).to_string())
315 SpeakerDialog* s = new SpeakerDialog ();
316 s->signal_unmap().connect (sigc::bind (sigc::ptr_fun (&ActionManager::uncheck_toggleaction), X_("<Actions>/Common/toggle-speaker-config")));
317 speaker_config_window->set (s);
319 starting.connect (sigc::mem_fun(*this, &ARDOUR_UI::startup));
320 stopping.connect (sigc::mem_fun(*this, &ARDOUR_UI::shutdown));
322 _process_thread = new ProcessThread ();
323 _process_thread->init ();
325 DPIReset.connect (sigc::mem_fun (*this, &ARDOUR_UI::resize_text_widgets));
328 /** @return true if a session was chosen and `apply' clicked, otherwise false if `cancel' was clicked */
330 ARDOUR_UI::run_startup (bool should_be_new, std::string load_template)
333 _startup = new ArdourStartup ();
335 XMLNode* audio_setup = Config->extra_xml ("AudioSetup");
337 if (audio_setup && _startup->engine_control()) {
338 _startup->engine_control()->set_state (*audio_setup);
341 _startup->set_new_only (should_be_new);
342 if (!load_template.empty()) {
343 _startup->set_load_template (load_template);
345 _startup->present ();
351 switch (_startup->response()) {
360 ARDOUR_UI::create_engine ()
362 // this gets called every time by new_session()
368 loading_message (_("Starting audio engine"));
371 engine = new ARDOUR::AudioEngine (ARDOUR_COMMAND_LINE::jack_client_name, ARDOUR_COMMAND_LINE::jack_session_uuid);
378 engine->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
379 engine->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
380 engine->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
382 engine->Halted.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
384 ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
392 ARDOUR_UI::post_engine ()
394 /* Things to be done once we create the AudioEngine
397 ARDOUR::init_post_engine ();
399 /* load up the UI manager */
401 ActionManager::init ();
405 if (setup_windows ()) {
406 throw failed_constructor ();
409 /* Do this after setup_windows (), as that's when the _status_bar_visibility is created */
410 XMLNode* n = Config->extra_xml (X_("UI"));
412 _status_bar_visibility.set_state (*n);
415 check_memory_locking();
417 /* this is the first point at which all the keybindings are available */
419 if (ARDOUR_COMMAND_LINE::show_key_actions) {
420 vector<string> names;
421 vector<string> paths;
422 vector<string> tooltips;
424 vector<AccelKey> bindings;
426 ActionManager::get_all_actions (names, paths, tooltips, keys, bindings);
428 vector<string>::iterator n;
429 vector<string>::iterator k;
430 for (n = names.begin(), k = keys.begin(); n != names.end(); ++n, ++k) {
431 cerr << "Action: " << (*n) << " bound to " << (*k) << endl;
437 blink_timeout_tag = -1;
439 /* this being a GUI and all, we want peakfiles */
441 AudioFileSource::set_build_peakfiles (true);
442 AudioFileSource::set_build_missing_peakfiles (true);
444 /* set default clock modes */
446 if (Profile->get_sae()) {
447 primary_clock->set_mode (AudioClock::BBT);
448 secondary_clock->set_mode (AudioClock::MinSec);
450 primary_clock->set_mode (AudioClock::Timecode);
451 secondary_clock->set_mode (AudioClock::BBT);
454 /* start the time-of-day-clock */
457 /* OS X provides a nearly-always visible wallclock, so don't be stupid */
458 update_wall_clock ();
459 Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::update_wall_clock), 60000);
462 update_disk_space ();
464 update_sample_rate (engine->frame_rate());
466 Config->ParameterChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
467 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
468 Config->map_parameters (pc);
470 /* now start and maybe save state */
472 if (do_engine_start () == 0) {
473 if (_session && _session_is_new) {
474 /* we need to retain initial visual
475 settings for a new session
477 _session->save_state ("");
482 ARDOUR_UI::~ARDOUR_UI ()
487 delete add_route_dialog;
491 ARDOUR_UI::pop_back_splash (Gtk::Window& win)
493 if (Splash::instance()) {
494 Splash::instance()->pop_back_for (win);
499 ARDOUR_UI::configure_timeout ()
501 if (last_configure_time == 0) {
502 /* no configure events yet */
506 /* force a gap of 0.5 seconds since the last configure event
509 if (get_microseconds() - last_configure_time < 500000) {
512 have_configure_timeout = false;
513 save_ardour_state ();
519 ARDOUR_UI::configure_handler (GdkEventConfigure* /*conf*/)
521 if (have_configure_timeout) {
522 last_configure_time = get_microseconds();
524 Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
525 have_configure_timeout = true;
532 ARDOUR_UI::set_transport_controllable_state (const XMLNode& node)
534 const XMLProperty* prop;
536 if ((prop = node.property ("roll")) != 0) {
537 roll_controllable->set_id (prop->value());
539 if ((prop = node.property ("stop")) != 0) {
540 stop_controllable->set_id (prop->value());
542 if ((prop = node.property ("goto-start")) != 0) {
543 goto_start_controllable->set_id (prop->value());
545 if ((prop = node.property ("goto-end")) != 0) {
546 goto_end_controllable->set_id (prop->value());
548 if ((prop = node.property ("auto-loop")) != 0) {
549 auto_loop_controllable->set_id (prop->value());
551 if ((prop = node.property ("play-selection")) != 0) {
552 play_selection_controllable->set_id (prop->value());
554 if ((prop = node.property ("rec")) != 0) {
555 rec_controllable->set_id (prop->value());
557 if ((prop = node.property ("shuttle")) != 0) {
558 shuttle_box->controllable()->set_id (prop->value());
563 ARDOUR_UI::get_transport_controllable_state ()
565 XMLNode* node = new XMLNode(X_("TransportControllables"));
568 roll_controllable->id().print (buf, sizeof (buf));
569 node->add_property (X_("roll"), buf);
570 stop_controllable->id().print (buf, sizeof (buf));
571 node->add_property (X_("stop"), buf);
572 goto_start_controllable->id().print (buf, sizeof (buf));
573 node->add_property (X_("goto_start"), buf);
574 goto_end_controllable->id().print (buf, sizeof (buf));
575 node->add_property (X_("goto_end"), buf);
576 auto_loop_controllable->id().print (buf, sizeof (buf));
577 node->add_property (X_("auto_loop"), buf);
578 play_selection_controllable->id().print (buf, sizeof (buf));
579 node->add_property (X_("play_selection"), buf);
580 rec_controllable->id().print (buf, sizeof (buf));
581 node->add_property (X_("rec"), buf);
582 shuttle_box->controllable()->id().print (buf, sizeof (buf));
583 node->add_property (X_("shuttle"), buf);
590 ARDOUR_UI::autosave_session ()
592 if (g_main_depth() > 1) {
593 /* inside a recursive main loop,
594 give up because we may not be able to
600 if (!Config->get_periodic_safety_backups()) {
605 _session->maybe_write_autosave();
612 ARDOUR_UI::update_autosave ()
614 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_autosave)
616 if (_session && _session->dirty()) {
617 if (_autosave_connection.connected()) {
618 _autosave_connection.disconnect();
621 _autosave_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &ARDOUR_UI::autosave_session),
622 Config->get_periodic_safety_backup_interval() * 1000);
625 if (_autosave_connection.connected()) {
626 _autosave_connection.disconnect();
632 ARDOUR_UI::startup ()
634 Application* app = Application::instance ();
636 app->ShouldQuit.connect (sigc::mem_fun (*this, &ARDOUR_UI::queue_finish));
637 app->ShouldLoad.connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_load));
640 call_the_mothership (VERSIONSTRING);
645 if (get_session_parameters (true, ARDOUR_COMMAND_LINE::new_session, ARDOUR_COMMAND_LINE::load_template)) {
651 goto_editor_window ();
653 /* Add the window proxies here; their addition may cause windows to be opened, and we want them
654 to be opened on top of the editor window that goto_editor_window() just opened.
656 add_window_proxy (location_ui);
657 add_window_proxy (big_clock_window);
658 for (ARDOUR::DataType::iterator i = ARDOUR::DataType::begin(); i != ARDOUR::DataType::end(); ++i) {
659 add_window_proxy (_global_port_matrix[*i]);
662 /* We have to do this here since goto_editor_window() ends up calling show_all() on the
663 * editor window, and we may want stuff to be hidden.
665 _status_bar_visibility.update ();
667 BootMessage (string_compose (_("%1 is ready for use"), PROGRAM_NAME));
671 ARDOUR_UI::no_memory_warning ()
673 XMLNode node (X_("no-memory-warning"));
674 Config->add_instant_xml (node);
678 ARDOUR_UI::check_memory_locking ()
681 /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
685 XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"));
687 if (engine->is_realtime() && memory_warning_node == 0) {
689 struct rlimit limits;
691 long pages, page_size;
693 if ((page_size = sysconf (_SC_PAGESIZE)) < 0 ||(pages = sysconf (_SC_PHYS_PAGES)) < 0) {
696 ram = (int64_t) pages * (int64_t) page_size;
699 if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
703 if (limits.rlim_cur != RLIM_INFINITY) {
705 if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
709 _("WARNING: Your system has a limit for maximum amount of locked memory. "
710 "This might cause %1 to run out of memory before your system "
711 "runs out of memory. \n\n"
712 "You can view the memory limit with 'ulimit -l', "
713 "and it is normally controlled by /etc/security/limits.conf"),
714 PROGRAM_NAME).c_str());
716 VBox* vbox = msg.get_vbox();
718 CheckButton cb (_("Do not show this window again"));
720 cb.signal_toggled().connect (sigc::mem_fun (*this, &ARDOUR_UI::no_memory_warning));
722 hbox.pack_start (cb, true, false);
723 vbox->pack_start (hbox);
728 pop_back_splash (msg);
730 editor->ensure_float (msg);
740 ARDOUR_UI::queue_finish ()
742 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::idle_finish));
746 ARDOUR_UI::idle_finish ()
749 return false; /* do not call again */
758 if (_session->transport_rolling() && (++tries < 8)) {
759 _session->request_stop (false, true);
763 if (_session->dirty()) {
764 vector<string> actions;
765 actions.push_back (_("Don't quit"));
766 actions.push_back (_("Just quit"));
767 actions.push_back (_("Save and quit"));
768 switch (ask_about_saving_session(actions)) {
773 /* use the default name */
774 if (save_state_canfail ("")) {
775 /* failed - don't quit */
776 MessageDialog msg (*editor,
778 %1 was unable to save your session.\n\n\
779 If you still wish to quit, please use the\n\n\
780 \"Just quit\" option."), PROGRAM_NAME));
781 pop_back_splash(msg);
791 second_connection.disconnect ();
792 point_one_second_connection.disconnect ();
793 point_oh_five_second_connection.disconnect ();
794 point_zero_one_second_connection.disconnect();
797 /* Save state before deleting the session, as that causes some
798 windows to be destroyed before their visible state can be
801 save_ardour_state ();
804 // _session->set_deletion_in_progress ();
805 _session->set_clean ();
806 _session->remove_pending_capture_state ();
811 ArdourDialog::close_all_dialogs ();
817 ARDOUR_UI::ask_about_saving_session (const vector<string>& actions)
819 ArdourDialog window (_("Unsaved Session"));
820 Gtk::HBox dhbox; // the hbox for the image and text
821 Gtk::Label prompt_label;
822 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG));
826 assert (actions.size() >= 3);
828 window.add_button (actions[0], RESPONSE_REJECT);
829 window.add_button (actions[1], RESPONSE_APPLY);
830 window.add_button (actions[2], RESPONSE_ACCEPT);
832 window.set_default_response (RESPONSE_ACCEPT);
834 Gtk::Button noquit_button (msg);
835 noquit_button.set_name ("EditorGTKButton");
839 if (_session->snap_name() == _session->name()) {
840 prompt = string_compose(_("The session \"%1\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
841 _session->snap_name());
843 prompt = string_compose(_("The snapshot \"%1\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
844 _session->snap_name());
847 prompt_label.set_text (prompt);
848 prompt_label.set_name (X_("PrompterLabel"));
849 prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP);
851 dimage->set_alignment(ALIGN_CENTER, ALIGN_TOP);
852 dhbox.set_homogeneous (false);
853 dhbox.pack_start (*dimage, false, false, 5);
854 dhbox.pack_start (prompt_label, true, false, 5);
855 window.get_vbox()->pack_start (dhbox);
857 window.set_name (_("Prompter"));
858 window.set_position (Gtk::WIN_POS_MOUSE);
859 window.set_modal (true);
860 window.set_resizable (false);
866 window.set_keep_above (true);
869 ResponseType r = (ResponseType) window.run();
874 case RESPONSE_ACCEPT: // save and get out of here
876 case RESPONSE_APPLY: // get out of here
886 ARDOUR_UI::every_second ()
889 update_buffer_load ();
890 update_disk_space ();
895 ARDOUR_UI::every_point_one_seconds ()
897 shuttle_box->update_speed_display ();
898 RapidScreenUpdate(); /* EMIT_SIGNAL */
903 ARDOUR_UI::every_point_zero_one_seconds ()
905 // august 2007: actual update frequency: 40Hz, not 100Hz
907 SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
912 ARDOUR_UI::update_sample_rate (framecnt_t)
916 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_sample_rate, ignored)
918 if (!engine->connected()) {
920 snprintf (buf, sizeof (buf), "%s", _("disconnected"));
924 framecnt_t rate = engine->frame_rate();
926 if (fmod (rate, 1000.0) != 0.0) {
927 snprintf (buf, sizeof (buf), _("JACK: <span foreground=\"green\">%.1f kHz / %4.1f ms</span>"),
928 (float) rate/1000.0f,
929 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
931 snprintf (buf, sizeof (buf), _("JACK: <span foreground=\"green\">%" PRId64 " kHz / %4.1f ms</span>"),
933 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
937 sample_rate_label.set_markup (buf);
941 ARDOUR_UI::update_format ()
944 format_label.set_text ("");
949 s << _("File:") << X_(" <span foreground=\"green\">");
951 switch (_session->config.get_native_file_header_format ()) {
977 switch (_session->config.get_native_file_data_format ()) {
991 format_label.set_markup (s.str ());
995 ARDOUR_UI::update_cpu_load ()
999 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1000 should also be changed.
1003 float const c = engine->get_cpu_load ();
1004 snprintf (buf, sizeof (buf), _("DSP: <span foreground=\"%s\">%5.1f%%</span>"), c >= 90 ? X_("red") : X_("green"), c);
1005 cpu_load_label.set_markup (buf);
1009 ARDOUR_UI::update_buffer_load ()
1013 uint32_t const playback = _session ? _session->playback_load () : 100;
1014 uint32_t const capture = _session ? _session->capture_load () : 100;
1016 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1017 should also be changed.
1023 _("Buffers: <span foreground=\"green\">p:</span><span foreground=\"%s\">%" PRIu32 "%%</span> "
1024 "<span foreground=\"green\">c:</span><span foreground=\"%s\">%" PRIu32 "%%</span>"),
1025 playback <= 5 ? X_("red") : X_("green"),
1027 capture <= 5 ? X_("red") : X_("green"),
1031 buffer_load_label.set_markup (buf);
1033 buffer_load_label.set_text ("");
1038 ARDOUR_UI::count_recenabled_streams (Route& route)
1040 Track* track = dynamic_cast<Track*>(&route);
1041 if (track && track->record_enabled()) {
1042 rec_enabled_streams += track->n_inputs().n_total();
1047 ARDOUR_UI::update_disk_space()
1049 if (_session == 0) {
1053 framecnt_t frames = _session->available_capture_duration();
1055 framecnt_t fr = _session->frame_rate();
1057 if (frames == max_framecnt) {
1058 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
1060 rec_enabled_streams = 0;
1061 _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
1063 if (rec_enabled_streams) {
1064 frames /= rec_enabled_streams;
1071 hrs = frames / (fr * 3600);
1074 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">>24 hrs</span>"));
1076 frames -= hrs * fr * 3600;
1077 mins = frames / (fr * 60);
1078 frames -= mins * fr * 60;
1081 bool const low = (hrs == 0 && mins <= 30);
1085 _("Disk: <span foreground=\"%s\">%02dh:%02dm:%02ds</span>"),
1086 low ? X_("red") : X_("green"),
1092 disk_space_label.set_markup (buf);
1096 ARDOUR_UI::update_wall_clock ()
1103 tm_now = localtime (&now);
1105 sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
1106 wall_clock_label.set_text (buf);
1112 ARDOUR_UI::redisplay_recent_sessions ()
1114 std::vector<sys::path> session_directories;
1115 RecentSessionsSorter cmp;
1117 recent_session_display.set_model (Glib::RefPtr<TreeModel>(0));
1118 recent_session_model->clear ();
1120 ARDOUR::RecentSessions rs;
1121 ARDOUR::read_recent_sessions (rs);
1124 recent_session_display.set_model (recent_session_model);
1128 // sort them alphabetically
1129 sort (rs.begin(), rs.end(), cmp);
1131 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
1132 session_directories.push_back ((*i).second);
1135 for (vector<sys::path>::const_iterator i = session_directories.begin();
1136 i != session_directories.end(); ++i)
1138 std::vector<sys::path> state_file_paths;
1140 // now get available states for this session
1142 get_state_files_in_directory (*i, state_file_paths);
1144 vector<string*>* states;
1145 vector<const gchar*> item;
1146 string fullpath = i->to_string();
1148 /* remove any trailing / */
1150 if (fullpath[fullpath.length() - 1] == '/') {
1151 fullpath = fullpath.substr (0, fullpath.length() - 1);
1154 /* check whether session still exists */
1155 if (!Glib::file_test(fullpath.c_str(), Glib::FILE_TEST_EXISTS)) {
1156 /* session doesn't exist */
1160 /* now get available states for this session */
1162 if ((states = Session::possible_states (fullpath)) == 0) {
1163 /* no state file? */
1167 std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
1169 Gtk::TreeModel::Row row = *(recent_session_model->append());
1171 row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
1172 row[recent_session_columns.fullpath] = fullpath;
1174 if (state_file_names.size() > 1) {
1178 for (std::vector<std::string>::iterator i2 = state_file_names.begin();
1179 i2 != state_file_names.end(); ++i2)
1182 Gtk::TreeModel::Row child_row = *(recent_session_model->append (row.children()));
1184 child_row[recent_session_columns.visible_name] = *i2;
1185 child_row[recent_session_columns.fullpath] = fullpath;
1190 recent_session_display.set_tooltip_column(1); // recent_session_columns.fullpath
1191 recent_session_display.set_model (recent_session_model);
1195 ARDOUR_UI::build_session_selector ()
1197 session_selector_window = new ArdourDialog (_("Recent Sessions"));
1199 Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow);
1201 session_selector_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1202 session_selector_window->add_button (Stock::OPEN, RESPONSE_ACCEPT);
1203 session_selector_window->set_default_response (RESPONSE_ACCEPT);
1204 recent_session_model = TreeStore::create (recent_session_columns);
1205 recent_session_display.set_model (recent_session_model);
1206 recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
1207 recent_session_display.set_headers_visible (false);
1208 recent_session_display.get_selection()->set_mode (SELECTION_BROWSE);
1209 recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
1211 scroller->add (recent_session_display);
1212 scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1214 session_selector_window->set_name ("SessionSelectorWindow");
1215 session_selector_window->set_size_request (200, 400);
1216 session_selector_window->get_vbox()->pack_start (*scroller);
1218 recent_session_display.show();
1223 ARDOUR_UI::recent_session_row_activated (const TreePath& /*path*/, TreeViewColumn* /*col*/)
1225 session_selector_window->response (RESPONSE_ACCEPT);
1229 ARDOUR_UI::open_recent_session ()
1231 bool can_return = (_session != 0);
1233 if (session_selector_window == 0) {
1234 build_session_selector ();
1237 redisplay_recent_sessions ();
1241 session_selector_window->set_position (WIN_POS_MOUSE);
1243 ResponseType r = (ResponseType) session_selector_window->run ();
1246 case RESPONSE_ACCEPT:
1250 session_selector_window->hide();
1257 if (recent_session_display.get_selection()->count_selected_rows() == 0) {
1261 session_selector_window->hide();
1263 Gtk::TreeModel::iterator i = recent_session_display.get_selection()->get_selected();
1265 if (i == recent_session_model->children().end()) {
1269 std::string path = (*i)[recent_session_columns.fullpath];
1270 std::string state = (*i)[recent_session_columns.visible_name];
1272 _session_is_new = false;
1274 if (load_session (path, state) == 0) {
1283 ARDOUR_UI::check_audioengine ()
1286 if (!engine->connected()) {
1287 MessageDialog msg (string_compose (
1288 _("%1 is not connected to JACK\n"
1289 "You cannot open or close sessions in this condition"),
1291 pop_back_splash (msg);
1302 ARDOUR_UI::open_session ()
1304 if (!check_audioengine()) {
1309 /* popup selector window */
1311 if (open_session_selector == 0) {
1313 /* ardour sessions are folders */
1315 open_session_selector = new Gtk::FileChooserDialog (_("Open Session"), FILE_CHOOSER_ACTION_OPEN);
1316 open_session_selector->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1317 open_session_selector->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
1318 open_session_selector->set_default_response(Gtk::RESPONSE_ACCEPT);
1321 string session_parent_dir = Glib::path_get_dirname(_session->path());
1322 string::size_type last_dir_sep = session_parent_dir.rfind(G_DIR_SEPARATOR);
1323 session_parent_dir = session_parent_dir.substr(0, last_dir_sep);
1324 open_session_selector->set_current_folder(session_parent_dir);
1326 open_session_selector->set_current_folder(Config->get_default_session_parent_dir());
1329 open_session_selector->add_shortcut_folder (Config->get_default_session_parent_dir());
1331 FileFilter session_filter;
1332 session_filter.add_pattern ("*.ardour");
1333 session_filter.set_name (string_compose (_("%1 sessions"), PROGRAM_NAME));
1334 open_session_selector->add_filter (session_filter);
1335 open_session_selector->set_filter (session_filter);
1338 int response = open_session_selector->run();
1339 open_session_selector->hide ();
1342 case RESPONSE_ACCEPT:
1345 open_session_selector->hide();
1349 open_session_selector->hide();
1350 string session_path = open_session_selector->get_filename();
1354 if (session_path.length() > 0) {
1355 if (ARDOUR::find_session (session_path, path, name, isnew) == 0) {
1356 _session_is_new = isnew;
1357 load_session (path, name);
1364 ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
1366 list<boost::shared_ptr<MidiTrack> > tracks;
1368 if (_session == 0) {
1369 warning << _("You cannot add a track without a session already loaded.") << endmsg;
1376 tracks = _session->new_midi_track (instrument, ARDOUR::Normal, route_group, how_many, name_template);
1378 if (tracks.size() != how_many) {
1379 if (how_many == 1) {
1380 error << _("could not create a new midi track") << endmsg;
1382 error << string_compose (_("could not create %1 new midi tracks"), how_many) << endmsg;
1390 MessageDialog msg (*editor,
1391 string_compose (_("There are insufficient JACK ports available\n\
1392 to create a new track or bus.\n\
1393 You should save %1, exit and\n\
1394 restart JACK with more ports."), PROGRAM_NAME));
1401 ARDOUR_UI::session_add_audio_route (
1403 int32_t input_channels,
1404 int32_t output_channels,
1405 ARDOUR::TrackMode mode,
1406 RouteGroup* route_group,
1408 string const & name_template
1411 list<boost::shared_ptr<AudioTrack> > tracks;
1414 if (_session == 0) {
1415 warning << _("You cannot add a track or bus without a session already loaded.") << endmsg;
1421 tracks = _session->new_audio_track (input_channels, output_channels, mode, route_group, how_many, name_template);
1423 if (tracks.size() != how_many) {
1424 if (how_many == 1) {
1425 error << _("could not create a new audio track") << endmsg;
1427 error << string_compose (_("could only create %1 of %2 new audio %3"),
1428 tracks.size(), how_many, (track ? _("tracks") : _("busses"))) << endmsg;
1434 routes = _session->new_audio_route (input_channels, output_channels, route_group, how_many, name_template);
1436 if (routes.size() != how_many) {
1437 if (how_many == 1) {
1438 error << _("could not create a new audio bus") << endmsg;
1440 error << string_compose (_("could not create %1 new audio busses"), how_many) << endmsg;
1447 MessageDialog msg (*editor,
1448 string_compose (_("There are insufficient JACK ports available\n\
1449 to create a new track or bus.\n\
1450 You should save %1, exit and\n\
1451 restart JACK with more ports."), PROGRAM_NAME));
1452 pop_back_splash (msg);
1458 ARDOUR_UI::transport_goto_start ()
1461 _session->goto_start();
1463 /* force displayed area in editor to start no matter
1464 what "follow playhead" setting is.
1468 editor->center_screen (_session->current_start_frame ());
1474 ARDOUR_UI::transport_goto_zero ()
1477 _session->request_locate (0);
1479 /* force displayed area in editor to start no matter
1480 what "follow playhead" setting is.
1484 editor->reset_x_origin (0);
1490 ARDOUR_UI::transport_goto_wallclock ()
1492 if (_session && editor) {
1499 localtime_r (&now, &tmnow);
1501 frames = tmnow.tm_hour * (60 * 60 * _session->frame_rate());
1502 frames += tmnow.tm_min * (60 * _session->frame_rate());
1503 frames += tmnow.tm_sec * _session->frame_rate();
1505 _session->request_locate (frames, _session->transport_rolling ());
1507 /* force displayed area in editor to start no matter
1508 what "follow playhead" setting is.
1512 editor->center_screen (frames);
1518 ARDOUR_UI::transport_goto_end ()
1521 framepos_t const frame = _session->current_end_frame();
1522 _session->request_locate (frame);
1524 /* force displayed area in editor to start no matter
1525 what "follow playhead" setting is.
1529 editor->center_screen (frame);
1535 ARDOUR_UI::transport_stop ()
1541 if (_session->is_auditioning()) {
1542 _session->cancel_audition ();
1546 _session->request_stop (false, true);
1550 ARDOUR_UI::transport_record (bool roll)
1554 switch (_session->record_status()) {
1555 case Session::Disabled:
1556 if (_session->ntracks() == 0) {
1557 MessageDialog msg (*editor, _("Please create one or more tracks before trying to record.\nYou can do this with the \"Add Track or Bus\" option in the Session menu."));
1561 _session->maybe_enable_record ();
1566 case Session::Recording:
1568 _session->request_stop();
1570 _session->disable_record (false, true);
1574 case Session::Enabled:
1575 _session->disable_record (false, true);
1581 ARDOUR_UI::transport_roll ()
1587 if (_session->is_auditioning()) {
1592 if (_session->config.get_external_sync()) {
1593 switch (_session->config.get_sync_source()) {
1597 /* transport controlled by the master */
1603 bool rolling = _session->transport_rolling();
1605 if (_session->get_play_loop()) {
1606 /* XXX it is not possible to just leave seamless loop and keep
1607 playing at present (nov 4th 2009)
1609 if (!Config->get_seamless_loop()) {
1610 _session->request_play_loop (false, true);
1612 } else if (_session->get_play_range () && !Config->get_always_play_range()) {
1613 /* stop playing a range if we currently are */
1614 _session->request_play_range (0, true);
1617 if (Config->get_always_play_range()) {
1618 _session->request_play_range (&editor->get_selection().time, true);
1622 _session->request_transport_speed (1.0f);
1627 ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
1634 if (_session->is_auditioning()) {
1635 _session->cancel_audition ();
1639 if (_session->config.get_external_sync()) {
1640 switch (_session->config.get_sync_source()) {
1644 /* transport controlled by the master */
1649 bool rolling = _session->transport_rolling();
1650 bool affect_transport = true;
1652 if (rolling && roll_out_of_bounded_mode) {
1653 /* drop out of loop/range playback but leave transport rolling */
1654 if (_session->get_play_loop()) {
1655 if (Config->get_seamless_loop()) {
1656 /* the disk buffers contain copies of the loop - we can't
1657 just keep playing, so stop the transport. the user
1658 can restart as they wish.
1660 affect_transport = true;
1662 /* disk buffers are normal, so we can keep playing */
1663 affect_transport = false;
1665 _session->request_play_loop (false, true);
1666 } else if (_session->get_play_range ()) {
1667 affect_transport = false;
1668 _session->request_play_range (0, true);
1672 if (affect_transport) {
1674 _session->request_stop (with_abort, true);
1676 if (Config->get_always_play_range ()) {
1677 _session->request_play_range (&editor->get_selection().time, true);
1680 _session->request_transport_speed (1.0f);
1686 ARDOUR_UI::toggle_session_auto_loop ()
1688 Location * looploc = _session->locations()->auto_loop_location();
1690 if (!_session || !looploc) {
1694 if (_session->get_play_loop()) {
1696 if (_session->transport_rolling()) {
1698 _session->request_locate (looploc->start(), true);
1699 _session->request_play_loop (false);
1702 _session->request_play_loop (false);
1705 _session->request_play_loop (true);
1708 //show the loop markers
1709 looploc->set_hidden (false, this);
1713 ARDOUR_UI::transport_play_selection ()
1719 editor->play_selection ();
1723 ARDOUR_UI::transport_rewind (int option)
1725 float current_transport_speed;
1728 current_transport_speed = _session->transport_speed();
1730 if (current_transport_speed >= 0.0f) {
1733 _session->request_transport_speed (-1.0f);
1736 _session->request_transport_speed (-4.0f);
1739 _session->request_transport_speed (-0.5f);
1744 _session->request_transport_speed (current_transport_speed * 1.5f);
1750 ARDOUR_UI::transport_forward (int option)
1756 float current_transport_speed = _session->transport_speed();
1758 if (current_transport_speed <= 0.0f) {
1761 _session->request_transport_speed (1.0f);
1764 _session->request_transport_speed (4.0f);
1767 _session->request_transport_speed (0.5f);
1772 _session->request_transport_speed (current_transport_speed * 1.5f);
1777 ARDOUR_UI::toggle_record_enable (uint32_t rid)
1783 boost::shared_ptr<Route> r;
1785 if ((r = _session->route_by_remote_id (rid)) != 0) {
1789 if ((t = dynamic_cast<Track*>(r.get())) != 0) {
1790 t->set_record_enabled (!t->record_enabled(), this);
1796 ARDOUR_UI::map_transport_state ()
1799 auto_loop_button.unset_active_state ();
1800 play_selection_button.unset_active_state ();
1801 roll_button.unset_active_state ();
1802 stop_button.set_active_state (Gtkmm2ext::ExplicitActive);
1806 shuttle_box->map_transport_state ();
1808 float sp = _session->transport_speed();
1814 if (_session->get_play_range()) {
1816 play_selection_button.set_active_state (Gtkmm2ext::ExplicitActive);
1817 roll_button.unset_active_state ();
1818 auto_loop_button.unset_active_state ();
1820 } else if (_session->get_play_loop ()) {
1822 auto_loop_button.set_active (true);
1823 play_selection_button.set_active (false);
1824 roll_button.set_active (false);
1828 roll_button.set_active (true);
1829 play_selection_button.set_active (false);
1830 auto_loop_button.set_active (false);
1833 if (Config->get_always_play_range()) {
1834 /* light up both roll and play-selection if they are joined */
1835 roll_button.set_active (true);
1836 play_selection_button.set_active (true);
1839 stop_button.set_active (false);
1843 stop_button.set_active (true);
1844 roll_button.set_active (false);
1845 play_selection_button.set_active (false);
1846 auto_loop_button.set_active (false);
1847 update_disk_space ();
1852 ARDOUR_UI::engine_stopped ()
1854 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_stopped)
1855 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1856 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1860 ARDOUR_UI::engine_running ()
1862 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_running)
1863 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
1864 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
1866 Glib::RefPtr<Action> action;
1867 const char* action_name = 0;
1869 switch (engine->frames_per_cycle()) {
1871 action_name = X_("JACKLatency32");
1874 action_name = X_("JACKLatency64");
1877 action_name = X_("JACKLatency128");
1880 action_name = X_("JACKLatency512");
1883 action_name = X_("JACKLatency1024");
1886 action_name = X_("JACKLatency2048");
1889 action_name = X_("JACKLatency4096");
1892 action_name = X_("JACKLatency8192");
1895 /* XXX can we do anything useful ? */
1901 action = ActionManager::get_action (X_("JACK"), action_name);
1904 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (action);
1905 ract->set_active ();
1911 ARDOUR_UI::engine_halted (const char* reason, bool free_reason)
1913 if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
1914 /* we can't rely on the original string continuing to exist when we are called
1915 again in the GUI thread, so make a copy and note that we need to
1918 char *copy = strdup (reason);
1919 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&ARDOUR_UI::engine_halted, this, copy, true));
1923 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1924 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1926 update_sample_rate (0);
1930 /* if the reason is a non-empty string, it means that the backend was shutdown
1931 rather than just Ardour.
1934 if (strlen (reason)) {
1935 msgstr = string_compose (_("The audio backend (JACK) was shutdown because:\n\n%1"), reason);
1937 msgstr = string_compose (_("\
1938 JACK has either been shutdown or it\n\
1939 disconnected %1 because %1\n\
1940 was not fast enough. Try to restart\n\
1941 JACK, reconnect and save the session."), PROGRAM_NAME);
1944 MessageDialog msg (*editor, msgstr);
1945 pop_back_splash (msg);
1949 free ((char*) reason);
1954 ARDOUR_UI::do_engine_start ()
1962 error << _("Unable to start the session running")
1972 ARDOUR_UI::update_clocks ()
1974 if (!editor || !editor->dragging_playhead()) {
1975 Clock (_session->audible_frame(), false, editor->get_preferred_edit_position()); /* EMIT_SIGNAL */
1980 ARDOUR_UI::start_clocking ()
1982 clock_signal_connection = RapidScreenUpdate.connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
1986 ARDOUR_UI::stop_clocking ()
1988 clock_signal_connection.disconnect ();
1992 ARDOUR_UI::_blink (void *arg)
1994 ((ARDOUR_UI *) arg)->blink ();
2001 Blink (blink_on = !blink_on); /* EMIT_SIGNAL */
2005 ARDOUR_UI::start_blinking ()
2007 /* Start the blink signal. Everybody with a blinking widget
2008 uses Blink to drive the widget's state.
2011 if (blink_timeout_tag < 0) {
2013 blink_timeout_tag = g_timeout_add (240, _blink, this);
2018 ARDOUR_UI::stop_blinking ()
2020 if (blink_timeout_tag >= 0) {
2021 g_source_remove (blink_timeout_tag);
2022 blink_timeout_tag = -1;
2027 /** Ask the user for the name of a new snapshot and then take it.
2031 ARDOUR_UI::snapshot_session (bool switch_to_it)
2033 ArdourPrompter prompter (true);
2036 prompter.set_name ("Prompter");
2037 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2038 prompter.set_title (_("Take Snapshot"));
2039 prompter.set_prompt (_("Name of new snapshot"));
2041 if (!switch_to_it) {
2044 struct tm local_time;
2047 localtime_r (&n, &local_time);
2048 strftime (timebuf, sizeof(timebuf), "%FT%H.%M.%S", &local_time);
2049 prompter.set_initial_text (timebuf);
2053 switch (prompter.run()) {
2054 case RESPONSE_ACCEPT:
2056 prompter.get_result (snapname);
2058 bool do_save = (snapname.length() != 0);
2061 char illegal = Session::session_name_is_legal(snapname);
2063 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2064 "snapshot names may not contain a '%1' character"), illegal));
2070 vector<sys::path> p;
2071 get_state_files_in_directory (_session->session_directory().root_path(), p);
2072 vector<string> n = get_file_names_no_extension (p);
2073 if (find (n.begin(), n.end(), snapname) != n.end()) {
2075 ArdourDialog confirm (_("Confirm Snapshot Overwrite"), true);
2076 Label m (_("A snapshot already exists with that name. Do you want to overwrite it?"));
2077 confirm.get_vbox()->pack_start (m, true, true);
2078 confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2079 confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
2080 confirm.show_all ();
2081 switch (confirm.run()) {
2082 case RESPONSE_CANCEL:
2088 save_state (snapname, switch_to_it);
2098 /** Ask the user for a new session name and then rename the session to it.
2102 ARDOUR_UI::rename_session ()
2108 ArdourPrompter prompter (true);
2111 prompter.set_name ("Prompter");
2112 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2113 prompter.set_title (_("Rename Session"));
2114 prompter.set_prompt (_("New session name"));
2117 switch (prompter.run()) {
2118 case RESPONSE_ACCEPT:
2120 prompter.get_result (name);
2122 bool do_rename = (name.length() != 0);
2125 char illegal = Session::session_name_is_legal (name);
2128 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2129 "session names may not contain a '%1' character"), illegal));
2134 switch (_session->rename (name)) {
2136 MessageDialog msg (_("That name is already in use by another directory/folder. Please try again."));
2137 msg.set_position (WIN_POS_MOUSE);
2145 MessageDialog msg (_("Renaming this session failed.\nThings could be seriously messed up at this point"));
2146 msg.set_position (WIN_POS_MOUSE);
2162 ARDOUR_UI::save_state (const string & name, bool switch_to_it)
2164 XMLNode* node = new XMLNode (X_("UI"));
2166 for (list<WindowProxyBase*>::iterator i = _window_proxies.begin(); i != _window_proxies.end(); ++i) {
2167 if (!(*i)->rc_configured()) {
2168 node->add_child_nocopy (*((*i)->get_state ()));
2172 node->add_child_nocopy (gui_object_state->get_state());
2174 _session->add_extra_xml (*node);
2176 save_state_canfail (name, switch_to_it);
2180 ARDOUR_UI::save_state_canfail (string name, bool switch_to_it)
2185 if (name.length() == 0) {
2186 name = _session->snap_name();
2189 if ((ret = _session->save_state (name, false, switch_to_it)) != 0) {
2194 save_ardour_state (); /* XXX cannot fail? yeah, right ... */
2199 ARDOUR_UI::primary_clock_value_changed ()
2202 _session->request_locate (primary_clock->current_time ());
2207 ARDOUR_UI::big_clock_value_changed ()
2210 _session->request_locate (big_clock->current_time ());
2215 ARDOUR_UI::secondary_clock_value_changed ()
2218 _session->request_locate (secondary_clock->current_time ());
2223 ARDOUR_UI::transport_rec_enable_blink (bool onoff)
2225 if (_session == 0) {
2229 if (_session->step_editing()) {
2233 Session::RecordState const r = _session->record_status ();
2234 bool const h = _session->have_rec_enabled_track ();
2236 if (r == Session::Enabled || (r == Session::Recording && !h)) {
2238 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2240 rec_button.set_active_state (Gtkmm2ext::ImplicitActive);
2242 } else if (r == Session::Recording && h) {
2243 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2245 rec_button.unset_active_state ();
2250 ARDOUR_UI::save_template ()
2252 ArdourPrompter prompter (true);
2255 if (!check_audioengine()) {
2259 prompter.set_name (X_("Prompter"));
2260 prompter.set_title (_("Save Template"));
2261 prompter.set_prompt (_("Name for template:"));
2262 prompter.set_initial_text(_session->name() + _("-template"));
2263 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2265 switch (prompter.run()) {
2266 case RESPONSE_ACCEPT:
2267 prompter.get_result (name);
2269 if (name.length()) {
2270 _session->save_template (name);
2280 ARDOUR_UI::edit_metadata ()
2282 SessionMetadataEditor dialog;
2283 dialog.set_session (_session);
2284 editor->ensure_float (dialog);
2289 ARDOUR_UI::import_metadata ()
2291 SessionMetadataImporter dialog;
2292 dialog.set_session (_session);
2293 editor->ensure_float (dialog);
2298 ARDOUR_UI::ask_about_loading_existing_session (const std::string& session_path)
2300 std::string str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
2302 MessageDialog msg (str,
2304 Gtk::MESSAGE_WARNING,
2305 Gtk::BUTTONS_YES_NO,
2309 msg.set_name (X_("OpenExistingDialog"));
2310 msg.set_title (_("Open Existing Session"));
2311 msg.set_wmclass (X_("existing_session"), PROGRAM_NAME);
2312 msg.set_position (Gtk::WIN_POS_MOUSE);
2313 pop_back_splash (msg);
2315 switch (msg.run()) {
2324 ARDOUR_UI::build_session_from_nsd (const std::string& session_path, const std::string& session_name)
2326 BusProfile bus_profile;
2328 if (Profile->get_sae()) {
2330 bus_profile.master_out_channels = 2;
2331 bus_profile.input_ac = AutoConnectPhysical;
2332 bus_profile.output_ac = AutoConnectMaster;
2333 bus_profile.requested_physical_in = 0; // use all available
2334 bus_profile.requested_physical_out = 0; // use all available
2338 /* get settings from advanced section of NSD */
2340 if (_startup->create_master_bus()) {
2341 bus_profile.master_out_channels = (uint32_t) _startup->master_channel_count();
2343 bus_profile.master_out_channels = 0;
2346 if (_startup->connect_inputs()) {
2347 bus_profile.input_ac = AutoConnectPhysical;
2349 bus_profile.input_ac = AutoConnectOption (0);
2352 bus_profile.output_ac = AutoConnectOption (0);
2354 if (_startup->connect_outputs ()) {
2355 if (_startup->connect_outs_to_master()) {
2356 bus_profile.output_ac = AutoConnectMaster;
2357 } else if (_startup->connect_outs_to_physical()) {
2358 bus_profile.output_ac = AutoConnectPhysical;
2362 bus_profile.requested_physical_in = (uint32_t) _startup->input_limit_count();
2363 bus_profile.requested_physical_out = (uint32_t) _startup->output_limit_count();
2366 if (build_session (session_path, session_name, bus_profile)) {
2374 ARDOUR_UI::idle_load (const std::string& path)
2377 if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
2378 /* /path/to/foo => /path/to/foo, foo */
2379 load_session (path, basename_nosuffix (path));
2381 /* /path/to/foo/foo.ardour => /path/to/foo, foo */
2382 load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
2386 ARDOUR_COMMAND_LINE::session_name = path;
2391 ARDOUR_UI::loading_message (const std::string& msg)
2393 if (ARDOUR_COMMAND_LINE::no_splash) {
2399 splash->message (msg);
2404 /** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */
2406 ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, string load_template)
2408 string session_name;
2409 string session_path;
2410 string template_name;
2412 bool likely_new = false;
2414 if (!load_template.empty()) {
2415 should_be_new = true;
2416 template_name = load_template;
2421 if (!should_be_new && !ARDOUR_COMMAND_LINE::session_name.empty()) {
2423 /* if they named a specific statefile, use it, otherwise they are
2424 just giving a session folder, and we want to use it as is
2425 to find the session.
2428 string::size_type suffix = ARDOUR_COMMAND_LINE::session_name.find (statefile_suffix);
2430 if (suffix != string::npos) {
2431 session_path = Glib::path_get_dirname (ARDOUR_COMMAND_LINE::session_name);
2432 session_name = ARDOUR_COMMAND_LINE::session_name.substr (0, suffix);
2433 session_name = Glib::path_get_basename (session_name);
2435 session_path = ARDOUR_COMMAND_LINE::session_name;
2436 session_name = Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name);
2441 bool const apply = run_startup (should_be_new, load_template);
2444 if (quit_on_cancel) {
2451 /* if we run the startup dialog again, offer more than just "new session" */
2453 should_be_new = false;
2455 session_name = _startup->session_name (likely_new);
2457 string::size_type suffix = session_name.find (statefile_suffix);
2459 if (suffix != string::npos) {
2460 session_name = session_name.substr (0, suffix);
2463 /* this shouldn't happen, but we catch it just in case it does */
2465 if (session_name.empty()) {
2469 if (_startup->use_session_template()) {
2470 template_name = _startup->session_template_name();
2471 _session_is_new = true;
2474 if (session_name[0] == G_DIR_SEPARATOR ||
2475 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == G_DIR_SEPARATOR) ||
2476 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == G_DIR_SEPARATOR)) {
2478 /* absolute path or cwd-relative path specified for session name: infer session folder
2479 from what was given.
2482 session_path = Glib::path_get_dirname (session_name);
2483 session_name = Glib::path_get_basename (session_name);
2487 session_path = _startup->session_folder();
2489 char illegal = Session::session_name_is_legal (session_name);
2492 MessageDialog msg (*_startup,
2493 string_compose (_("To ensure compatibility with various systems\n"
2494 "session names may not contain a '%1' character"),
2497 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2503 if (create_engine ()) {
2507 if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
2511 std::string existing = Glib::build_filename (session_path, session_name);
2513 if (!ask_about_loading_existing_session (existing)) {
2514 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2519 _session_is_new = false;
2525 pop_back_splash (*_startup);
2530 MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
2532 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2536 char illegal = Session::session_name_is_legal(session_name);
2538 pop_back_splash (*_startup);
2539 MessageDialog msg (*_startup, string_compose(_("To ensure compatibility with various systems\n"
2540 "session names may not contain a '%1' character"), illegal));
2542 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2546 _session_is_new = true;
2549 if (likely_new && template_name.empty()) {
2551 ret = build_session_from_nsd (session_path, session_name);
2555 ret = load_session (session_path, session_name, template_name);
2558 /* not connected to the AudioEngine, so quit to avoid an infinite loop */
2562 if (!ARDOUR_COMMAND_LINE::immediate_save.empty()) {
2563 _session->save_state (ARDOUR_COMMAND_LINE::immediate_save, false);
2573 ARDOUR_UI::close_session()
2575 if (!check_audioengine()) {
2579 if (unload_session (true)) {
2583 ARDOUR_COMMAND_LINE::session_name = "";
2585 if (get_session_parameters (true, false)) {
2589 goto_editor_window ();
2592 /** @param snap_name Snapshot name (without .ardour suffix).
2593 * @return -2 if the load failed because we are not connected to the AudioEngine.
2596 ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, std::string mix_template)
2598 Session *new_session;
2602 session_loaded = false;
2604 if (!check_audioengine()) {
2608 unload_status = unload_session ();
2610 if (unload_status < 0) {
2612 } else if (unload_status > 0) {
2617 loading_message (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
2620 new_session = new Session (*engine, path, snap_name, 0, mix_template);
2623 /* this one is special */
2625 catch (AudioEngine::PortRegistrationFailure& err) {
2627 MessageDialog msg (err.what(),
2630 Gtk::BUTTONS_CLOSE);
2632 msg.set_title (_("Port Registration Error"));
2633 msg.set_secondary_text (_("Click the Close button to try again."));
2634 msg.set_position (Gtk::WIN_POS_CENTER);
2635 pop_back_splash (msg);
2638 int response = msg.run ();
2643 case RESPONSE_CANCEL:
2653 MessageDialog msg (string_compose(
2654 _("Session \"%1 (snapshot %2)\" did not load successfully"),
2660 msg.set_title (_("Loading Error"));
2661 msg.set_secondary_text (_("Click the Refresh button to try again."));
2662 msg.add_button (Stock::REFRESH, 1);
2663 msg.set_position (Gtk::WIN_POS_CENTER);
2664 pop_back_splash (msg);
2667 int response = msg.run ();
2682 list<string> const u = new_session->unknown_processors ();
2684 MissingPluginDialog d (_session, u);
2689 /* Now the session been created, add the transport controls */
2690 new_session->add_controllable(roll_controllable);
2691 new_session->add_controllable(stop_controllable);
2692 new_session->add_controllable(goto_start_controllable);
2693 new_session->add_controllable(goto_end_controllable);
2694 new_session->add_controllable(auto_loop_controllable);
2695 new_session->add_controllable(play_selection_controllable);
2696 new_session->add_controllable(rec_controllable);
2698 set_session (new_session);
2700 session_loaded = true;
2702 goto_editor_window ();
2705 _session->set_clean ();
2716 ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name, BusProfile& bus_profile)
2718 Session *new_session;
2721 if (!check_audioengine()) {
2725 session_loaded = false;
2727 x = unload_session ();
2735 _session_is_new = true;
2738 new_session = new Session (*engine, path, snap_name, &bus_profile);
2743 MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
2744 pop_back_splash (msg);
2749 /* Give the new session the default GUI state, if such things exist */
2752 n = Config->instant_xml (X_("Editor"));
2754 new_session->add_instant_xml (*n, false);
2756 n = Config->instant_xml (X_("Mixer"));
2758 new_session->add_instant_xml (*n, false);
2761 /* Put the playhead at 0 and scroll fully left */
2762 n = new_session->instant_xml (X_("Editor"));
2764 n->add_property (X_("playhead"), X_("0"));
2765 n->add_property (X_("left-frame"), X_("0"));
2768 set_session (new_session);
2770 session_loaded = true;
2772 new_session->save_state(new_session->name());
2778 ARDOUR_UI::launch_chat ()
2781 open_uri("http://webchat.freenode.net/?channels=ardour-osx");
2783 open_uri("http://webchat.freenode.net/?channels=ardour");
2788 ARDOUR_UI::show_about ()
2792 about->signal_response().connect (sigc::mem_fun (*this, &ARDOUR_UI::about_signal_response));
2795 about->set_transient_for(*editor);
2800 ARDOUR_UI::launch_manual ()
2802 PBD::open_uri("http://ardour.org/flossmanual");
2806 ARDOUR_UI::launch_reference ()
2808 PBD::open_uri("http://ardour.org/refmanual");
2812 ARDOUR_UI::hide_about ()
2815 about->get_window()->set_cursor ();
2821 ARDOUR_UI::about_signal_response (int /*response*/)
2827 ARDOUR_UI::show_splash ()
2831 splash = new Splash;
2838 splash->pop_front ();
2839 splash->queue_draw ();
2840 splash->get_window()->process_updates (true);
2845 ARDOUR_UI::hide_splash ()
2854 ARDOUR_UI::display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title,
2855 const string& plural_msg, const string& singular_msg)
2859 removed = rep.paths.size();
2862 MessageDialog msgd (*editor,
2863 _("No files were ready for clean-up"),
2867 msgd.set_title (_("Clean-up"));
2868 msgd.set_secondary_text (_("If this seems suprising, \n\
2869 check for any existing snapshots.\n\
2870 These may still include regions that\n\
2871 require some unused files to continue to exist."));
2877 ArdourDialog results (_("Clean-up"), true, false);
2879 struct CleanupResultsModelColumns : public Gtk::TreeModel::ColumnRecord {
2880 CleanupResultsModelColumns() {
2884 Gtk::TreeModelColumn<std::string> visible_name;
2885 Gtk::TreeModelColumn<std::string> fullpath;
2889 CleanupResultsModelColumns results_columns;
2890 Glib::RefPtr<Gtk::ListStore> results_model;
2891 Gtk::TreeView results_display;
2893 results_model = ListStore::create (results_columns);
2894 results_display.set_model (results_model);
2895 results_display.append_column (list_title, results_columns.visible_name);
2897 results_display.set_name ("CleanupResultsList");
2898 results_display.set_headers_visible (true);
2899 results_display.set_headers_clickable (false);
2900 results_display.set_reorderable (false);
2902 Gtk::ScrolledWindow list_scroller;
2905 Gtk::HBox dhbox; // the hbox for the image and text
2906 Gtk::HBox ddhbox; // the hbox we eventually pack into the dialog's vbox
2907 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG));
2909 dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
2911 const string dead_directory = _session->session_directory().dead_path().to_string();
2914 %1 - number of files removed
2915 %2 - location of "dead"
2916 %3 - size of files affected
2917 %4 - prefix for "bytes" to produce sensible results (e.g. mega, kilo, giga)
2920 const char* bprefix;
2921 double space_adjusted = 0;
2923 if (rep.space < 1000) {
2925 space_adjusted = rep.space;
2926 } else if (rep.space < 1000000) {
2927 bprefix = X_("kilo");
2928 space_adjusted = truncf((float)rep.space / 1000.0);
2929 } else if (rep.space < 1000000 * 1000) {
2930 bprefix = X_("mega");
2931 space_adjusted = truncf((float)rep.space / (1000.0 * 1000.0));
2933 bprefix = X_("giga");
2934 space_adjusted = truncf((float)rep.space / (1000.0 * 1000 * 1000.0));
2938 txt.set_text (string_compose (plural_msg, removed, dead_directory, space_adjusted, bprefix, PROGRAM_NAME));
2940 txt.set_text (string_compose (singular_msg, removed, dead_directory, space_adjusted, bprefix, PROGRAM_NAME));
2943 dhbox.pack_start (*dimage, true, false, 5);
2944 dhbox.pack_start (txt, true, false, 5);
2946 for (vector<string>::iterator i = rep.paths.begin(); i != rep.paths.end(); ++i) {
2947 TreeModel::Row row = *(results_model->append());
2948 row[results_columns.visible_name] = *i;
2949 row[results_columns.fullpath] = *i;
2952 list_scroller.add (results_display);
2953 list_scroller.set_size_request (-1, 150);
2954 list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2956 dvbox.pack_start (dhbox, true, false, 5);
2957 dvbox.pack_start (list_scroller, true, false, 5);
2958 ddhbox.pack_start (dvbox, true, false, 5);
2960 results.get_vbox()->pack_start (ddhbox, true, false, 5);
2961 results.add_button (Stock::CLOSE, RESPONSE_CLOSE);
2962 results.set_default_response (RESPONSE_CLOSE);
2963 results.set_position (Gtk::WIN_POS_MOUSE);
2965 results_display.show();
2966 list_scroller.show();
2973 //results.get_vbox()->show();
2974 results.set_resizable (false);
2981 ARDOUR_UI::cleanup ()
2983 if (_session == 0) {
2984 /* shouldn't happen: menu item is insensitive */
2989 MessageDialog checker (_("Are you sure you want to clean-up?"),
2991 Gtk::MESSAGE_QUESTION,
2994 checker.set_title (_("Clean-up"));
2996 checker.set_secondary_text(_("Clean-up is a destructive operation.\n\
2997 ALL undo/redo information will be lost if you clean-up.\n\
2998 Clean-up will move all unused files to a \"dead\" location."));
3000 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3001 checker.add_button (_("Clean-up"), RESPONSE_ACCEPT);
3002 checker.set_default_response (RESPONSE_CANCEL);
3004 checker.set_name (_("CleanupDialog"));
3005 checker.set_wmclass (X_("ardour_cleanup"), PROGRAM_NAME);
3006 checker.set_position (Gtk::WIN_POS_MOUSE);
3008 switch (checker.run()) {
3009 case RESPONSE_ACCEPT:
3015 ARDOUR::CleanupReport rep;
3017 editor->prepare_for_cleanup ();
3019 /* do not allow flush until a session is reloaded */
3021 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket"));
3023 act->set_sensitive (false);
3026 if (_session->cleanup_sources (rep)) {
3027 editor->finish_cleanup ();
3031 editor->finish_cleanup ();
3034 display_cleanup_results (rep,
3037 The following %1 files were not in use and \n\
3038 have been moved to:\n\n\
3040 After a restart of %5,\n\n\
3041 Session -> Clean-up -> Flush Wastebasket\n\n\
3042 will release an additional\n\
3043 %3 %4bytes of disk space.\n"),
3045 The following file was not in use and \n\
3046 has been moved to:\n \
3048 After a restart of %5,\n\n\
3049 Session -> Clean-up -> Flush Wastebasket\n\n\
3050 will release an additional\n\
3051 %3 %4bytes of disk space.\n"
3057 ARDOUR_UI::flush_trash ()
3059 if (_session == 0) {
3060 /* shouldn't happen: menu item is insensitive */
3064 ARDOUR::CleanupReport rep;
3066 if (_session->cleanup_trash_sources (rep)) {
3070 display_cleanup_results (rep,
3072 _("The following %1 files were deleted from\n\
3074 releasing %3 %4bytes of disk space"),
3075 _("The following file was deleted from\n\
3077 releasing %3 %4bytes of disk space"));
3081 ARDOUR_UI::add_route (Gtk::Window* float_window)
3089 if (add_route_dialog == 0) {
3090 add_route_dialog = new AddRouteDialog (_session);
3091 add_route_dialog->set_position (WIN_POS_MOUSE);
3093 add_route_dialog->set_transient_for (*float_window);
3097 if (add_route_dialog->is_visible()) {
3098 /* we're already doing this */
3102 ResponseType r = (ResponseType) add_route_dialog->run ();
3104 add_route_dialog->hide();
3107 case RESPONSE_ACCEPT:
3114 if ((count = add_route_dialog->count()) <= 0) {
3118 string template_path = add_route_dialog->track_template();
3120 if (!template_path.empty()) {
3121 _session->new_route_from_template (count, template_path);
3125 uint32_t input_chan = add_route_dialog->channels ();
3126 uint32_t output_chan;
3127 string name_template = add_route_dialog->name_template ();
3128 PluginInfoPtr instrument = add_route_dialog->requested_instrument ();
3129 RouteGroup* route_group = add_route_dialog->route_group ();
3131 AutoConnectOption oac = Config->get_output_auto_connect();
3133 if (oac & AutoConnectMaster) {
3134 output_chan = (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan);
3136 output_chan = input_chan;
3139 /* XXX do something with name template */
3141 if (add_route_dialog->midi_tracks_wanted()) {
3142 session_add_midi_track (route_group, count, name_template, instrument);
3143 } else if (add_route_dialog->audio_tracks_wanted()) {
3144 session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), route_group, count, name_template);
3146 session_add_audio_bus (input_chan, output_chan, route_group, count, name_template);
3151 ARDOUR_UI::mixer_settings () const
3156 node = _session->instant_xml(X_("Mixer"));
3158 node = Config->instant_xml(X_("Mixer"));
3162 node = new XMLNode (X_("Mixer"));
3169 ARDOUR_UI::editor_settings () const
3174 node = _session->instant_xml(X_("Editor"));
3176 node = Config->instant_xml(X_("Editor"));
3180 if (getenv("ARDOUR_INSTANT_XML_PATH")) {
3181 node = Config->instant_xml(getenv("ARDOUR_INSTANT_XML_PATH"));
3186 node = new XMLNode (X_("Editor"));
3193 ARDOUR_UI::keyboard_settings () const
3197 node = Config->extra_xml(X_("Keyboard"));
3200 node = new XMLNode (X_("Keyboard"));
3207 ARDOUR_UI::create_xrun_marker (framepos_t where)
3209 editor->mouse_add_new_marker (where, false, true);
3213 ARDOUR_UI::halt_on_xrun_message ()
3215 MessageDialog msg (*editor,
3216 _("Recording was stopped because your system could not keep up."));
3221 ARDOUR_UI::xrun_handler (framepos_t where)
3227 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::xrun_handler, where)
3229 if (_session && Config->get_create_xrun_marker() && _session->actively_recording()) {
3230 create_xrun_marker(where);
3233 if (_session && Config->get_stop_recording_on_xrun() && _session->actively_recording()) {
3234 halt_on_xrun_message ();
3239 ARDOUR_UI::disk_overrun_handler ()
3241 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_overrun_handler)
3243 if (!have_disk_speed_dialog_displayed) {
3244 have_disk_speed_dialog_displayed = true;
3245 MessageDialog* msg = new MessageDialog (*editor, string_compose (_("\
3246 The disk system on your computer\n\
3247 was not able to keep up with %1.\n\
3249 Specifically, it failed to write data to disk\n\
3250 quickly enough to keep up with recording.\n"), PROGRAM_NAME));
3251 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
3257 ARDOUR_UI::disk_underrun_handler ()
3259 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_underrun_handler)
3261 if (!have_disk_speed_dialog_displayed) {
3262 have_disk_speed_dialog_displayed = true;
3263 MessageDialog* msg = new MessageDialog (
3264 *editor, string_compose (_("The disk system on your computer\n\
3265 was not able to keep up with %1.\n\
3267 Specifically, it failed to read data from disk\n\
3268 quickly enough to keep up with playback.\n"), PROGRAM_NAME));
3269 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
3275 ARDOUR_UI::disk_speed_dialog_gone (int /*ignored_response*/, MessageDialog* msg)
3277 have_disk_speed_dialog_displayed = false;
3282 ARDOUR_UI::session_dialog (std::string msg)
3284 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::session_dialog, msg)
3289 d = new MessageDialog (*editor, msg, false, MESSAGE_INFO, BUTTONS_OK, true);
3291 d = new MessageDialog (msg, false, MESSAGE_INFO, BUTTONS_OK, true);
3300 ARDOUR_UI::pending_state_dialog ()
3302 HBox* hbox = new HBox();
3303 Image* image = new Image (Stock::DIALOG_QUESTION, ICON_SIZE_DIALOG);
3304 ArdourDialog dialog (_("Crash Recovery"), true);
3305 Label message (string_compose (_("\
3306 This session appears to have been in\n\
3307 middle of recording when ardour or\n\
3308 the computer was shutdown.\n\
3310 %1 can recover any captured audio for\n\
3311 you, or it can ignore it. Please decide\n\
3312 what you would like to do.\n"), PROGRAM_NAME));
3313 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
3314 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
3315 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
3316 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
3317 dialog.add_button (_("Ignore crash data"), RESPONSE_REJECT);
3318 dialog.add_button (_("Recover from crash"), RESPONSE_ACCEPT);
3319 dialog.set_default_response (RESPONSE_ACCEPT);
3320 dialog.set_position (WIN_POS_CENTER);
3325 switch (dialog.run ()) {
3326 case RESPONSE_ACCEPT:
3334 ARDOUR_UI::sr_mismatch_dialog (framecnt_t desired, framecnt_t actual)
3336 HBox* hbox = new HBox();
3337 Image* image = new Image (Stock::DIALOG_QUESTION, ICON_SIZE_DIALOG);
3338 ArdourDialog dialog (_("Sample Rate Mismatch"), true);
3339 Label message (string_compose (_("\
3340 This session was created with a sample rate of %1 Hz, but\n\
3341 %2 is currently running at %3 Hz. If you load this session,\n\
3342 audio may be played at the wrong sample rate.\n"), desired, PROGRAM_NAME, actual));
3344 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
3345 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
3346 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
3347 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
3348 dialog.add_button (_("Do not load session"), RESPONSE_REJECT);
3349 dialog.add_button (_("Load session anyway"), RESPONSE_ACCEPT);
3350 dialog.set_default_response (RESPONSE_ACCEPT);
3351 dialog.set_position (WIN_POS_CENTER);
3356 switch (dialog.run ()) {
3357 case RESPONSE_ACCEPT:
3366 ARDOUR_UI::disconnect_from_jack ()
3369 if (engine->disconnect_from_jack ()) {
3370 MessageDialog msg (*editor, _("Could not disconnect from JACK"));
3374 update_sample_rate (0);
3379 ARDOUR_UI::reconnect_to_jack ()
3382 if (engine->reconnect_to_jack ()) {
3383 MessageDialog msg (*editor, _("Could not reconnect to JACK"));
3387 update_sample_rate (0);
3392 ARDOUR_UI::use_config ()
3394 XMLNode* node = Config->extra_xml (X_("TransportControllables"));
3396 set_transport_controllable_state (*node);
3401 ARDOUR_UI::update_transport_clocks (framepos_t pos)
3403 if (Config->get_primary_clock_delta_edit_cursor()) {
3404 primary_clock->set (pos, false, editor->get_preferred_edit_position());
3406 primary_clock->set (pos);
3409 if (Config->get_secondary_clock_delta_edit_cursor()) {
3410 secondary_clock->set (pos, false, editor->get_preferred_edit_position());
3412 secondary_clock->set (pos);
3415 if (big_clock_window->get()) {
3416 big_clock->set (pos);
3422 ARDOUR_UI::step_edit_status_change (bool yn)
3424 // XXX should really store pre-step edit status of things
3425 // we make insensitive
3428 rec_button.set_active_state (Gtkmm2ext::ImplicitActive);
3429 rec_button.set_sensitive (false);
3431 rec_button.unset_active_state ();;
3432 rec_button.set_sensitive (true);
3437 ARDOUR_UI::record_state_changed ()
3439 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed);
3441 if (!_session || !big_clock_window->get()) {
3442 /* why bother - the clock isn't visible */
3446 if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) {
3447 big_clock->set_active (true);
3449 big_clock->set_active (false);
3454 ARDOUR_UI::first_idle ()
3457 _session->allow_auto_play (true);
3461 editor->first_idle();
3464 Keyboard::set_can_save_keybindings (true);
3469 ARDOUR_UI::store_clock_modes ()
3471 XMLNode* node = new XMLNode(X_("ClockModes"));
3473 for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
3474 XMLNode* child = new XMLNode (X_("Clock"));
3476 child->add_property (X_("name"), (*x)->name());
3477 child->add_property (X_("mode"), enum_2_string ((*x)->mode()));
3478 child->add_property (X_("on"), ((*x)->off() ? X_("no") : X_("yes")));
3480 node->add_child_nocopy (*child);
3483 _session->add_extra_xml (*node);
3484 _session->set_dirty ();
3487 ARDOUR_UI::TransportControllable::TransportControllable (std::string name, ARDOUR_UI& u, ToggleType tp)
3488 : Controllable (name), ui (u), type(tp)
3494 ARDOUR_UI::TransportControllable::set_value (double val)
3497 /* do nothing: these are radio-style actions */
3501 const char *action = 0;
3505 action = X_("Roll");
3508 action = X_("Stop");
3511 action = X_("Goto Start");
3514 action = X_("Goto End");
3517 action = X_("Loop");
3520 action = X_("Play Selection");
3523 action = X_("Record");
3533 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", action);
3541 ARDOUR_UI::TransportControllable::get_value (void) const
3568 ARDOUR_UI::setup_profile ()
3570 if (gdk_screen_width() < 1200 || getenv ("ARDOUR_NARROW_SCREEN")) {
3571 Profile->set_small_screen ();
3574 if (getenv ("ARDOUR_SAE")) {
3575 Profile->set_sae ();
3576 Profile->set_single_package ();
3581 ARDOUR_UI::toggle_translations ()
3583 using namespace Glib;
3585 RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("EnableTranslation"));
3587 RefPtr<ToggleAction> ract = RefPtr<ToggleAction>::cast_dynamic (act);
3590 string i18n_killer = ARDOUR::translation_kill_path();
3592 bool already_enabled = !ARDOUR::translations_are_disabled ();
3594 if (ract->get_active ()) {
3595 /* we don't care about errors */
3596 int fd = ::open (i18n_killer.c_str(), O_RDONLY|O_CREAT, 0644);
3599 /* we don't care about errors */
3600 unlink (i18n_killer.c_str());
3603 if (already_enabled != ract->get_active()) {
3604 MessageDialog win (already_enabled ? _("Translations disabled") : _("Translations enabled"),
3606 Gtk::MESSAGE_WARNING,
3608 win.set_secondary_text (string_compose (_("You must restart %1 for this to take effect."), PROGRAM_NAME));
3609 win.set_position (Gtk::WIN_POS_CENTER);
3617 /** Add a window proxy to our list, so that its state will be saved.
3618 * This call also causes the window to be created and opened if its
3619 * state was saved as `visible'.
3622 ARDOUR_UI::add_window_proxy (WindowProxyBase* p)
3624 _window_proxies.push_back (p);
3628 /** Remove a window proxy from our list. Must be called if a WindowProxy
3629 * is deleted, to prevent hanging pointers.
3632 ARDOUR_UI::remove_window_proxy (WindowProxyBase* p)
3634 _window_proxies.remove (p);
3638 ARDOUR_UI::missing_file (Session*s, std::string str, DataType type)
3640 MissingFileDialog dialog (s, str, type);
3645 int result = dialog.run ();
3652 return 1; // quit entire session load
3655 result = dialog.get_action ();
3661 ARDOUR_UI::ambiguous_file (std::string file, std::string /*path*/, std::vector<std::string> hits)
3663 AmbiguousFileDialog dialog (file, hits);
3669 return dialog.get_which ();
3672 /** Allocate our thread-local buffers */
3674 ARDOUR_UI::get_process_buffers ()
3676 _process_thread->get_buffers ();
3679 /** Drop our thread-local buffers */
3681 ARDOUR_UI::drop_process_buffers ()
3683 _process_thread->drop_buffers ();
3687 ARDOUR_UI::feedback_detected ()
3689 _feedback_exists = true;
3693 ARDOUR_UI::successful_graph_sort ()
3695 _feedback_exists = false;
3699 ARDOUR_UI::midi_panic ()
3702 _session->midi_panic();