2 Copyright (C) 1999-2013 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"
30 #include <boost/locale.hpp>
38 #include <sys/resource.h>
39 #include <sys/types.h>
40 #include <sys/sysctl.h>
42 #include <gtkmm/messagedialog.h>
43 #include <gtkmm/accelmap.h>
45 #include "pbd/error.h"
46 #include "pbd/basename.h"
47 #include "pbd/compose.h"
48 #include "pbd/failed_constructor.h"
49 #include "pbd/enumwriter.h"
50 #include "pbd/memento_command.h"
51 #include "pbd/openuri.h"
52 #include "pbd/file_utils.h"
54 #include "gtkmm2ext/application.h"
55 #include "gtkmm2ext/bindings.h"
56 #include "gtkmm2ext/gtk_ui.h"
57 #include "gtkmm2ext/utils.h"
58 #include "gtkmm2ext/click_box.h"
59 #include "gtkmm2ext/fastmeter.h"
60 #include "gtkmm2ext/popup.h"
61 #include "gtkmm2ext/window_title.h"
63 #include "midi++/manager.h"
65 #include "ardour/ardour.h"
66 #include "ardour/audioengine.h"
67 #include "ardour/audiofilesource.h"
68 #include "ardour/automation_watch.h"
69 #include "ardour/diskstream.h"
70 #include "ardour/filename_extensions.h"
71 #include "ardour/filesystem_paths.h"
72 #include "ardour/port.h"
73 #include "ardour/process_thread.h"
74 #include "ardour/profile.h"
75 #include "ardour/recent_sessions.h"
76 #include "ardour/session_directory.h"
77 #include "ardour/session_route.h"
78 #include "ardour/session_state_utils.h"
79 #include "ardour/session_utils.h"
80 #include "ardour/slave.h"
82 #include "timecode/time.h"
84 typedef uint64_t microseconds_t;
88 #include "add_route_dialog.h"
89 #include "ambiguous_file_dialog.h"
90 #include "ardour_ui.h"
91 #include "audio_clock.h"
92 #include "big_clock_window.h"
93 #include "bundle_manager.h"
94 #include "engine_dialog.h"
95 #include "gain_meter.h"
96 #include "global_port_matrix.h"
97 #include "gui_object.h"
98 #include "gui_thread.h"
100 #include "keyeditor.h"
101 #include "location_ui.h"
102 #include "main_clock.h"
103 #include "missing_file_dialog.h"
104 #include "missing_plugin_dialog.h"
105 #include "mixer_ui.h"
106 #include "mouse_cursors.h"
108 #include "pingback.h"
109 #include "processor_box.h"
110 #include "prompter.h"
111 #include "public_editor.h"
112 #include "rc_option_editor.h"
113 #include "route_time_axis.h"
114 #include "route_params_ui.h"
115 #include "session_metadata_dialog.h"
116 #include "session_option_editor.h"
117 #include "shuttle_control.h"
118 #include "speaker_dialog.h"
121 #include "theme_manager.h"
122 #include "time_axis_view_item.h"
124 #include "video_server_dialog.h"
125 #include "add_video_dialog.h"
126 #include "transcode_video_dialog.h"
127 #include "system_exec.h"
131 using namespace ARDOUR;
133 using namespace Gtkmm2ext;
137 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
138 UIConfiguration *ARDOUR_UI::ui_config = 0;
140 sigc::signal<void,bool> ARDOUR_UI::Blink;
141 sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
142 sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
143 sigc::signal<void, framepos_t, bool, framepos_t> ARDOUR_UI::Clock;
144 sigc::signal<void> ARDOUR_UI::CloseAllDialogs;
146 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
148 : Gtkmm2ext::UI (PROGRAM_NAME, argcp, argvp)
150 , gui_object_state (new GUIObjectState)
151 , primary_clock (new MainClock (X_("primary"), false, X_("transport"), true, true, true, false, true))
152 , secondary_clock (new MainClock (X_("secondary"), false, X_("secondary"), true, true, false, false, true))
156 , big_clock (new AudioClock (X_("bigclock"), false, "big", true, true, false, false))
160 , roll_controllable (new TransportControllable ("transport roll", *this, TransportControllable::Roll))
161 , stop_controllable (new TransportControllable ("transport stop", *this, TransportControllable::Stop))
162 , goto_start_controllable (new TransportControllable ("transport goto start", *this, TransportControllable::GotoStart))
163 , goto_end_controllable (new TransportControllable ("transport goto end", *this, TransportControllable::GotoEnd))
164 , auto_loop_controllable (new TransportControllable ("transport auto loop", *this, TransportControllable::AutoLoop))
165 , play_selection_controllable (new TransportControllable ("transport play selection", *this, TransportControllable::PlaySelection))
166 , rec_controllable (new TransportControllable ("transport rec-enable", *this, TransportControllable::RecordEnable))
168 , auto_return_button (ArdourButton::led_default_elements)
169 , follow_edits_button (ArdourButton::led_default_elements)
170 , auto_input_button (ArdourButton::led_default_elements)
172 , auditioning_alert_button (_("audition"))
173 , solo_alert_button (_("solo"))
174 , feedback_alert_button (_("feedback"))
176 , speaker_config_window (X_("speaker-config"), _("Speaker Configuration"))
177 , theme_manager (X_("theme-manager"), _("Theme Manager"))
178 , key_editor (X_("key-editor"), _("Key Bindings"))
179 , rc_option_editor (X_("rc-options-editor"), _("Preferences"))
180 , add_route_dialog (X_("add-routes"), _("Add Tracks/Busses"))
181 , about (X_("about"), _("About"))
182 , location_ui (X_("locations"), _("Locations"))
183 , route_params (X_("inspector"), _("Tracks and Busses"))
184 , session_option_editor (X_("session-options-editor"), _("Properties"), boost::bind (&ARDOUR_UI::create_session_option_editor, this))
185 , add_video_dialog (X_("add-video"), _("Add Tracks/Busses"), boost::bind (&ARDOUR_UI::create_add_video_dialog, this))
186 , bundle_manager (X_("bundle-manager"), _("Bundle Manager"), boost::bind (&ARDOUR_UI::create_bundle_manager, this))
187 , big_clock_window (X_("big-clock"), _("Big Clock"), boost::bind (&ARDOUR_UI::create_big_clock_window, this))
188 , audio_port_matrix (X_("audio-connection-manager"), _("Audio Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::AUDIO))
189 , midi_port_matrix (X_("midi-connection-manager"), _("MIDI Connections"), boost::bind (&ARDOUR_UI::create_global_port_matrix, this, ARDOUR::DataType::MIDI))
191 , error_log_button (_("Errors"))
193 , _status_bar_visibility (X_("status-bar"))
194 , _feedback_exists (false)
197 Gtkmm2ext::init(localedir);
202 if (theArdourUI == 0) {
206 ui_config = new UIConfiguration();
212 _session_is_new = false;
213 session_selector_window = 0;
214 last_key_press_time = 0;
215 video_server_process = 0;
216 open_session_selector = 0;
217 have_configure_timeout = false;
218 have_disk_speed_dialog_displayed = false;
219 session_loaded = false;
220 ignore_dual_punch = false;
222 roll_button.set_controllable (roll_controllable);
223 stop_button.set_controllable (stop_controllable);
224 goto_start_button.set_controllable (goto_start_controllable);
225 goto_end_button.set_controllable (goto_end_controllable);
226 auto_loop_button.set_controllable (auto_loop_controllable);
227 play_selection_button.set_controllable (play_selection_controllable);
228 rec_button.set_controllable (rec_controllable);
230 roll_button.set_name ("transport button");
231 stop_button.set_name ("transport button");
232 goto_start_button.set_name ("transport button");
233 goto_end_button.set_name ("transport button");
234 auto_loop_button.set_name ("transport button");
235 play_selection_button.set_name ("transport button");
236 rec_button.set_name ("transport recenable button");
237 midi_panic_button.set_name ("transport button");
239 goto_start_button.set_tweaks (ArdourButton::ShowClick);
240 goto_end_button.set_tweaks (ArdourButton::ShowClick);
241 midi_panic_button.set_tweaks (ArdourButton::ShowClick);
243 last_configure_time= 0;
246 ARDOUR::Diskstream::DiskOverrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_overrun_handler, this), gui_context());
247 ARDOUR::Diskstream::DiskUnderrun.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::disk_underrun_handler, this), gui_context());
249 ARDOUR::Session::VersionMismatch.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_format_mismatch, this, _1, _2), gui_context());
251 /* handle dialog requests */
253 ARDOUR::Session::Dialog.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::session_dialog, this, _1), gui_context());
255 /* handle pending state with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
257 ARDOUR::Session::AskAboutPendingState.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::pending_state_dialog, this));
259 /* handle sr mismatch with a dialog (PROBLEM: needs to return a value and thus cannot be x-thread) */
261 ARDOUR::Session::AskAboutSampleRateMismatch.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::sr_mismatch_dialog, this, _1, _2));
263 /* handle requests to quit (coming from JACK session) */
265 ARDOUR::Session::Quit.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::finish, this), gui_context ());
267 /* tell the user about feedback */
269 ARDOUR::Session::FeedbackDetected.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::feedback_detected, this), gui_context ());
270 ARDOUR::Session::SuccessfulGraphSort.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::successful_graph_sort, this), gui_context ());
272 /* handle requests to deal with missing files */
274 ARDOUR::Session::MissingFile.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::missing_file, this, _1, _2, _3));
276 /* and ambiguous files */
278 ARDOUR::FileSource::AmbiguousFileName.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::ambiguous_file, this, _1, _2, _3));
280 /* lets get this party started */
283 if (ARDOUR::init (ARDOUR_COMMAND_LINE::use_vst, ARDOUR_COMMAND_LINE::try_hw_optimization, localedir)) {
284 throw failed_constructor ();
287 setup_gtk_ardour_enums ();
290 SessionEvent::create_per_thread_pool ("GUI", 512);
292 } catch (failed_constructor& err) {
293 error << string_compose (_("could not initialize %1."), PROGRAM_NAME) << endmsg;
298 /* we like keyboards */
300 keyboard = new ArdourKeyboard(*this);
302 XMLNode* node = ARDOUR_UI::instance()->keyboard_settings();
304 keyboard->set_state (*node, Stateful::loading_state_version);
307 /* we don't like certain modifiers */
308 Bindings::set_ignored_state (GDK_LOCK_MASK|GDK_MOD2_MASK|GDK_MOD3_MASK);
312 TimeAxisViewItem::set_constant_heights ();
314 /* load up the UI manager */
316 ActionManager::init ();
318 /* The following must happen after ARDOUR::init() so that Config is set up */
320 const XMLNode* ui_xml = Config->extra_xml (X_("UI"));
323 theme_manager.set_state (*ui_xml);
324 key_editor.set_state (*ui_xml);
325 rc_option_editor.set_state (*ui_xml);
326 session_option_editor.set_state (*ui_xml);
327 speaker_config_window.set_state (*ui_xml);
328 about.set_state (*ui_xml);
329 add_route_dialog.set_state (*ui_xml);
330 add_video_dialog.set_state (*ui_xml);
331 route_params.set_state (*ui_xml);
332 bundle_manager.set_state (*ui_xml);
333 location_ui.set_state (*ui_xml);
334 big_clock_window.set_state (*ui_xml);
335 audio_port_matrix.set_state (*ui_xml);
336 midi_port_matrix.set_state (*ui_xml);
339 WindowManager::instance().register_window (&theme_manager);
340 WindowManager::instance().register_window (&key_editor);
341 WindowManager::instance().register_window (&rc_option_editor);
342 WindowManager::instance().register_window (&session_option_editor);
343 WindowManager::instance().register_window (&speaker_config_window);
344 WindowManager::instance().register_window (&about);
345 WindowManager::instance().register_window (&add_route_dialog);
346 WindowManager::instance().register_window (&add_video_dialog);
347 WindowManager::instance().register_window (&route_params);
348 WindowManager::instance().register_window (&bundle_manager);
349 WindowManager::instance().register_window (&location_ui);
350 WindowManager::instance().register_window (&big_clock_window);
351 WindowManager::instance().register_window (&audio_port_matrix);
352 WindowManager::instance().register_window (&midi_port_matrix);
354 /* We need to instantiate the theme manager because it loads our
355 theme files. This should really change so that its window
356 and its functionality are separate
359 (void) theme_manager.get (true);
361 starting.connect (sigc::mem_fun(*this, &ARDOUR_UI::startup));
362 stopping.connect (sigc::mem_fun(*this, &ARDOUR_UI::shutdown));
364 _process_thread = new ProcessThread ();
365 _process_thread->init ();
367 DPIReset.connect (sigc::mem_fun (*this, &ARDOUR_UI::resize_text_widgets));
370 GlobalPortMatrixWindow*
371 ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
376 return new GlobalPortMatrixWindow (_session, type);
380 ARDOUR_UI::create_engine ()
382 // this gets called every time by new_session()
388 loading_message (_("Starting audio engine"));
391 engine = new ARDOUR::AudioEngine (ARDOUR_COMMAND_LINE::jack_client_name, ARDOUR_COMMAND_LINE::jack_session_uuid);
398 engine->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
399 engine->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
400 engine->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
402 engine->Halted.connect_same_thread (forever_connections, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
404 ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
412 ARDOUR_UI::post_engine ()
414 /* Things to be done once we create the AudioEngine
417 ARDOUR::init_post_engine ();
421 if (setup_windows ()) {
422 throw failed_constructor ();
425 /* Do this after setup_windows (), as that's when the _status_bar_visibility is created */
426 XMLNode* n = Config->extra_xml (X_("UI"));
428 _status_bar_visibility.set_state (*n);
431 check_memory_locking();
433 /* this is the first point at which all the keybindings are available */
435 if (ARDOUR_COMMAND_LINE::show_key_actions) {
436 vector<string> names;
437 vector<string> paths;
438 vector<string> tooltips;
440 vector<AccelKey> bindings;
442 ActionManager::get_all_actions (names, paths, tooltips, keys, bindings);
444 vector<string>::iterator n;
445 vector<string>::iterator k;
446 for (n = names.begin(), k = keys.begin(); n != names.end(); ++n, ++k) {
447 cout << "Action: " << (*n) << " bound to " << (*k) << endl;
453 blink_timeout_tag = -1;
455 /* this being a GUI and all, we want peakfiles */
457 AudioFileSource::set_build_peakfiles (true);
458 AudioFileSource::set_build_missing_peakfiles (true);
460 /* set default clock modes */
462 if (Profile->get_sae()) {
463 primary_clock->set_mode (AudioClock::BBT);
464 secondary_clock->set_mode (AudioClock::MinSec);
466 primary_clock->set_mode (AudioClock::Timecode);
467 secondary_clock->set_mode (AudioClock::BBT);
470 /* start the time-of-day-clock */
473 /* OS X provides a nearly-always visible wallclock, so don't be stupid */
474 update_wall_clock ();
475 Glib::signal_timeout().connect_seconds (sigc::mem_fun(*this, &ARDOUR_UI::update_wall_clock), 1);
478 update_disk_space ();
480 update_sample_rate (engine->frame_rate());
481 update_timecode_format ();
483 Config->ParameterChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::parameter_changed, this, _1), gui_context());
484 boost::function<void (string)> pc (boost::bind (&ARDOUR_UI::parameter_changed, this, _1));
485 Config->map_parameters (pc);
487 /* now start and maybe save state */
489 if (do_engine_start () == 0) {
490 if (_session && _session_is_new) {
491 /* we need to retain initial visual
492 settings for a new session
494 _session->save_state ("");
499 ARDOUR_UI::~ARDOUR_UI ()
509 ARDOUR_UI::pop_back_splash (Gtk::Window& win)
511 if (Splash::instance()) {
512 Splash::instance()->pop_back_for (win);
517 ARDOUR_UI::configure_timeout ()
519 if (last_configure_time == 0) {
520 /* no configure events yet */
524 /* force a gap of 0.5 seconds since the last configure event
527 if (get_microseconds() - last_configure_time < 500000) {
530 have_configure_timeout = false;
531 save_ardour_state ();
537 ARDOUR_UI::configure_handler (GdkEventConfigure* /*conf*/)
539 if (have_configure_timeout) {
540 last_configure_time = get_microseconds();
542 Glib::signal_timeout().connect (sigc::mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
543 have_configure_timeout = true;
550 ARDOUR_UI::set_transport_controllable_state (const XMLNode& node)
552 const XMLProperty* prop;
554 if ((prop = node.property ("roll")) != 0) {
555 roll_controllable->set_id (prop->value());
557 if ((prop = node.property ("stop")) != 0) {
558 stop_controllable->set_id (prop->value());
560 if ((prop = node.property ("goto-start")) != 0) {
561 goto_start_controllable->set_id (prop->value());
563 if ((prop = node.property ("goto-end")) != 0) {
564 goto_end_controllable->set_id (prop->value());
566 if ((prop = node.property ("auto-loop")) != 0) {
567 auto_loop_controllable->set_id (prop->value());
569 if ((prop = node.property ("play-selection")) != 0) {
570 play_selection_controllable->set_id (prop->value());
572 if ((prop = node.property ("rec")) != 0) {
573 rec_controllable->set_id (prop->value());
575 if ((prop = node.property ("shuttle")) != 0) {
576 shuttle_box->controllable()->set_id (prop->value());
581 ARDOUR_UI::get_transport_controllable_state ()
583 XMLNode* node = new XMLNode(X_("TransportControllables"));
586 roll_controllable->id().print (buf, sizeof (buf));
587 node->add_property (X_("roll"), buf);
588 stop_controllable->id().print (buf, sizeof (buf));
589 node->add_property (X_("stop"), buf);
590 goto_start_controllable->id().print (buf, sizeof (buf));
591 node->add_property (X_("goto_start"), buf);
592 goto_end_controllable->id().print (buf, sizeof (buf));
593 node->add_property (X_("goto_end"), buf);
594 auto_loop_controllable->id().print (buf, sizeof (buf));
595 node->add_property (X_("auto_loop"), buf);
596 play_selection_controllable->id().print (buf, sizeof (buf));
597 node->add_property (X_("play_selection"), buf);
598 rec_controllable->id().print (buf, sizeof (buf));
599 node->add_property (X_("rec"), buf);
600 shuttle_box->controllable()->id().print (buf, sizeof (buf));
601 node->add_property (X_("shuttle"), buf);
608 ARDOUR_UI::autosave_session ()
610 if (g_main_depth() > 1) {
611 /* inside a recursive main loop,
612 give up because we may not be able to
618 if (!Config->get_periodic_safety_backups()) {
623 _session->maybe_write_autosave();
630 ARDOUR_UI::update_autosave ()
632 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_autosave)
634 if (_session && _session->dirty()) {
635 if (_autosave_connection.connected()) {
636 _autosave_connection.disconnect();
639 _autosave_connection = Glib::signal_timeout().connect (sigc::mem_fun (*this, &ARDOUR_UI::autosave_session),
640 Config->get_periodic_safety_backup_interval() * 1000);
643 if (_autosave_connection.connected()) {
644 _autosave_connection.disconnect();
650 ARDOUR_UI::check_announcements ()
653 string _annc_filename;
656 _annc_filename = PROGRAM_NAME "_announcements_osx_";
658 _annc_filename = PROGRAM_NAME "_announcements_linux_";
660 _annc_filename.append (VERSIONSTRING);
662 std::string path = Glib::build_filename (user_config_directory(), _annc_filename);
663 std::ifstream announce_file (path.c_str());
664 if ( announce_file.fail() )
665 _announce_string = "";
667 std::stringstream oss;
668 oss << announce_file.rdbuf();
669 _announce_string = oss.str();
672 pingback (VERSIONSTRING, path);
677 ARDOUR_UI::startup ()
679 Application* app = Application::instance ();
681 app->ShouldQuit.connect (sigc::mem_fun (*this, &ARDOUR_UI::queue_finish));
682 app->ShouldLoad.connect (sigc::mem_fun (*this, &ARDOUR_UI::idle_load));
684 if (ARDOUR_COMMAND_LINE::check_announcements) {
685 check_announcements ();
690 nsm_url = getenv ("NSM_URL");
694 nsm = new NSM_Client;
695 if (!nsm->init (nsm_url)) {
696 nsm->announce (PROGRAM_NAME, ":dirty:", "ardour3");
699 // wait for announce reply from nsm server
700 for ( i = 0; i < 5000; ++i) {
703 if (nsm->is_active())
706 // wait for open command from nsm server
707 for ( i = 0; i < 5000; ++i) {
710 if (nsm->client_id ())
714 if (_session && nsm) {
715 _session->set_nsm_state( nsm->is_active() );
718 // nsm requires these actions disabled
719 vector<string> action_names;
720 action_names.push_back("SaveAs");
721 action_names.push_back("Rename");
722 action_names.push_back("New");
723 action_names.push_back("Open");
724 action_names.push_back("Recent");
725 action_names.push_back("Close");
727 for (vector<string>::const_iterator n = action_names.begin(); n != action_names.end(); ++n) {
728 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), (*n).c_str());
730 act->set_sensitive (false);
741 else if (get_session_parameters (true, ARDOUR_COMMAND_LINE::new_session, ARDOUR_COMMAND_LINE::load_template)) {
747 goto_editor_window ();
749 WindowManager::instance().show_visible ();
751 /* We have to do this here since goto_editor_window() ends up calling show_all() on the
752 * editor window, and we may want stuff to be hidden.
754 _status_bar_visibility.update ();
756 BootMessage (string_compose (_("%1 is ready for use"), PROGRAM_NAME));
760 ARDOUR_UI::no_memory_warning ()
762 XMLNode node (X_("no-memory-warning"));
763 Config->add_instant_xml (node);
767 ARDOUR_UI::check_memory_locking ()
770 /* OS X doesn't support mlockall(2), and so testing for memory locking capability there is pointless */
774 XMLNode* memory_warning_node = Config->instant_xml (X_("no-memory-warning"));
776 if (engine->is_realtime() && memory_warning_node == 0) {
778 struct rlimit limits;
780 long pages, page_size;
782 size_t pages_len=sizeof(pages);
783 if ((page_size = getpagesize()) < 0 ||
784 sysctlbyname("hw.availpages", &pages, &pages_len, NULL, 0))
786 if ((page_size = sysconf (_SC_PAGESIZE)) < 0 ||(pages = sysconf (_SC_PHYS_PAGES)) < 0)
791 ram = (int64_t) pages * (int64_t) page_size;
794 if (getrlimit (RLIMIT_MEMLOCK, &limits)) {
798 if (limits.rlim_cur != RLIM_INFINITY) {
800 if (ram == 0 || ((double) limits.rlim_cur / ram) < 0.75) {
804 _("WARNING: Your system has a limit for maximum amount of locked memory. "
805 "This might cause %1 to run out of memory before your system "
806 "runs out of memory. \n\n"
807 "You can view the memory limit with 'ulimit -l', "
808 "and it is normally controlled by %2"),
809 PROGRAM_NAME).c_str(),
811 X_("/etc/login.conf")
813 X_(" /etc/security/limits.conf")
817 msg.set_default_response (RESPONSE_OK);
819 VBox* vbox = msg.get_vbox();
821 CheckButton cb (_("Do not show this window again"));
823 cb.signal_toggled().connect (sigc::mem_fun (*this, &ARDOUR_UI::no_memory_warning));
825 hbox.pack_start (cb, true, false);
826 vbox->pack_start (hbox);
831 pop_back_splash (msg);
833 editor->ensure_float (msg);
843 ARDOUR_UI::queue_finish ()
845 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::idle_finish));
849 ARDOUR_UI::idle_finish ()
852 return false; /* do not call again */
859 ARDOUR_UI::instance()->video_timeline->sync_session_state();
861 if (_session->dirty()) {
862 vector<string> actions;
863 actions.push_back (_("Don't quit"));
864 actions.push_back (_("Just quit"));
865 actions.push_back (_("Save and quit"));
866 switch (ask_about_saving_session(actions)) {
871 /* use the default name */
872 if (save_state_canfail ("")) {
873 /* failed - don't quit */
874 MessageDialog msg (*editor,
876 %1 was unable to save your session.\n\n\
877 If you still wish to quit, please use the\n\n\
878 \"Just quit\" option."), PROGRAM_NAME));
879 pop_back_splash(msg);
889 second_connection.disconnect ();
890 point_one_second_connection.disconnect ();
891 point_oh_five_second_connection.disconnect ();
892 point_zero_one_second_connection.disconnect();
895 delete ARDOUR_UI::instance()->video_timeline;
898 /* Save state before deleting the session, as that causes some
899 windows to be destroyed before their visible state can be
902 save_ardour_state ();
904 close_all_dialogs ();
906 loading_message (string_compose (_("Please wait while %1 cleans up..."), PROGRAM_NAME));
909 // _session->set_deletion_in_progress ();
910 _session->set_clean ();
911 _session->remove_pending_capture_state ();
921 ARDOUR_UI::ask_about_saving_session (const vector<string>& actions)
923 ArdourDialog window (_("Unsaved Session"));
924 Gtk::HBox dhbox; // the hbox for the image and text
925 Gtk::Label prompt_label;
926 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG));
930 assert (actions.size() >= 3);
932 window.add_button (actions[0], RESPONSE_REJECT);
933 window.add_button (actions[1], RESPONSE_APPLY);
934 window.add_button (actions[2], RESPONSE_ACCEPT);
936 window.set_default_response (RESPONSE_ACCEPT);
938 Gtk::Button noquit_button (msg);
939 noquit_button.set_name ("EditorGTKButton");
943 if (_session->snap_name() == _session->name()) {
944 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?"),
945 _session->snap_name());
947 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?"),
948 _session->snap_name());
951 prompt_label.set_text (prompt);
952 prompt_label.set_name (X_("PrompterLabel"));
953 prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP);
955 dimage->set_alignment(ALIGN_CENTER, ALIGN_TOP);
956 dhbox.set_homogeneous (false);
957 dhbox.pack_start (*dimage, false, false, 5);
958 dhbox.pack_start (prompt_label, true, false, 5);
959 window.get_vbox()->pack_start (dhbox);
961 window.set_name (_("Prompter"));
962 window.set_modal (true);
963 window.set_resizable (false);
969 window.set_keep_above (true);
972 ResponseType r = (ResponseType) window.run();
977 case RESPONSE_ACCEPT: // save and get out of here
979 case RESPONSE_APPLY: // get out of here
990 ARDOUR_UI::every_second ()
993 update_buffer_load ();
994 update_disk_space ();
995 update_timecode_format ();
997 if (nsm && nsm->is_active ()) {
1000 if (!_was_dirty && _session->dirty ()) {
1004 else if (_was_dirty && !_session->dirty ()){
1013 ARDOUR_UI::every_point_one_seconds ()
1015 shuttle_box->update_speed_display ();
1016 RapidScreenUpdate(); /* EMIT_SIGNAL */
1021 ARDOUR_UI::every_point_zero_one_seconds ()
1023 // august 2007: actual update frequency: 40Hz, not 100Hz
1025 SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
1030 ARDOUR_UI::update_sample_rate (framecnt_t)
1034 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::update_sample_rate, ignored)
1036 if (!engine->connected()) {
1038 snprintf (buf, sizeof (buf), "%s", _("disconnected"));
1042 framecnt_t rate = engine->frame_rate();
1044 if (fmod (rate, 1000.0) != 0.0) {
1045 snprintf (buf, sizeof (buf), _("JACK: <span foreground=\"green\">%.1f kHz / %4.1f ms</span>"),
1046 (float) rate/1000.0f,
1047 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
1049 snprintf (buf, sizeof (buf), _("JACK: <span foreground=\"green\">%" PRId64 " kHz / %4.1f ms</span>"),
1051 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
1055 sample_rate_label.set_markup (buf);
1059 ARDOUR_UI::update_format ()
1062 format_label.set_text ("");
1067 s << _("File:") << X_(" <span foreground=\"green\">");
1069 switch (_session->config.get_native_file_header_format ()) {
1095 switch (_session->config.get_native_file_data_format ()) {
1109 format_label.set_markup (s.str ());
1113 ARDOUR_UI::update_cpu_load ()
1117 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1118 should also be changed.
1121 float const c = engine->get_cpu_load ();
1122 snprintf (buf, sizeof (buf), _("DSP: <span foreground=\"%s\">%5.1f%%</span>"), c >= 90 ? X_("red") : X_("green"), c);
1123 cpu_load_label.set_markup (buf);
1127 ARDOUR_UI::update_buffer_load ()
1131 uint32_t const playback = _session ? _session->playback_load () : 100;
1132 uint32_t const capture = _session ? _session->capture_load () : 100;
1134 /* If this text is changed, the set_size_request_to_display_given_text call in ARDOUR_UI::resize_text_widgets
1135 should also be changed.
1141 _("Buffers: <span foreground=\"green\">p:</span><span foreground=\"%s\">%" PRIu32 "%%</span> "
1142 "<span foreground=\"green\">c:</span><span foreground=\"%s\">%" PRIu32 "%%</span>"),
1143 playback <= 5 ? X_("red") : X_("green"),
1145 capture <= 5 ? X_("red") : X_("green"),
1149 buffer_load_label.set_markup (buf);
1151 buffer_load_label.set_text ("");
1156 ARDOUR_UI::count_recenabled_streams (Route& route)
1158 Track* track = dynamic_cast<Track*>(&route);
1159 if (track && track->record_enabled()) {
1160 rec_enabled_streams += track->n_inputs().n_total();
1165 ARDOUR_UI::update_disk_space()
1167 if (_session == 0) {
1171 boost::optional<framecnt_t> opt_frames = _session->available_capture_duration();
1173 framecnt_t fr = _session->frame_rate();
1176 /* Available space is unknown */
1177 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">Unknown</span>"));
1178 } else if (opt_frames.get_value_or (0) == max_framecnt) {
1179 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">24hrs+</span>"));
1181 rec_enabled_streams = 0;
1182 _session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
1184 framecnt_t frames = opt_frames.get_value_or (0);
1186 if (rec_enabled_streams) {
1187 frames /= rec_enabled_streams;
1194 hrs = frames / (fr * 3600);
1197 snprintf (buf, sizeof (buf), "%s", _("Disk: <span foreground=\"green\">>24 hrs</span>"));
1199 frames -= hrs * fr * 3600;
1200 mins = frames / (fr * 60);
1201 frames -= mins * fr * 60;
1204 bool const low = (hrs == 0 && mins <= 30);
1208 _("Disk: <span foreground=\"%s\">%02dh:%02dm:%02ds</span>"),
1209 low ? X_("red") : X_("green"),
1215 disk_space_label.set_markup (buf);
1219 ARDOUR_UI::update_timecode_format ()
1225 TimecodeSlave* tcslave;
1226 SyncSource sync_src = Config->get_sync_source();
1228 if ((sync_src == LTC || sync_src == MTC) && (tcslave = dynamic_cast<TimecodeSlave*>(_session->slave())) != 0) {
1229 matching = (tcslave->apparent_timecode_format() == _session->config.get_timecode_format());
1234 snprintf (buf, sizeof (buf), S_("Timecode|TC: <span foreground=\"%s\">%s</span>"),
1235 matching ? X_("green") : X_("red"),
1236 Timecode::timecode_format_name (_session->config.get_timecode_format()).c_str());
1238 snprintf (buf, sizeof (buf), "TC: n/a");
1241 timecode_format_label.set_markup (buf);
1245 ARDOUR_UI::update_wall_clock ()
1249 static int last_min = -1;
1252 tm_now = localtime (&now);
1253 if (last_min != tm_now->tm_min) {
1255 sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
1256 wall_clock_label.set_text (buf);
1257 last_min = tm_now->tm_min;
1264 ARDOUR_UI::redisplay_recent_sessions ()
1266 std::vector<std::string> session_directories;
1267 RecentSessionsSorter cmp;
1269 recent_session_display.set_model (Glib::RefPtr<TreeModel>(0));
1270 recent_session_model->clear ();
1272 ARDOUR::RecentSessions rs;
1273 ARDOUR::read_recent_sessions (rs);
1276 recent_session_display.set_model (recent_session_model);
1280 // sort them alphabetically
1281 sort (rs.begin(), rs.end(), cmp);
1283 for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
1284 session_directories.push_back ((*i).second);
1287 for (vector<std::string>::const_iterator i = session_directories.begin();
1288 i != session_directories.end(); ++i)
1290 std::vector<std::string> state_file_paths;
1292 // now get available states for this session
1294 get_state_files_in_directory (*i, state_file_paths);
1296 vector<string*>* states;
1297 vector<const gchar*> item;
1298 string fullpath = *i;
1300 /* remove any trailing / */
1302 if (fullpath[fullpath.length() - 1] == '/') {
1303 fullpath = fullpath.substr (0, fullpath.length() - 1);
1306 /* check whether session still exists */
1307 if (!Glib::file_test(fullpath.c_str(), Glib::FILE_TEST_EXISTS)) {
1308 /* session doesn't exist */
1312 /* now get available states for this session */
1314 if ((states = Session::possible_states (fullpath)) == 0) {
1315 /* no state file? */
1319 std::vector<string> state_file_names(get_file_names_no_extension (state_file_paths));
1321 Gtk::TreeModel::Row row = *(recent_session_model->append());
1323 row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
1324 row[recent_session_columns.fullpath] = fullpath;
1325 row[recent_session_columns.tip] = Glib::Markup::escape_text (fullpath);
1327 if (state_file_names.size() > 1) {
1331 for (std::vector<std::string>::iterator i2 = state_file_names.begin();
1332 i2 != state_file_names.end(); ++i2)
1335 Gtk::TreeModel::Row child_row = *(recent_session_model->append (row.children()));
1337 child_row[recent_session_columns.visible_name] = *i2;
1338 child_row[recent_session_columns.fullpath] = fullpath;
1339 child_row[recent_session_columns.tip] = Glib::Markup::escape_text (fullpath);
1344 recent_session_display.set_tooltip_column(1); // recent_session_columns.tip
1345 recent_session_display.set_model (recent_session_model);
1349 ARDOUR_UI::build_session_selector ()
1351 session_selector_window = new ArdourDialog (_("Recent Sessions"));
1353 Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow);
1355 session_selector_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
1356 session_selector_window->add_button (Stock::OPEN, RESPONSE_ACCEPT);
1357 session_selector_window->set_default_response (RESPONSE_ACCEPT);
1358 recent_session_model = TreeStore::create (recent_session_columns);
1359 recent_session_display.set_model (recent_session_model);
1360 recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
1361 recent_session_display.set_headers_visible (false);
1362 recent_session_display.get_selection()->set_mode (SELECTION_BROWSE);
1363 recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
1365 scroller->add (recent_session_display);
1366 scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
1368 session_selector_window->set_name ("SessionSelectorWindow");
1369 session_selector_window->set_size_request (200, 400);
1370 session_selector_window->get_vbox()->pack_start (*scroller);
1372 recent_session_display.show();
1377 ARDOUR_UI::recent_session_row_activated (const TreePath& /*path*/, TreeViewColumn* /*col*/)
1379 session_selector_window->response (RESPONSE_ACCEPT);
1383 ARDOUR_UI::open_recent_session ()
1385 bool can_return = (_session != 0);
1387 if (session_selector_window == 0) {
1388 build_session_selector ();
1391 redisplay_recent_sessions ();
1395 ResponseType r = (ResponseType) session_selector_window->run ();
1398 case RESPONSE_ACCEPT:
1402 session_selector_window->hide();
1409 if (recent_session_display.get_selection()->count_selected_rows() == 0) {
1413 session_selector_window->hide();
1415 Gtk::TreeModel::iterator i = recent_session_display.get_selection()->get_selected();
1417 if (i == recent_session_model->children().end()) {
1421 std::string path = (*i)[recent_session_columns.fullpath];
1422 std::string state = (*i)[recent_session_columns.visible_name];
1424 _session_is_new = false;
1426 if (load_session (path, state) == 0) {
1435 ARDOUR_UI::check_audioengine ()
1438 if (!engine->connected()) {
1439 MessageDialog msg (string_compose (
1440 _("%1 is not connected to JACK\n"
1441 "You cannot open or close sessions in this condition"),
1443 pop_back_splash (msg);
1454 ARDOUR_UI::open_session ()
1456 if (!check_audioengine()) {
1461 /* popup selector window */
1463 if (open_session_selector == 0) {
1465 /* ardour sessions are folders */
1467 open_session_selector = new Gtk::FileChooserDialog (_("Open Session"), FILE_CHOOSER_ACTION_OPEN);
1468 open_session_selector->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
1469 open_session_selector->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
1470 open_session_selector->set_default_response(Gtk::RESPONSE_ACCEPT);
1473 string session_parent_dir = Glib::path_get_dirname(_session->path());
1474 string::size_type last_dir_sep = session_parent_dir.rfind(G_DIR_SEPARATOR);
1475 session_parent_dir = session_parent_dir.substr(0, last_dir_sep);
1476 open_session_selector->set_current_folder(session_parent_dir);
1478 open_session_selector->set_current_folder(Config->get_default_session_parent_dir());
1481 open_session_selector->add_shortcut_folder (Config->get_default_session_parent_dir());
1483 FileFilter session_filter;
1484 session_filter.add_pattern ("*.ardour");
1485 session_filter.set_name (string_compose (_("%1 sessions"), PROGRAM_NAME));
1486 open_session_selector->add_filter (session_filter);
1487 open_session_selector->set_filter (session_filter);
1490 int response = open_session_selector->run();
1491 open_session_selector->hide ();
1494 case RESPONSE_ACCEPT:
1497 open_session_selector->hide();
1501 open_session_selector->hide();
1502 string session_path = open_session_selector->get_filename();
1506 if (session_path.length() > 0) {
1507 if (ARDOUR::find_session (session_path, path, name, isnew) == 0) {
1508 _session_is_new = isnew;
1509 load_session (path, name);
1516 ARDOUR_UI::session_add_mixed_track (const ChanCount& input, const ChanCount& output, RouteGroup* route_group,
1517 uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
1519 list<boost::shared_ptr<MidiTrack> > tracks;
1521 if (_session == 0) {
1522 warning << _("You cannot add a track without a session already loaded.") << endmsg;
1527 tracks = _session->new_midi_track (input, output, instrument, ARDOUR::Normal, route_group, how_many, name_template);
1529 if (tracks.size() != how_many) {
1530 error << string_compose(P_("could not create %1 new mixed track", "could not create %1 new mixed tracks", how_many), how_many) << endmsg;
1535 MessageDialog msg (*editor,
1536 string_compose (_("There are insufficient JACK ports available\n\
1537 to create a new track or bus.\n\
1538 You should save %1, exit and\n\
1539 restart JACK with more ports."), PROGRAM_NAME));
1546 ARDOUR_UI::session_add_midi_route (bool disk, RouteGroup* route_group, uint32_t how_many, const string& name_template, PluginInfoPtr instrument)
1548 ChanCount one_midi_channel;
1549 one_midi_channel.set (DataType::MIDI, 1);
1552 session_add_mixed_track (one_midi_channel, one_midi_channel, route_group, how_many, name_template, instrument);
1557 ARDOUR_UI::session_add_audio_route (
1559 int32_t input_channels,
1560 int32_t output_channels,
1561 ARDOUR::TrackMode mode,
1562 RouteGroup* route_group,
1564 string const & name_template
1567 list<boost::shared_ptr<AudioTrack> > tracks;
1570 if (_session == 0) {
1571 warning << _("You cannot add a track or bus without a session already loaded.") << endmsg;
1577 tracks = _session->new_audio_track (input_channels, output_channels, mode, route_group, how_many, name_template);
1579 if (tracks.size() != how_many) {
1580 error << string_compose (P_("could not create %1 new audio track", "could not create %1 new audio tracks", how_many), how_many)
1586 routes = _session->new_audio_route (input_channels, output_channels, route_group, how_many, name_template);
1588 if (routes.size() != how_many) {
1589 error << string_compose (P_("could not create %1 new audio bus", "could not create %1 new audio busses", how_many), how_many)
1596 MessageDialog msg (*editor,
1597 string_compose (_("There are insufficient JACK ports available\n\
1598 to create a new track or bus.\n\
1599 You should save %1, exit and\n\
1600 restart JACK with more ports."), PROGRAM_NAME));
1601 pop_back_splash (msg);
1607 ARDOUR_UI::transport_goto_start ()
1610 _session->goto_start();
1612 /* force displayed area in editor to start no matter
1613 what "follow playhead" setting is.
1617 editor->center_screen (_session->current_start_frame ());
1623 ARDOUR_UI::transport_goto_zero ()
1626 _session->request_locate (0);
1628 /* force displayed area in editor to start no matter
1629 what "follow playhead" setting is.
1633 editor->reset_x_origin (0);
1639 ARDOUR_UI::transport_goto_wallclock ()
1641 if (_session && editor) {
1648 localtime_r (&now, &tmnow);
1650 frames = tmnow.tm_hour * (60 * 60 * _session->frame_rate());
1651 frames += tmnow.tm_min * (60 * _session->frame_rate());
1652 frames += tmnow.tm_sec * _session->frame_rate();
1654 _session->request_locate (frames, _session->transport_rolling ());
1656 /* force displayed area in editor to start no matter
1657 what "follow playhead" setting is.
1661 editor->center_screen (frames);
1667 ARDOUR_UI::transport_goto_end ()
1670 framepos_t const frame = _session->current_end_frame();
1671 _session->request_locate (frame);
1673 /* force displayed area in editor to start no matter
1674 what "follow playhead" setting is.
1678 editor->center_screen (frame);
1684 ARDOUR_UI::transport_stop ()
1690 if (_session->is_auditioning()) {
1691 _session->cancel_audition ();
1695 _session->request_stop (false, true);
1699 ARDOUR_UI::transport_record (bool roll)
1703 switch (_session->record_status()) {
1704 case Session::Disabled:
1705 if (_session->ntracks() == 0) {
1706 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."));
1710 _session->maybe_enable_record ();
1715 case Session::Recording:
1717 _session->request_stop();
1719 _session->disable_record (false, true);
1723 case Session::Enabled:
1724 _session->disable_record (false, true);
1730 ARDOUR_UI::transport_roll ()
1736 if (_session->is_auditioning()) {
1741 if (_session->config.get_external_sync()) {
1742 switch (Config->get_sync_source()) {
1746 /* transport controlled by the master */
1752 bool rolling = _session->transport_rolling();
1754 if (_session->get_play_loop()) {
1755 /* XXX it is not possible to just leave seamless loop and keep
1756 playing at present (nov 4th 2009)
1758 if (!Config->get_seamless_loop()) {
1759 _session->request_play_loop (false, true);
1761 } else if (_session->get_play_range () && !Config->get_always_play_range()) {
1762 /* stop playing a range if we currently are */
1763 _session->request_play_range (0, true);
1767 _session->request_transport_speed (1.0f);
1772 ARDOUR_UI::get_smart_mode() const
1774 return ( editor->get_smart_mode() );
1779 ARDOUR_UI::toggle_roll (bool with_abort, bool roll_out_of_bounded_mode)
1786 if (_session->is_auditioning()) {
1787 _session->cancel_audition ();
1791 if (_session->config.get_external_sync()) {
1792 switch (Config->get_sync_source()) {
1796 /* transport controlled by the master */
1801 bool rolling = _session->transport_rolling();
1802 bool affect_transport = true;
1804 if (rolling && roll_out_of_bounded_mode) {
1805 /* drop out of loop/range playback but leave transport rolling */
1806 if (_session->get_play_loop()) {
1807 if (Config->get_seamless_loop()) {
1808 /* the disk buffers contain copies of the loop - we can't
1809 just keep playing, so stop the transport. the user
1810 can restart as they wish.
1812 affect_transport = true;
1814 /* disk buffers are normal, so we can keep playing */
1815 affect_transport = false;
1817 _session->request_play_loop (false, true);
1818 } else if (_session->get_play_range ()) {
1819 affect_transport = false;
1820 _session->request_play_range (0, true);
1824 if (affect_transport) {
1826 _session->request_stop (with_abort, true);
1828 if ( Config->get_always_play_range() ) {
1829 _session->request_play_range (&editor->get_selection().time, true);
1832 _session->request_transport_speed (1.0f);
1838 ARDOUR_UI::toggle_session_auto_loop ()
1840 Location * looploc = _session->locations()->auto_loop_location();
1842 if (!_session || !looploc) {
1846 if (_session->get_play_loop()) {
1848 if (_session->transport_rolling()) {
1850 _session->request_locate (looploc->start(), true);
1851 _session->request_play_loop (false);
1854 _session->request_play_loop (false);
1857 _session->request_play_loop (true);
1860 //show the loop markers
1861 looploc->set_hidden (false, this);
1865 ARDOUR_UI::transport_play_selection ()
1871 editor->play_selection ();
1875 ARDOUR_UI::transport_play_preroll ()
1880 editor->play_with_preroll ();
1884 ARDOUR_UI::transport_rewind (int option)
1886 float current_transport_speed;
1889 current_transport_speed = _session->transport_speed();
1891 if (current_transport_speed >= 0.0f) {
1894 _session->request_transport_speed (-1.0f);
1897 _session->request_transport_speed (-4.0f);
1900 _session->request_transport_speed (-0.5f);
1905 _session->request_transport_speed (current_transport_speed * 1.5f);
1911 ARDOUR_UI::transport_forward (int option)
1917 float current_transport_speed = _session->transport_speed();
1919 if (current_transport_speed <= 0.0f) {
1922 _session->request_transport_speed (1.0f);
1925 _session->request_transport_speed (4.0f);
1928 _session->request_transport_speed (0.5f);
1933 _session->request_transport_speed (current_transport_speed * 1.5f);
1938 ARDOUR_UI::toggle_record_enable (uint32_t rid)
1944 boost::shared_ptr<Route> r;
1946 if ((r = _session->route_by_remote_id (rid)) != 0) {
1950 if ((t = dynamic_cast<Track*>(r.get())) != 0) {
1951 t->set_record_enabled (!t->record_enabled(), this);
1957 ARDOUR_UI::map_transport_state ()
1960 auto_loop_button.unset_active_state ();
1961 play_selection_button.unset_active_state ();
1962 roll_button.unset_active_state ();
1963 stop_button.set_active_state (Gtkmm2ext::ExplicitActive);
1967 shuttle_box->map_transport_state ();
1969 float sp = _session->transport_speed();
1975 if (_session->get_play_range()) {
1977 play_selection_button.set_active_state (Gtkmm2ext::ExplicitActive);
1978 roll_button.unset_active_state ();
1979 auto_loop_button.unset_active_state ();
1981 } else if (_session->get_play_loop ()) {
1983 auto_loop_button.set_active (true);
1984 play_selection_button.set_active (false);
1985 roll_button.set_active (false);
1989 roll_button.set_active (true);
1990 play_selection_button.set_active (false);
1991 auto_loop_button.set_active (false);
1994 if (Config->get_always_play_range()) {
1995 /* light up both roll and play-selection if they are joined */
1996 roll_button.set_active (true);
1997 play_selection_button.set_active (true);
2000 stop_button.set_active (false);
2004 stop_button.set_active (true);
2005 roll_button.set_active (false);
2006 play_selection_button.set_active (false);
2007 auto_loop_button.set_active (false);
2008 update_disk_space ();
2013 ARDOUR_UI::engine_stopped ()
2015 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_stopped)
2016 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
2017 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
2021 ARDOUR_UI::engine_running ()
2023 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::engine_running)
2024 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
2025 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
2027 Glib::RefPtr<Action> action;
2028 const char* action_name = 0;
2030 switch (engine->frames_per_cycle()) {
2032 action_name = X_("JACKLatency32");
2035 action_name = X_("JACKLatency64");
2038 action_name = X_("JACKLatency128");
2041 action_name = X_("JACKLatency512");
2044 action_name = X_("JACKLatency1024");
2047 action_name = X_("JACKLatency2048");
2050 action_name = X_("JACKLatency4096");
2053 action_name = X_("JACKLatency8192");
2056 /* XXX can we do anything useful ? */
2062 action = ActionManager::get_action (X_("JACK"), action_name);
2065 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (action);
2066 ract->set_active ();
2072 ARDOUR_UI::engine_halted (const char* reason, bool free_reason)
2074 if (!Gtkmm2ext::UI::instance()->caller_is_ui_thread()) {
2075 /* we can't rely on the original string continuing to exist when we are called
2076 again in the GUI thread, so make a copy and note that we need to
2079 char *copy = strdup (reason);
2080 Gtkmm2ext::UI::instance()->call_slot (invalidator (*this), boost::bind (&ARDOUR_UI::engine_halted, this, copy, true));
2084 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
2085 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
2087 update_sample_rate (0);
2091 /* if the reason is a non-empty string, it means that the backend was shutdown
2092 rather than just Ardour.
2095 if (strlen (reason)) {
2096 msgstr = string_compose (_("The audio backend (JACK) was shutdown because:\n\n%1"), reason);
2098 msgstr = string_compose (_("\
2099 JACK has either been shutdown or it\n\
2100 disconnected %1 because %1\n\
2101 was not fast enough. Try to restart\n\
2102 JACK, reconnect and save the session."), PROGRAM_NAME);
2105 MessageDialog msg (*editor, msgstr);
2106 pop_back_splash (msg);
2107 msg.set_keep_above (true);
2111 free (const_cast<char*> (reason));
2116 ARDOUR_UI::do_engine_start ()
2124 error << _("Unable to start the session running")
2134 ARDOUR_UI::update_clocks ()
2136 if (!editor || !editor->dragging_playhead()) {
2137 Clock (_session->audible_frame(), false, editor->get_preferred_edit_position()); /* EMIT_SIGNAL */
2142 ARDOUR_UI::start_clocking ()
2144 if (Config->get_super_rapid_clock_update()) {
2145 clock_signal_connection = SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
2147 clock_signal_connection = RapidScreenUpdate.connect (sigc::mem_fun(*this, &ARDOUR_UI::update_clocks));
2152 ARDOUR_UI::stop_clocking ()
2154 clock_signal_connection.disconnect ();
2158 ARDOUR_UI::_blink (void *arg)
2160 ((ARDOUR_UI *) arg)->blink ();
2167 Blink (blink_on = !blink_on); /* EMIT_SIGNAL */
2171 ARDOUR_UI::start_blinking ()
2173 /* Start the blink signal. Everybody with a blinking widget
2174 uses Blink to drive the widget's state.
2177 if (blink_timeout_tag < 0) {
2179 blink_timeout_tag = g_timeout_add (240, _blink, this);
2184 ARDOUR_UI::stop_blinking ()
2186 if (blink_timeout_tag >= 0) {
2187 g_source_remove (blink_timeout_tag);
2188 blink_timeout_tag = -1;
2193 /** Ask the user for the name of a new snapshot and then take it.
2197 ARDOUR_UI::snapshot_session (bool switch_to_it)
2199 ArdourPrompter prompter (true);
2202 prompter.set_name ("Prompter");
2203 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2204 prompter.set_title (_("Take Snapshot"));
2205 prompter.set_prompt (_("Name of new snapshot"));
2207 if (!switch_to_it) {
2210 struct tm local_time;
2213 localtime_r (&n, &local_time);
2214 strftime (timebuf, sizeof(timebuf), "%FT%H.%M.%S", &local_time);
2215 prompter.set_initial_text (timebuf);
2219 switch (prompter.run()) {
2220 case RESPONSE_ACCEPT:
2222 prompter.get_result (snapname);
2224 bool do_save = (snapname.length() != 0);
2227 char illegal = Session::session_name_is_legal(snapname);
2229 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2230 "snapshot names may not contain a '%1' character"), illegal));
2236 vector<std::string> p;
2237 get_state_files_in_directory (_session->session_directory().root_path(), p);
2238 vector<string> n = get_file_names_no_extension (p);
2239 if (find (n.begin(), n.end(), snapname) != n.end()) {
2241 ArdourDialog confirm (_("Confirm Snapshot Overwrite"), true);
2242 Label m (_("A snapshot already exists with that name. Do you want to overwrite it?"));
2243 confirm.get_vbox()->pack_start (m, true, true);
2244 confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
2245 confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
2246 confirm.show_all ();
2247 switch (confirm.run()) {
2248 case RESPONSE_CANCEL:
2254 save_state (snapname, switch_to_it);
2264 /** Ask the user for a new session name and then rename the session to it.
2268 ARDOUR_UI::rename_session ()
2274 ArdourPrompter prompter (true);
2277 prompter.set_name ("Prompter");
2278 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2279 prompter.set_title (_("Rename Session"));
2280 prompter.set_prompt (_("New session name"));
2283 switch (prompter.run()) {
2284 case RESPONSE_ACCEPT:
2286 prompter.get_result (name);
2288 bool do_rename = (name.length() != 0);
2291 char illegal = Session::session_name_is_legal (name);
2294 MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
2295 "session names may not contain a '%1' character"), illegal));
2300 switch (_session->rename (name)) {
2302 MessageDialog msg (_("That name is already in use by another directory/folder. Please try again."));
2303 msg.set_position (WIN_POS_MOUSE);
2311 MessageDialog msg (_("Renaming this session failed.\nThings could be seriously messed up at this point"));
2312 msg.set_position (WIN_POS_MOUSE);
2328 ARDOUR_UI::save_state (const string & name, bool switch_to_it)
2330 XMLNode* node = new XMLNode (X_("UI"));
2332 WindowManager::instance().add_state (*node);
2334 node->add_child_nocopy (gui_object_state->get_state());
2336 _session->add_extra_xml (*node);
2338 save_state_canfail (name, switch_to_it);
2342 ARDOUR_UI::save_state_canfail (string name, bool switch_to_it)
2347 if (name.length() == 0) {
2348 name = _session->snap_name();
2351 if ((ret = _session->save_state (name, false, switch_to_it)) != 0) {
2356 save_ardour_state (); /* XXX cannot fail? yeah, right ... */
2361 ARDOUR_UI::primary_clock_value_changed ()
2364 _session->request_locate (primary_clock->current_time ());
2369 ARDOUR_UI::big_clock_value_changed ()
2372 _session->request_locate (big_clock->current_time ());
2377 ARDOUR_UI::secondary_clock_value_changed ()
2380 _session->request_locate (secondary_clock->current_time ());
2385 ARDOUR_UI::transport_rec_enable_blink (bool onoff)
2387 if (_session == 0) {
2391 if (_session->step_editing()) {
2395 Session::RecordState const r = _session->record_status ();
2396 bool const h = _session->have_rec_enabled_track ();
2398 if (r == Session::Enabled || (r == Session::Recording && !h)) {
2400 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2402 rec_button.set_active_state (Gtkmm2ext::ImplicitActive);
2404 } else if (r == Session::Recording && h) {
2405 rec_button.set_active_state (Gtkmm2ext::ExplicitActive);
2407 rec_button.unset_active_state ();
2412 ARDOUR_UI::save_template ()
2414 ArdourPrompter prompter (true);
2417 if (!check_audioengine()) {
2421 prompter.set_name (X_("Prompter"));
2422 prompter.set_title (_("Save Template"));
2423 prompter.set_prompt (_("Name for template:"));
2424 prompter.set_initial_text(_session->name() + _("-template"));
2425 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
2427 switch (prompter.run()) {
2428 case RESPONSE_ACCEPT:
2429 prompter.get_result (name);
2431 if (name.length()) {
2432 _session->save_template (name);
2442 ARDOUR_UI::edit_metadata ()
2444 SessionMetadataEditor dialog;
2445 dialog.set_session (_session);
2446 editor->ensure_float (dialog);
2451 ARDOUR_UI::import_metadata ()
2453 SessionMetadataImporter dialog;
2454 dialog.set_session (_session);
2455 editor->ensure_float (dialog);
2460 ARDOUR_UI::ask_about_loading_existing_session (const std::string& session_path)
2462 std::string str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
2464 MessageDialog msg (str,
2466 Gtk::MESSAGE_WARNING,
2467 Gtk::BUTTONS_YES_NO,
2471 msg.set_name (X_("OpenExistingDialog"));
2472 msg.set_title (_("Open Existing Session"));
2473 msg.set_wmclass (X_("existing_session"), PROGRAM_NAME);
2474 msg.set_position (Gtk::WIN_POS_MOUSE);
2475 pop_back_splash (msg);
2477 switch (msg.run()) {
2486 ARDOUR_UI::build_session_from_nsd (const std::string& session_path, const std::string& session_name)
2488 BusProfile bus_profile;
2490 if (nsm || Profile->get_sae()) {
2492 bus_profile.master_out_channels = 2;
2493 bus_profile.input_ac = AutoConnectPhysical;
2494 bus_profile.output_ac = AutoConnectMaster;
2495 bus_profile.requested_physical_in = 0; // use all available
2496 bus_profile.requested_physical_out = 0; // use all available
2500 /* get settings from advanced section of NSD */
2502 if (_startup->create_master_bus()) {
2503 bus_profile.master_out_channels = (uint32_t) _startup->master_channel_count();
2505 bus_profile.master_out_channels = 0;
2508 if (_startup->connect_inputs()) {
2509 bus_profile.input_ac = AutoConnectPhysical;
2511 bus_profile.input_ac = AutoConnectOption (0);
2514 bus_profile.output_ac = AutoConnectOption (0);
2516 if (_startup->connect_outputs ()) {
2517 if (_startup->connect_outs_to_master()) {
2518 bus_profile.output_ac = AutoConnectMaster;
2519 } else if (_startup->connect_outs_to_physical()) {
2520 bus_profile.output_ac = AutoConnectPhysical;
2524 bus_profile.requested_physical_in = (uint32_t) _startup->input_limit_count();
2525 bus_profile.requested_physical_out = (uint32_t) _startup->output_limit_count();
2528 if (build_session (session_path, session_name, bus_profile)) {
2536 ARDOUR_UI::idle_load (const std::string& path)
2539 if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) {
2540 /* /path/to/foo => /path/to/foo, foo */
2541 load_session (path, basename_nosuffix (path));
2543 /* /path/to/foo/foo.ardour => /path/to/foo, foo */
2544 load_session (Glib::path_get_dirname (path), basename_nosuffix (path));
2548 ARDOUR_COMMAND_LINE::session_name = path;
2552 /** @param quit_on_cancel true if exit() should be called if the user clicks `cancel' in the new session dialog */
2554 ARDOUR_UI::get_session_parameters (bool quit_on_cancel, bool should_be_new, string load_template)
2556 string session_name;
2557 string session_path;
2558 string template_name;
2560 bool likely_new = false;
2562 /* deal with any existing DIRTY session now, rather than later. don't
2563 * treat a non-dirty session this way, so that it stays visible
2564 * as we bring up the new session dialog.
2567 if (_session && ARDOUR_UI::instance()->video_timeline) {
2568 ARDOUR_UI::instance()->video_timeline->sync_session_state();
2571 if (_session && _session->dirty()) {
2572 if (unload_session (false)) {
2573 /* unload cancelled by user */
2576 ARDOUR_COMMAND_LINE::session_name = "";
2579 if (!load_template.empty()) {
2580 should_be_new = true;
2581 template_name = load_template;
2586 if (!ARDOUR_COMMAND_LINE::session_name.empty()) {
2588 /* if they named a specific statefile, use it, otherwise they are
2589 just giving a session folder, and we want to use it as is
2590 to find the session.
2593 string::size_type suffix = ARDOUR_COMMAND_LINE::session_name.find (statefile_suffix);
2595 if (suffix != string::npos) {
2596 session_path = Glib::path_get_dirname (ARDOUR_COMMAND_LINE::session_name);
2597 session_name = ARDOUR_COMMAND_LINE::session_name.substr (0, suffix);
2598 session_name = Glib::path_get_basename (session_name);
2600 session_path = ARDOUR_COMMAND_LINE::session_name;
2601 session_name = Glib::path_get_basename (ARDOUR_COMMAND_LINE::session_name);
2609 _startup = new ArdourStartup (should_be_new, session_name, session_path, load_template);
2611 if (!_startup->ready_without_display()) {
2612 _startup->present ();
2617 switch (_startup->response()) {
2621 if (quit_on_cancel) {
2628 /* if we run the startup dialog again, offer more than just "new session" */
2630 should_be_new = false;
2632 session_name = _startup->session_name (likely_new);
2638 string::size_type suffix = session_name.find (statefile_suffix);
2640 if (suffix != string::npos) {
2641 session_name = session_name.substr (0, suffix);
2644 /* this shouldn't happen, but we catch it just in case it does */
2646 if (session_name.empty()) {
2650 if (_startup->use_session_template()) {
2651 template_name = _startup->session_template_name();
2652 _session_is_new = true;
2655 if (session_name[0] == G_DIR_SEPARATOR ||
2656 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == G_DIR_SEPARATOR) ||
2657 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == G_DIR_SEPARATOR)) {
2659 /* absolute path or cwd-relative path specified for session name: infer session folder
2660 from what was given.
2663 session_path = Glib::path_get_dirname (session_name);
2664 session_name = Glib::path_get_basename (session_name);
2668 session_path = _startup->session_folder();
2670 char illegal = Session::session_name_is_legal (session_name);
2673 MessageDialog msg (*_startup,
2674 string_compose (_("To ensure compatibility with various systems\n"
2675 "session names may not contain a '%1' character"),
2678 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2683 if (create_engine ()) {
2687 if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
2689 if (likely_new && !nsm) {
2691 std::string existing = Glib::build_filename (session_path, session_name);
2693 if (!ask_about_loading_existing_session (existing)) {
2694 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2699 _session_is_new = false;
2705 pop_back_splash (*_startup);
2710 MessageDialog msg (string_compose (_("There is no existing session at \"%1\""), session_path));
2712 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2716 char illegal = Session::session_name_is_legal(session_name);
2718 pop_back_splash (*_startup);
2719 MessageDialog msg (*_startup, string_compose(_("To ensure compatibility with various systems\n"
2720 "session names may not contain a '%1' character"), illegal));
2722 ARDOUR_COMMAND_LINE::session_name = ""; // cancel that
2726 _session_is_new = true;
2729 if (likely_new && template_name.empty()) {
2731 ret = build_session_from_nsd (session_path, session_name);
2735 ret = load_session (session_path, session_name, template_name);
2738 /* not connected to the AudioEngine, so quit to avoid an infinite loop */
2742 if (!ARDOUR_COMMAND_LINE::immediate_save.empty()) {
2743 _session->save_state (ARDOUR_COMMAND_LINE::immediate_save, false);
2753 ARDOUR_UI::close_session()
2755 if (!check_audioengine()) {
2759 if (unload_session (true)) {
2763 ARDOUR_COMMAND_LINE::session_name = "";
2765 if (get_session_parameters (true, false)) {
2769 goto_editor_window ();
2772 /** @param snap_name Snapshot name (without .ardour suffix).
2773 * @return -2 if the load failed because we are not connected to the AudioEngine.
2776 ARDOUR_UI::load_session (const std::string& path, const std::string& snap_name, std::string mix_template)
2778 Session *new_session;
2782 session_loaded = false;
2784 if (!check_audioengine()) {
2788 unload_status = unload_session ();
2790 if (unload_status < 0) {
2792 } else if (unload_status > 0) {
2797 loading_message (string_compose (_("Please wait while %1 loads your session"), PROGRAM_NAME));
2800 new_session = new Session (*engine, path, snap_name, 0, mix_template);
2803 /* this one is special */
2805 catch (AudioEngine::PortRegistrationFailure& err) {
2807 MessageDialog msg (err.what(),
2810 Gtk::BUTTONS_CLOSE);
2812 msg.set_title (_("Port Registration Error"));
2813 msg.set_secondary_text (_("Click the Close button to try again."));
2814 msg.set_position (Gtk::WIN_POS_CENTER);
2815 pop_back_splash (msg);
2818 int response = msg.run ();
2823 case RESPONSE_CANCEL:
2833 MessageDialog msg (string_compose(
2834 _("Session \"%1 (snapshot %2)\" did not load successfully"),
2840 msg.set_title (_("Loading Error"));
2841 msg.set_secondary_text (_("Click the Refresh button to try again."));
2842 msg.add_button (Stock::REFRESH, 1);
2843 msg.set_position (Gtk::WIN_POS_CENTER);
2844 pop_back_splash (msg);
2847 int response = msg.run ();
2862 list<string> const u = new_session->unknown_processors ();
2864 MissingPluginDialog d (_session, u);
2869 /* Now the session been created, add the transport controls */
2870 new_session->add_controllable(roll_controllable);
2871 new_session->add_controllable(stop_controllable);
2872 new_session->add_controllable(goto_start_controllable);
2873 new_session->add_controllable(goto_end_controllable);
2874 new_session->add_controllable(auto_loop_controllable);
2875 new_session->add_controllable(play_selection_controllable);
2876 new_session->add_controllable(rec_controllable);
2878 set_session (new_session);
2880 session_loaded = true;
2882 goto_editor_window ();
2885 _session->set_clean ();
2896 ARDOUR_UI::build_session (const std::string& path, const std::string& snap_name, BusProfile& bus_profile)
2898 Session *new_session;
2901 if (!check_audioengine()) {
2905 session_loaded = false;
2907 x = unload_session ();
2915 _session_is_new = true;
2918 new_session = new Session (*engine, path, snap_name, &bus_profile);
2923 MessageDialog msg (string_compose(_("Could not create session in \"%1\""), path));
2924 pop_back_splash (msg);
2929 /* Give the new session the default GUI state, if such things exist */
2932 n = Config->instant_xml (X_("Editor"));
2934 new_session->add_instant_xml (*n, false);
2936 n = Config->instant_xml (X_("Mixer"));
2938 new_session->add_instant_xml (*n, false);
2941 /* Put the playhead at 0 and scroll fully left */
2942 n = new_session->instant_xml (X_("Editor"));
2944 n->add_property (X_("playhead"), X_("0"));
2945 n->add_property (X_("left-frame"), X_("0"));
2948 set_session (new_session);
2950 session_loaded = true;
2952 new_session->save_state(new_session->name());
2958 ARDOUR_UI::launch_chat ()
2961 open_uri("http://webchat.freenode.net/?channels=ardour-osx");
2963 open_uri("http://webchat.freenode.net/?channels=ardour");
2968 ARDOUR_UI::launch_manual ()
2970 PBD::open_uri (Config->get_tutorial_manual_url());
2974 ARDOUR_UI::launch_reference ()
2976 PBD::open_uri (Config->get_reference_manual_url());
2980 ARDOUR_UI::loading_message (const std::string& msg)
2982 if (ARDOUR_COMMAND_LINE::no_splash) {
2990 splash->message (msg);
2994 ARDOUR_UI::show_splash ()
2998 splash = new Splash;
3008 ARDOUR_UI::hide_splash ()
3015 ARDOUR_UI::display_cleanup_results (ARDOUR::CleanupReport& rep, const gchar* list_title, const bool msg_delete)
3019 removed = rep.paths.size();
3022 MessageDialog msgd (*editor,
3023 _("No files were ready for clean-up"),
3027 msgd.set_title (_("Clean-up"));
3028 msgd.set_secondary_text (_("If this seems suprising, \n\
3029 check for any existing snapshots.\n\
3030 These may still include regions that\n\
3031 require some unused files to continue to exist."));
3037 ArdourDialog results (_("Clean-up"), true, false);
3039 struct CleanupResultsModelColumns : public Gtk::TreeModel::ColumnRecord {
3040 CleanupResultsModelColumns() {
3044 Gtk::TreeModelColumn<std::string> visible_name;
3045 Gtk::TreeModelColumn<std::string> fullpath;
3049 CleanupResultsModelColumns results_columns;
3050 Glib::RefPtr<Gtk::ListStore> results_model;
3051 Gtk::TreeView results_display;
3053 results_model = ListStore::create (results_columns);
3054 results_display.set_model (results_model);
3055 results_display.append_column (list_title, results_columns.visible_name);
3057 results_display.set_name ("CleanupResultsList");
3058 results_display.set_headers_visible (true);
3059 results_display.set_headers_clickable (false);
3060 results_display.set_reorderable (false);
3062 Gtk::ScrolledWindow list_scroller;
3065 Gtk::HBox dhbox; // the hbox for the image and text
3066 Gtk::HBox ddhbox; // the hbox we eventually pack into the dialog's vbox
3067 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG));
3069 dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
3071 const string dead_directory = _session->session_directory().dead_path();
3074 %1 - number of files removed
3075 %2 - location of "dead"
3076 %3 - size of files affected
3077 %4 - prefix for "bytes" to produce sensible results (e.g. mega, kilo, giga)
3080 const char* bprefix;
3081 double space_adjusted = 0;
3083 if (rep.space < 1000) {
3085 space_adjusted = rep.space;
3086 } else if (rep.space < 1000000) {
3087 bprefix = _("kilo");
3088 space_adjusted = truncf((float)rep.space / 1000.0);
3089 } else if (rep.space < 1000000 * 1000) {
3090 bprefix = _("mega");
3091 space_adjusted = truncf((float)rep.space / (1000.0 * 1000.0));
3093 bprefix = _("giga");
3094 space_adjusted = truncf((float)rep.space / (1000.0 * 1000 * 1000.0));
3098 txt.set_markup (string_compose (P_("\
3099 The following file was deleted from %2,\n\
3100 releasing %3 %4bytes of disk space", "\
3101 The following %1 files were deleted from %2,\n\
3102 releasing %3 %4bytes of disk space", removed),
3103 removed, Glib::Markup::escape_text (dead_directory), space_adjusted, bprefix, PROGRAM_NAME));
3105 txt.set_markup (string_compose (P_("\
3106 The following file was not in use and \n\
3107 has been moved to: %2\n\n\
3108 After a restart of %5\n\n\
3109 <span face=\"mono\">Session -> Clean-up -> Flush Wastebasket</span>\n\n\
3110 will release an additional %3 %4bytes of disk space.\n", "\
3111 The following %1 files were not in use and \n\
3112 have been moved to: %2\n\n\
3113 After a restart of %5\n\n\
3114 <span face=\"mono\">Session -> Clean-up -> Flush Wastebasket</span>\n\n\
3115 will release an additional %3 %4bytes of disk space.\n", removed),
3116 removed, Glib::Markup::escape_text (dead_directory), space_adjusted, bprefix, PROGRAM_NAME));
3119 dhbox.pack_start (*dimage, true, false, 5);
3120 dhbox.pack_start (txt, true, false, 5);
3122 for (vector<string>::iterator i = rep.paths.begin(); i != rep.paths.end(); ++i) {
3123 TreeModel::Row row = *(results_model->append());
3124 row[results_columns.visible_name] = *i;
3125 row[results_columns.fullpath] = *i;
3128 list_scroller.add (results_display);
3129 list_scroller.set_size_request (-1, 150);
3130 list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
3132 dvbox.pack_start (dhbox, true, false, 5);
3133 dvbox.pack_start (list_scroller, true, false, 5);
3134 ddhbox.pack_start (dvbox, true, false, 5);
3136 results.get_vbox()->pack_start (ddhbox, true, false, 5);
3137 results.add_button (Stock::CLOSE, RESPONSE_CLOSE);
3138 results.set_default_response (RESPONSE_CLOSE);
3139 results.set_position (Gtk::WIN_POS_MOUSE);
3141 results_display.show();
3142 list_scroller.show();
3149 //results.get_vbox()->show();
3150 results.set_resizable (false);
3157 ARDOUR_UI::cleanup ()
3159 if (_session == 0) {
3160 /* shouldn't happen: menu item is insensitive */
3165 MessageDialog checker (_("Are you sure you want to clean-up?"),
3167 Gtk::MESSAGE_QUESTION,
3170 checker.set_title (_("Clean-up"));
3172 checker.set_secondary_text(_("Clean-up is a destructive operation.\n\
3173 ALL undo/redo information will be lost if you clean-up.\n\
3174 Clean-up will move all unused files to a \"dead\" location."));
3176 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
3177 checker.add_button (_("Clean-up"), RESPONSE_ACCEPT);
3178 checker.set_default_response (RESPONSE_CANCEL);
3180 checker.set_name (_("CleanupDialog"));
3181 checker.set_wmclass (X_("ardour_cleanup"), PROGRAM_NAME);
3182 checker.set_position (Gtk::WIN_POS_MOUSE);
3184 switch (checker.run()) {
3185 case RESPONSE_ACCEPT:
3191 ARDOUR::CleanupReport rep;
3193 editor->prepare_for_cleanup ();
3195 /* do not allow flush until a session is reloaded */
3197 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Main"), X_("FlushWastebasket"));
3199 act->set_sensitive (false);
3202 if (_session->cleanup_sources (rep)) {
3203 editor->finish_cleanup ();
3207 editor->finish_cleanup ();
3210 display_cleanup_results (rep, _("Cleaned Files"), false);
3214 ARDOUR_UI::flush_trash ()
3216 if (_session == 0) {
3217 /* shouldn't happen: menu item is insensitive */
3221 ARDOUR::CleanupReport rep;
3223 if (_session->cleanup_trash_sources (rep)) {
3227 display_cleanup_results (rep, _("deleted file"), true);
3231 ARDOUR_UI::add_route (Gtk::Window* float_window)
3239 if (add_route_dialog->is_visible()) {
3240 /* we're already doing this */
3245 add_route_dialog->set_transient_for (*float_window);
3248 ResponseType r = (ResponseType) add_route_dialog->run ();
3250 add_route_dialog->hide();
3253 case RESPONSE_ACCEPT:
3260 if ((count = add_route_dialog->count()) <= 0) {
3264 PBD::ScopedConnection idle_connection;
3267 ARDOUR::GUIIdle.connect (idle_connection, MISSING_INVALIDATOR, boost::bind (&Gtkmm2ext::UI::flush_pending, this), gui_context());
3270 string template_path = add_route_dialog->track_template();
3272 if (!template_path.empty()) {
3273 if (add_route_dialog->name_template_is_default()) {
3274 _session->new_route_from_template (count, template_path, string());
3276 _session->new_route_from_template (count, template_path, add_route_dialog->name_template());
3281 ChanCount input_chan= add_route_dialog->channels ();
3282 ChanCount output_chan;
3283 string name_template = add_route_dialog->name_template ();
3284 PluginInfoPtr instrument = add_route_dialog->requested_instrument ();
3285 RouteGroup* route_group = add_route_dialog->route_group ();
3286 AutoConnectOption oac = Config->get_output_auto_connect();
3288 if (oac & AutoConnectMaster) {
3289 output_chan.set (DataType::AUDIO, (_session->master_out() ? _session->master_out()->n_inputs().n_audio() : input_chan.n_audio()));
3290 output_chan.set (DataType::MIDI, 0);
3292 output_chan = input_chan;
3295 /* XXX do something with name template */
3297 switch (add_route_dialog->type_wanted()) {
3298 case AddRouteDialog::AudioTrack:
3299 session_add_audio_track (input_chan.n_audio(), output_chan.n_audio(), add_route_dialog->mode(), route_group, count, name_template);
3301 case AddRouteDialog::MidiTrack:
3302 session_add_midi_track (route_group, count, name_template, instrument);
3304 case AddRouteDialog::MixedTrack:
3305 session_add_mixed_track (input_chan, output_chan, route_group, count, name_template, instrument);
3307 case AddRouteDialog::AudioBus:
3308 session_add_audio_bus (input_chan.n_audio(), output_chan.n_audio(), route_group, count, name_template);
3312 /* idle connection will end at scope end */
3316 ARDOUR_UI::stop_video_server (bool ask_confirm)
3318 if (!video_server_process && ask_confirm) {
3319 warning << _("Video-Server was not launched by Ardour. The request to stop it is ignored.") << endmsg;
3321 if (video_server_process) {
3323 ArdourDialog confirm (_("Stop Video-Server"), true);
3324 Label m (_("Do you really want to stop the Video Server?"));
3325 confirm.get_vbox()->pack_start (m, true, true);
3326 confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
3327 confirm.add_button (_("Yes, Stop It"), Gtk::RESPONSE_ACCEPT);
3328 confirm.show_all ();
3329 if (confirm.run() == RESPONSE_CANCEL) {
3333 delete video_server_process;
3334 video_server_process =0;
3339 ARDOUR_UI::start_video_server_menu (Gtk::Window* float_window)
3341 ARDOUR_UI::start_video_server( float_window, true);
3345 ARDOUR_UI::start_video_server (Gtk::Window* float_window, bool popup_msg)
3351 if (ARDOUR_UI::instance()->video_timeline->check_server()) {
3352 if (video_server_process) {
3353 popup_error(_("The Video Server is already started."));
3355 popup_error(_("An external Video Server is configured and can be reached. Not starting a new instance."));
3361 while (!ARDOUR_UI::instance()->video_timeline->check_server()) {
3363 warning << _("Could not connect to the Video Server. Start it or configure its access URL in Edit -> Preferences.") << endmsg;
3365 VideoServerDialog *video_server_dialog = new VideoServerDialog (_session);
3367 video_server_dialog->set_transient_for (*float_window);
3370 if (!Config->get_show_video_server_dialog() && firsttime < 2) {
3371 video_server_dialog->hide();
3373 ResponseType r = (ResponseType) video_server_dialog->run ();
3374 video_server_dialog->hide();
3375 if (r != RESPONSE_ACCEPT) { return false; }
3376 if (video_server_dialog->show_again()) {
3377 Config->set_show_video_server_dialog(false);
3381 std::string icsd_exec = video_server_dialog->get_exec_path();
3382 std::string icsd_docroot = video_server_dialog->get_docroot();
3383 if (icsd_docroot.empty()) {icsd_docroot = X_("/");}
3386 if (!lstat (icsd_docroot.c_str(), &sb) == 0 || !S_ISDIR(sb.st_mode)) {
3387 warning << _("Specified docroot is not an existing directory.") << endmsg;
3390 if ( (!lstat (icsd_exec.c_str(), &sb) == 0)
3391 || (sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)) == 0 ) {
3392 warning << _("Given Video Server is not an executable file.") << endmsg;
3397 argp=(char**) calloc(9,sizeof(char*));
3398 argp[0] = strdup(icsd_exec.c_str());
3399 argp[1] = strdup("-P");
3400 argp[2] = (char*) calloc(16,sizeof(char)); snprintf(argp[2], 16, "%s", video_server_dialog->get_listenaddr().c_str());
3401 argp[3] = strdup("-p");
3402 argp[4] = (char*) calloc(6,sizeof(char)); snprintf(argp[4], 6, "%i", video_server_dialog->get_listenport());
3403 argp[5] = strdup("-C");
3404 argp[6] = (char*) calloc(6,sizeof(char)); snprintf(argp[6], 6, "%i", video_server_dialog->get_cachesize());
3405 argp[7] = strdup(icsd_docroot.c_str());
3407 stop_video_server();
3409 if (icsd_docroot == X_("/")) {
3410 Config->set_video_advanced_setup(false);
3412 std::ostringstream osstream;
3413 osstream << "http://localhost:" << video_server_dialog->get_listenport() << "/";
3414 Config->set_video_server_url(osstream.str());
3415 Config->set_video_server_docroot(icsd_docroot);
3416 Config->set_video_advanced_setup(true);
3419 video_server_process = new SystemExec(icsd_exec, argp);
3420 video_server_process->start();
3427 ARDOUR_UI::add_video (Gtk::Window* float_window)
3433 if (!start_video_server(float_window, false)) {
3434 warning << _("Could not connect to the Video Server. Start it or configure its access URL in Edit -> Preferences.") << endmsg;
3439 add_video_dialog->set_transient_for (*float_window);
3442 if (add_video_dialog->is_visible()) {
3443 /* we're already doing this */
3447 ResponseType r = (ResponseType) add_video_dialog->run ();
3448 add_video_dialog->hide();
3449 if (r != RESPONSE_ACCEPT) { return; }
3452 std::string path = add_video_dialog->file_name(local_file);
3453 bool auto_set_session_fps = add_video_dialog->auto_set_session_fps();
3455 if (local_file && !Glib::file_test(path, Glib::FILE_TEST_EXISTS)) {
3456 warning << string_compose(_("could not open %1"), path) << endmsg;
3459 if (!local_file && path.length() == 0) {
3460 warning << _("no video-file selected") << endmsg;
3464 switch (add_video_dialog->import_option()) {
3465 case VTL_IMPORT_TRANSCODE:
3467 TranscodeVideoDialog *transcode_video_dialog;
3468 transcode_video_dialog = new TranscodeVideoDialog (_session, path);
3469 ResponseType r = (ResponseType) transcode_video_dialog->run ();
3470 transcode_video_dialog->hide();
3471 if (r != RESPONSE_ACCEPT) {
3472 delete transcode_video_dialog;
3475 if (!transcode_video_dialog->get_audiofile().empty()) {
3476 editor->embed_audio_from_video(transcode_video_dialog->get_audiofile());
3478 switch (transcode_video_dialog->import_option()) {
3479 case VTL_IMPORT_TRANSCODED:
3480 path = transcode_video_dialog->get_filename();
3483 case VTL_IMPORT_REFERENCE:
3486 delete transcode_video_dialog;
3489 delete transcode_video_dialog;
3493 case VTL_IMPORT_NONE:
3497 /* strip _session->session_directory().video_path() from video file if possible */
3498 if (local_file && !path.compare(0, _session->session_directory().video_path().size(), _session->session_directory().video_path())) {
3499 path=path.substr(_session->session_directory().video_path().size());
3500 if (path.at(0) == G_DIR_SEPARATOR) {
3501 path=path.substr(1);
3505 video_timeline->set_update_session_fps(auto_set_session_fps);
3506 if (video_timeline->video_file_info(path, local_file)) {
3507 XMLNode* node = new XMLNode(X_("Videotimeline"));
3508 node->add_property (X_("Filename"), path);
3509 node->add_property (X_("AutoFPS"), auto_set_session_fps?X_("1"):X_("0"));
3510 node->add_property (X_("LocalFile"), local_file?X_("1"):X_("0"));
3511 _session->add_extra_xml (*node);
3512 _session->set_dirty ();
3514 _session->maybe_update_session_range(
3515 std::max(video_timeline->get_offset(), (ARDOUR::frameoffset_t) 0),
3516 std::max(video_timeline->get_offset() + video_timeline->get_duration(), (ARDOUR::frameoffset_t) 0));
3519 if (add_video_dialog->launch_xjadeo() && local_file) {
3520 editor->set_xjadeo_sensitive(true);
3521 editor->toggle_xjadeo_proc(1);
3523 editor->toggle_xjadeo_proc(0);
3525 editor->toggle_ruler_video(true);
3530 ARDOUR_UI::remove_video ()
3532 video_timeline->close_session();
3533 editor->toggle_ruler_video(false);
3535 /* delete session state */
3536 XMLNode* node = new XMLNode(X_("Videotimeline"));
3537 _session->add_extra_xml(*node);
3538 node = new XMLNode(X_("Videomonitor"));
3539 _session->add_extra_xml(*node);
3540 stop_video_server();
3544 ARDOUR_UI::flush_videotimeline_cache (bool localcacheonly)
3546 if (localcacheonly) {
3547 video_timeline->vmon_update();
3549 video_timeline->flush_cache();
3551 editor->queue_visual_videotimeline_update();
3555 ARDOUR_UI::mixer_settings () const
3560 node = _session->instant_xml(X_("Mixer"));
3562 node = Config->instant_xml(X_("Mixer"));
3566 node = new XMLNode (X_("Mixer"));
3573 ARDOUR_UI::editor_settings () const
3578 node = _session->instant_xml(X_("Editor"));
3580 node = Config->instant_xml(X_("Editor"));
3584 if (getenv("ARDOUR_INSTANT_XML_PATH")) {
3585 node = Config->instant_xml(getenv("ARDOUR_INSTANT_XML_PATH"));
3590 node = new XMLNode (X_("Editor"));
3597 ARDOUR_UI::keyboard_settings () const
3601 node = Config->extra_xml(X_("Keyboard"));
3604 node = new XMLNode (X_("Keyboard"));
3611 ARDOUR_UI::create_xrun_marker (framepos_t where)
3613 editor->mouse_add_new_marker (where, false, true);
3617 ARDOUR_UI::halt_on_xrun_message ()
3619 MessageDialog msg (*editor,
3620 _("Recording was stopped because your system could not keep up."));
3625 ARDOUR_UI::xrun_handler (framepos_t where)
3631 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::xrun_handler, where)
3633 if (_session && Config->get_create_xrun_marker() && _session->actively_recording()) {
3634 create_xrun_marker(where);
3637 if (_session && Config->get_stop_recording_on_xrun() && _session->actively_recording()) {
3638 halt_on_xrun_message ();
3643 ARDOUR_UI::disk_overrun_handler ()
3645 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_overrun_handler)
3647 if (!have_disk_speed_dialog_displayed) {
3648 have_disk_speed_dialog_displayed = true;
3649 MessageDialog* msg = new MessageDialog (*editor, string_compose (_("\
3650 The disk system on your computer\n\
3651 was not able to keep up with %1.\n\
3653 Specifically, it failed to write data to disk\n\
3654 quickly enough to keep up with recording.\n"), PROGRAM_NAME));
3655 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
3661 ARDOUR_UI::disk_underrun_handler ()
3663 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::disk_underrun_handler)
3665 if (!have_disk_speed_dialog_displayed) {
3666 have_disk_speed_dialog_displayed = true;
3667 MessageDialog* msg = new MessageDialog (
3668 *editor, string_compose (_("The disk system on your computer\n\
3669 was not able to keep up with %1.\n\
3671 Specifically, it failed to read data from disk\n\
3672 quickly enough to keep up with playback.\n"), PROGRAM_NAME));
3673 msg->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::disk_speed_dialog_gone), msg));
3679 ARDOUR_UI::disk_speed_dialog_gone (int /*ignored_response*/, MessageDialog* msg)
3681 have_disk_speed_dialog_displayed = false;
3686 ARDOUR_UI::session_dialog (std::string msg)
3688 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::session_dialog, msg)
3693 d = new MessageDialog (*editor, msg, false, MESSAGE_INFO, BUTTONS_OK, true);
3695 d = new MessageDialog (msg, false, MESSAGE_INFO, BUTTONS_OK, true);
3704 ARDOUR_UI::pending_state_dialog ()
3706 HBox* hbox = new HBox();
3707 Image* image = new Image (Stock::DIALOG_QUESTION, ICON_SIZE_DIALOG);
3708 ArdourDialog dialog (_("Crash Recovery"), true);
3709 Label message (string_compose (_("\
3710 This session appears to have been in the\n\
3711 middle of recording when %1 or\n\
3712 the computer was shutdown.\n\
3714 %1 can recover any captured audio for\n\
3715 you, or it can ignore it. Please decide\n\
3716 what you would like to do.\n"), PROGRAM_NAME));
3717 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
3718 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
3719 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
3720 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
3721 dialog.add_button (_("Ignore crash data"), RESPONSE_REJECT);
3722 dialog.add_button (_("Recover from crash"), RESPONSE_ACCEPT);
3723 dialog.set_default_response (RESPONSE_ACCEPT);
3724 dialog.set_position (WIN_POS_CENTER);
3729 switch (dialog.run ()) {
3730 case RESPONSE_ACCEPT:
3738 ARDOUR_UI::sr_mismatch_dialog (framecnt_t desired, framecnt_t actual)
3740 HBox* hbox = new HBox();
3741 Image* image = new Image (Stock::DIALOG_WARNING, ICON_SIZE_DIALOG);
3742 ArdourDialog dialog (_("Sample Rate Mismatch"), true);
3743 Label message (string_compose (_("\
3744 This session was created with a sample rate of %1 Hz, but\n\
3745 %2 is currently running at %3 Hz. If you load this session,\n\
3746 audio may be played at the wrong sample rate.\n"), desired, PROGRAM_NAME, actual));
3748 image->set_alignment(ALIGN_CENTER, ALIGN_TOP);
3749 hbox->pack_start (*image, PACK_EXPAND_WIDGET, 12);
3750 hbox->pack_end (message, PACK_EXPAND_PADDING, 12);
3751 dialog.get_vbox()->pack_start(*hbox, PACK_EXPAND_PADDING, 6);
3752 dialog.add_button (_("Do not load session"), RESPONSE_REJECT);
3753 dialog.add_button (_("Load session anyway"), RESPONSE_ACCEPT);
3754 dialog.set_default_response (RESPONSE_ACCEPT);
3755 dialog.set_position (WIN_POS_CENTER);
3760 switch (dialog.run()) {
3761 case RESPONSE_ACCEPT:
3772 ARDOUR_UI::disconnect_from_jack ()
3775 if (engine->disconnect_from_jack ()) {
3776 MessageDialog msg (*editor, _("Could not disconnect from JACK"));
3780 update_sample_rate (0);
3785 ARDOUR_UI::reconnect_to_jack ()
3788 if (engine->reconnect_to_jack ()) {
3789 MessageDialog msg (*editor, _("Could not reconnect to JACK"));
3793 update_sample_rate (0);
3798 ARDOUR_UI::use_config ()
3800 XMLNode* node = Config->extra_xml (X_("TransportControllables"));
3802 set_transport_controllable_state (*node);
3807 ARDOUR_UI::update_transport_clocks (framepos_t pos)
3809 if (Config->get_primary_clock_delta_edit_cursor()) {
3810 primary_clock->set (pos, false, editor->get_preferred_edit_position());
3812 primary_clock->set (pos);
3815 if (Config->get_secondary_clock_delta_edit_cursor()) {
3816 secondary_clock->set (pos, false, editor->get_preferred_edit_position());
3818 secondary_clock->set (pos);
3821 if (big_clock_window) {
3822 big_clock->set (pos);
3824 ARDOUR_UI::instance()->video_timeline->manual_seek_video_monitor(pos);
3828 ARDOUR_UI::step_edit_status_change (bool yn)
3830 // XXX should really store pre-step edit status of things
3831 // we make insensitive
3834 rec_button.set_active_state (Gtkmm2ext::ImplicitActive);
3835 rec_button.set_sensitive (false);
3837 rec_button.unset_active_state ();;
3838 rec_button.set_sensitive (true);
3843 ARDOUR_UI::record_state_changed ()
3845 ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed);
3847 if (!_session || !big_clock_window) {
3848 /* why bother - the clock isn't visible */
3852 if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) {
3853 big_clock->set_active (true);
3855 big_clock->set_active (false);
3860 ARDOUR_UI::first_idle ()
3863 _session->allow_auto_play (true);
3867 editor->first_idle();
3870 Keyboard::set_can_save_keybindings (true);
3875 ARDOUR_UI::store_clock_modes ()
3877 XMLNode* node = new XMLNode(X_("ClockModes"));
3879 for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
3880 XMLNode* child = new XMLNode (X_("Clock"));
3882 child->add_property (X_("name"), (*x)->name());
3883 child->add_property (X_("mode"), enum_2_string ((*x)->mode()));
3884 child->add_property (X_("on"), ((*x)->off() ? X_("no") : X_("yes")));
3886 node->add_child_nocopy (*child);
3889 _session->add_extra_xml (*node);
3890 _session->set_dirty ();
3893 ARDOUR_UI::TransportControllable::TransportControllable (std::string name, ARDOUR_UI& u, ToggleType tp)
3894 : Controllable (name), ui (u), type(tp)
3900 ARDOUR_UI::TransportControllable::set_value (double val)
3903 /* do nothing: these are radio-style actions */
3907 const char *action = 0;
3911 action = X_("Roll");
3914 action = X_("Stop");
3917 action = X_("GotoStart");
3920 action = X_("GotoEnd");
3923 action = X_("Loop");
3926 action = X_("PlaySelection");
3929 action = X_("Record");
3939 Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", action);
3947 ARDOUR_UI::TransportControllable::get_value (void) const
3974 ARDOUR_UI::setup_profile ()
3976 if (gdk_screen_width() < 1200 || getenv ("ARDOUR_NARROW_SCREEN")) {
3977 Profile->set_small_screen ();
3980 if (getenv ("ARDOUR_SAE")) {
3981 Profile->set_sae ();
3982 Profile->set_single_package ();
3987 ARDOUR_UI::missing_file (Session*s, std::string str, DataType type)
3989 MissingFileDialog dialog (s, str, type);
3994 int result = dialog.run ();
4001 return 1; // quit entire session load
4004 result = dialog.get_action ();
4010 ARDOUR_UI::ambiguous_file (std::string file, std::string /*path*/, std::vector<std::string> hits)
4012 AmbiguousFileDialog dialog (file, hits);
4018 return dialog.get_which ();
4021 /** Allocate our thread-local buffers */
4023 ARDOUR_UI::get_process_buffers ()
4025 _process_thread->get_buffers ();
4028 /** Drop our thread-local buffers */
4030 ARDOUR_UI::drop_process_buffers ()
4032 _process_thread->drop_buffers ();
4036 ARDOUR_UI::feedback_detected ()
4038 _feedback_exists = true;
4042 ARDOUR_UI::successful_graph_sort ()
4044 _feedback_exists = false;
4048 ARDOUR_UI::midi_panic ()
4051 _session->midi_panic();
4056 ARDOUR_UI::session_format_mismatch (std::string xml_path, std::string backup_path)
4058 const char* start_big = "<span size=\"x-large\" weight=\"bold\">";
4059 const char* end_big = "</span>";
4060 const char* start_mono = "<tt>";
4061 const char* end_mono = "</tt>";
4063 MessageDialog msg (string_compose (_("%4This is a session from an older version of %3%5\n\n"
4064 "%3 has copied the old session file\n\n%6%1%7\n\nto\n\n%6%2%7\n\n"
4065 "From now on, use the -2000 version with older versions of %3"),
4066 xml_path, backup_path, PROGRAM_NAME,
4068 start_mono, end_mono), true);