2 Copyright (C) 1999-2002 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.
31 #include <gtkmm/messagedialog.h>
32 #include <gtkmm/accelmap.h>
34 #include <pbd/error.h>
35 #include <pbd/compose.h>
36 #include <pbd/pathscanner.h>
37 #include <pbd/failed_constructor.h>
38 #include <pbd/enumwriter.h>
39 #include <pbd/stacktrace.h>
40 #include <gtkmm2ext/gtk_ui.h>
41 #include <gtkmm2ext/utils.h>
42 #include <gtkmm2ext/click_box.h>
43 #include <gtkmm2ext/fastmeter.h>
44 #include <gtkmm2ext/stop_signal.h>
45 #include <gtkmm2ext/popup.h>
47 #include <midi++/port.h>
48 #include <midi++/mmc.h>
50 #include <ardour/ardour.h>
51 #include <ardour/session_route.h>
52 #include <ardour/port.h>
53 #include <ardour/audioengine.h>
54 #include <ardour/playlist.h>
55 #include <ardour/utils.h>
56 #include <ardour/audio_diskstream.h>
57 #include <ardour/audiofilesource.h>
58 #include <ardour/recent_sessions.h>
59 #include <ardour/port.h>
60 #include <ardour/audio_track.h>
63 #include "ardour_ui.h"
64 #include "public_editor.h"
65 #include "audio_clock.h"
70 #include "keyboard_target.h"
71 #include "add_route_dialog.h"
72 #include "new_session_dialog.h"
75 #include "gui_thread.h"
76 #include "color_manager.h"
80 using namespace ARDOUR;
82 using namespace Gtkmm2ext;
86 ARDOUR_UI *ARDOUR_UI::theArdourUI = 0;
88 sigc::signal<void,bool> ARDOUR_UI::Blink;
89 sigc::signal<void> ARDOUR_UI::RapidScreenUpdate;
90 sigc::signal<void> ARDOUR_UI::SuperRapidScreenUpdate;
91 sigc::signal<void,nframes_t> ARDOUR_UI::Clock;
93 ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
95 : Gtkmm2ext::UI ("ardour", argcp, argvp, rcfile),
97 primary_clock (X_("primary"), false, X_("TransportClockDisplay"), true, false, true),
98 secondary_clock (X_("secondary"), false, X_("SecondaryClockDisplay"), true, false, true),
99 preroll_clock (X_("preroll"), false, X_("PreRollClock"), true, true),
100 postroll_clock (X_("postroll"), false, X_("PostRollClock"), true, true),
104 adjuster_table (3, 3),
108 preroll_button (_("pre\nroll")),
109 postroll_button (_("post\nroll")),
113 big_clock (X_("bigclock"), false, "BigClockNonRecording", false, false, true),
117 time_master_button (_("time\nmaster")),
119 shuttle_units_button (_("% ")),
121 punch_in_button (_("Punch In")),
122 punch_out_button (_("Punch Out")),
123 auto_return_button (_("Auto Return")),
124 auto_play_button (_("Autuo Play")),
125 auto_input_button (_("Auto Input")),
126 click_button (_("Click")),
127 auditioning_alert_button (_("AUDITION")),
128 solo_alert_button (_("SOLO")),
131 using namespace Gtk::Menu_Helpers;
137 if (theArdourUI == 0) {
143 color_manager = new ColorManager();
145 std::string color_file = ARDOUR::find_config_file("ardour.colors");
147 color_manager->load (color_file);
152 _session_is_new = false;
153 big_clock_window = 0;
154 session_selector_window = 0;
155 last_key_press_time = 0;
156 connection_editor = 0;
157 add_route_dialog = 0;
161 open_session_selector = 0;
162 have_configure_timeout = false;
163 have_disk_overrun_displayed = false;
164 have_disk_underrun_displayed = false;
165 _will_create_new_session_automatically = false;
166 session_loaded = false;
167 last_speed_displayed = -1.0f;
168 keybindings_path = ARDOUR::find_config_file ("ardour.bindings");
170 can_save_keybindings = false;
171 Glib::signal_idle().connect (mem_fun (*this, &ARDOUR_UI::first_idle));
173 last_configure_time.tv_sec = 0;
174 last_configure_time.tv_usec = 0;
176 shuttle_grabbed = false;
178 shuttle_max_speed = 8.0f;
180 shuttle_style_menu = 0;
181 shuttle_unit_menu = 0;
183 gettimeofday (&last_peak_grab, 0);
184 gettimeofday (&last_shuttle_request, 0);
186 ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler));
187 ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
189 /* handle pending state with a dialog */
191 ARDOUR::Session::AskAboutPendingState.connect (mem_fun(*this, &ARDOUR_UI::pending_state_dialog));
193 /* have to wait for AudioEngine and Configuration before proceeding */
197 ARDOUR_UI::set_engine (AudioEngine& e)
201 engine->Stopped.connect (mem_fun(*this, &ARDOUR_UI::engine_stopped));
202 engine->Running.connect (mem_fun(*this, &ARDOUR_UI::engine_running));
203 engine->Halted.connect (mem_fun(*this, &ARDOUR_UI::engine_halted));
204 engine->SampleRateChanged.connect (mem_fun(*this, &ARDOUR_UI::update_sample_rate));
206 ActionManager::init ();
207 new_session_dialog = new NewSessionDialog();
211 keyboard = new Keyboard;
213 if (setup_windows ()) {
214 throw failed_constructor ();
217 if (GTK_ARDOUR::show_key_actions) {
218 vector<string> names;
219 vector<string> paths;
221 vector<AccelKey> bindings;
223 ActionManager::get_all_actions (names, paths, keys, bindings);
225 vector<string>::iterator n;
226 vector<string>::iterator k;
227 for (n = names.begin(), k = keys.begin(); n != names.end(); ++n, ++k) {
228 cerr << "Action: " << (*n) << " bound to " << (*k) << endl;
234 /* start with timecode, metering enabled
237 blink_timeout_tag = -1;
239 /* the global configuration object is now valid */
243 /* this being a GUI and all, we want peakfiles */
245 AudioFileSource::set_build_peakfiles (true);
246 AudioFileSource::set_build_missing_peakfiles (true);
248 if (AudioSource::start_peak_thread ()) {
249 throw failed_constructor();
252 /* set default clock modes */
254 primary_clock.set_mode (AudioClock::SMPTE);
255 secondary_clock.set_mode (AudioClock::BBT);
257 /* start the time-of-day-clock */
259 update_wall_clock ();
260 Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::update_wall_clock), 60000);
262 update_disk_space ();
264 update_sample_rate (engine->frame_rate());
266 starting.connect (mem_fun(*this, &ARDOUR_UI::startup));
267 stopping.connect (mem_fun(*this, &ARDOUR_UI::shutdown));
270 ARDOUR_UI::~ARDOUR_UI ()
272 save_ardour_state ();
286 if (add_route_dialog) {
287 delete add_route_dialog;
290 AudioSource::stop_peak_thread ();
294 ARDOUR_UI::configure_timeout ()
299 if (last_configure_time.tv_sec == 0 && last_configure_time.tv_usec == 0) {
300 /* no configure events yet */
304 gettimeofday (&now, 0);
305 timersub (&now, &last_configure_time, &diff);
307 /* force a gap of 0.5 seconds since the last configure event
310 if (diff.tv_sec == 0 && diff.tv_usec < 500000) {
313 have_configure_timeout = false;
314 save_ardour_state ();
320 ARDOUR_UI::configure_handler (GdkEventConfigure* conf)
322 if (have_configure_timeout) {
323 gettimeofday (&last_configure_time, 0);
325 Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::configure_timeout), 100);
326 have_configure_timeout = true;
333 ARDOUR_UI::save_ardour_state ()
335 if (!keyboard || !mixer || !editor) {
339 /* XXX this is all a bit dubious. add_extra_xml() uses
340 a different lifetime model from add_instant_xml().
343 XMLNode* node = new XMLNode (keyboard->get_state());
344 Config->add_extra_xml (*node);
345 Config->save_state();
347 XMLNode enode(static_cast<Stateful*>(editor)->get_state());
348 XMLNode mnode(mixer->get_state());
351 session->add_instant_xml (enode, session->path());
352 session->add_instant_xml (mnode, session->path());
354 Config->add_instant_xml (enode, get_user_ardour_path());
355 Config->add_instant_xml (mnode, get_user_ardour_path());
362 ARDOUR_UI::startup ()
370 if (session && session->dirty()) {
371 switch (ask_about_saving_session(_("quit"))) {
376 /* use the default name */
377 if (save_state_canfail ("")) {
378 /* failed - don't quit */
379 MessageDialog msg (*editor,
381 Ardour was unable to save your session.\n\n\
382 If you still wish to quit, please use the\n\n\
383 \"Just quit\" option."));
394 session->set_deletion_in_progress ();
397 Config->save_state();
402 ARDOUR_UI::ask_about_saving_session (const string & what)
404 ArdourDialog window (_("ardour: save session?"));
405 Gtk::HBox dhbox; // the hbox for the image and text
406 Gtk::Label prompt_label;
407 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG));
411 msg = string_compose(_("Don't %1"), what);
412 window.add_button (msg, RESPONSE_REJECT);
413 msg = string_compose(_("Just %1"), what);
414 window.add_button (msg, RESPONSE_APPLY);
415 msg = string_compose(_("Save and %1"), what);
416 window.add_button (msg, RESPONSE_ACCEPT);
418 window.set_default_response (RESPONSE_ACCEPT);
420 Gtk::Button noquit_button (msg);
421 noquit_button.set_name ("EditorGTKButton");
426 if (session->snap_name() == session->name()) {
429 type = _("snapshot");
431 prompt = string_compose(_("The %1\"%2\"\nhas not been saved.\n\nAny changes made this time\nwill be lost unless you save it.\n\nWhat do you want to do?"),
432 type, session->snap_name());
434 prompt_label.set_text (prompt);
435 prompt_label.set_name (X_("PrompterLabel"));
436 prompt_label.set_alignment(ALIGN_LEFT, ALIGN_TOP);
438 dimage->set_alignment(ALIGN_CENTER, ALIGN_TOP)
440 dhbox.set_homogeneous (false);
441 dhbox.pack_start (*dimage, false, false, 5);
442 dhbox.pack_start (prompt_label, true, false, 5);
443 window.get_vbox()->pack_start (dhbox);
445 window.set_name (_("Prompter"));
446 window.set_position (Gtk::WIN_POS_MOUSE);
447 window.set_modal (true);
448 window.set_resizable (false);
451 save_the_session = 0;
453 window.set_keep_above (true);
456 ResponseType r = (ResponseType) window.run();
461 case RESPONSE_ACCEPT: // save and get out of here
463 case RESPONSE_APPLY: // get out of here
473 ARDOUR_UI::every_second ()
476 update_buffer_load ();
477 update_disk_space ();
482 ARDOUR_UI::every_point_one_seconds ()
484 update_speed_display ();
485 RapidScreenUpdate(); /* EMIT_SIGNAL */
490 ARDOUR_UI::every_point_zero_one_seconds ()
492 SuperRapidScreenUpdate(); /* EMIT_SIGNAL */
497 ARDOUR_UI::update_sample_rate (nframes_t ignored)
501 ENSURE_GUI_THREAD (bind (mem_fun(*this, &ARDOUR_UI::update_sample_rate), ignored));
503 if (!engine->connected()) {
505 snprintf (buf, sizeof (buf), _("disconnected"));
509 nframes_t rate = engine->frame_rate();
511 if (fmod (rate, 1000.0) != 0.0) {
512 snprintf (buf, sizeof (buf), _("%.1f kHz / %4.1f msecs"),
513 (float) rate/1000.0f,
514 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
516 snprintf (buf, sizeof (buf), _("%u kHz / %4.1f msecs"),
518 (engine->frames_per_cycle() / (float) rate) * 1000.0f);
522 sample_rate_label.set_text (buf);
526 ARDOUR_UI::update_cpu_load ()
529 snprintf (buf, sizeof (buf), _("DSP: %.1f%%"), engine->get_cpu_load());
530 cpu_load_label.set_text (buf);
534 ARDOUR_UI::update_buffer_load ()
539 snprintf (buf, sizeof (buf), _("Buffers p:%" PRIu32 "%% c:%" PRIu32 "%%"),
540 session->playback_load(), session->capture_load());
541 buffer_load_label.set_text (buf);
543 buffer_load_label.set_text ("");
548 ARDOUR_UI::count_recenabled_streams (Route& route)
550 Track* track = dynamic_cast<Track*>(&route);
551 if (track && track->diskstream()->record_enabled()) {
552 rec_enabled_streams += track->n_inputs();
557 ARDOUR_UI::update_disk_space()
563 nframes_t frames = session->available_capture_duration();
566 if (frames == max_frames) {
567 strcpy (buf, _("Disk: 24hrs+"));
572 nframes_t fr = session->frame_rate();
574 rec_enabled_streams = 0;
575 session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams);
577 if (rec_enabled_streams) {
578 frames /= rec_enabled_streams;
581 hrs = frames / (fr * 3600);
582 frames -= hrs * fr * 3600;
583 mins = frames / (fr * 60);
584 frames -= mins * fr * 60;
587 snprintf (buf, sizeof(buf), _("Disk: %02dh:%02dm:%02ds"), hrs, mins, secs);
590 disk_space_label.set_text (buf);
594 ARDOUR_UI::update_wall_clock ()
601 tm_now = localtime (&now);
603 sprintf (buf, "%02d:%02d", tm_now->tm_hour, tm_now->tm_min);
604 wall_clock_label.set_text (buf);
609 ARDOUR_UI::control_methods_adjusted ()
614 which_method = (int) online_control_button->adjustment.get_value();
615 switch (which_method) {
617 allow_mmc_and_local ();
626 fatal << _("programming error: impossible control method") << endmsg;
632 ARDOUR_UI::mmc_device_id_adjusted ()
637 int dev_id = (int) mmc_id_button->adjustment.get_value();
638 mmc->set_device_id (dev_id);
644 ARDOUR_UI::session_menu (GdkEventButton *ev)
646 session_popup_menu->popup (0, 0);
651 ARDOUR_UI::redisplay_recent_sessions ()
653 vector<string *> *sessions;
654 vector<string *>::iterator i;
655 RecentSessionsSorter cmp;
657 recent_session_display.set_model (Glib::RefPtr<TreeModel>(0));
658 recent_session_model->clear ();
661 ARDOUR::read_recent_sessions (rs);
664 recent_session_display.set_model (recent_session_model);
668 /* sort them alphabetically */
669 sort (rs.begin(), rs.end(), cmp);
670 sessions = new vector<string*>;
672 for (RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) {
673 sessions->push_back (new string ((*i).second));
676 for (i = sessions->begin(); i != sessions->end(); ++i) {
678 vector<string*>* states;
679 vector<const gchar*> item;
680 string fullpath = *(*i);
682 /* remove any trailing / */
684 if (fullpath[fullpath.length()-1] == '/') {
685 fullpath = fullpath.substr (0, fullpath.length()-1);
688 /* now get available states for this session */
690 if ((states = Session::possible_states (fullpath)) == 0) {
695 TreeModel::Row row = *(recent_session_model->append());
697 row[recent_session_columns.visible_name] = Glib::path_get_basename (fullpath);
698 row[recent_session_columns.fullpath] = fullpath;
700 if (states->size() > 1) {
702 /* add the children */
704 for (vector<string*>::iterator i2 = states->begin(); i2 != states->end(); ++i2) {
706 TreeModel::Row child_row = *(recent_session_model->append (row.children()));
708 child_row[recent_session_columns.visible_name] = **i2;
709 child_row[recent_session_columns.fullpath] = fullpath;
718 recent_session_display.set_model (recent_session_model);
723 ARDOUR_UI::build_session_selector ()
725 session_selector_window = new ArdourDialog ("session selector");
727 Gtk::ScrolledWindow *scroller = manage (new Gtk::ScrolledWindow);
729 session_selector_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
730 session_selector_window->add_button (Stock::OPEN, RESPONSE_ACCEPT);
731 session_selector_window->set_default_response (RESPONSE_ACCEPT);
732 recent_session_model = TreeStore::create (recent_session_columns);
733 recent_session_display.set_model (recent_session_model);
734 recent_session_display.append_column (_("Recent Sessions"), recent_session_columns.visible_name);
735 recent_session_display.set_headers_visible (false);
736 recent_session_display.get_selection()->set_mode (SELECTION_SINGLE);
738 recent_session_display.signal_row_activated().connect (mem_fun (*this, &ARDOUR_UI::recent_session_row_activated));
740 scroller->add (recent_session_display);
741 scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
743 session_selector_window->set_name ("SessionSelectorWindow");
744 session_selector_window->set_size_request (200, 400);
745 session_selector_window->get_vbox()->pack_start (*scroller);
746 session_selector_window->show_all_children();
750 ARDOUR_UI::recent_session_row_activated (const TreePath& path, TreeViewColumn* col)
752 session_selector_window->response (RESPONSE_ACCEPT);
756 ARDOUR_UI::open_recent_session ()
758 /* popup selector window */
760 if (session_selector_window == 0) {
761 build_session_selector ();
764 redisplay_recent_sessions ();
766 ResponseType r = (ResponseType) session_selector_window->run ();
768 session_selector_window->hide();
771 case RESPONSE_ACCEPT:
777 Gtk::TreeModel::iterator i = recent_session_display.get_selection()->get_selected();
779 if (i == recent_session_model->children().end()) {
783 Glib::ustring path = (*i)[recent_session_columns.fullpath];
784 Glib::ustring state = (*i)[recent_session_columns.visible_name];
786 _session_is_new = false;
788 load_session (path, state);
792 ARDOUR_UI::filter_ardour_session_dirs (const FileFilter::Info& info)
796 if (stat (info.filename.c_str(), &statbuf) != 0) {
800 if (!S_ISDIR(statbuf.st_mode)) {
806 string session_file = info.filename;
808 session_file += Glib::path_get_basename (info.filename);
809 session_file += ".ardour";
811 if (stat (session_file.c_str(), &statbuf) != 0) {
815 return S_ISREG (statbuf.st_mode);
819 ARDOUR_UI::open_session ()
821 /* popup selector window */
823 if (open_session_selector == 0) {
825 /* ardour sessions are folders */
827 open_session_selector = new Gtk::FileChooserDialog (_("open session"), FILE_CHOOSER_ACTION_OPEN);
828 open_session_selector->add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
829 open_session_selector->add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_ACCEPT);
831 FileFilter session_filter;
832 session_filter.add_pattern ("*.ardour");
833 session_filter.set_name (_("Ardour sessions"));
834 open_session_selector->add_filter (session_filter);
835 open_session_selector->set_filter (session_filter);
838 int response = open_session_selector->run();
839 open_session_selector->hide ();
842 case RESPONSE_ACCEPT:
845 open_session_selector->hide();
849 open_session_selector->hide();
850 string session_path = open_session_selector->get_filename();
854 if (session_path.length() > 0) {
855 if (Session::find_session (session_path, path, name, isnew) == 0) {
856 _session_is_new = isnew;
857 load_session (path, name);
864 ARDOUR_UI::session_add_midi_track ()
866 cerr << _("Patience is a virtue.\n");
870 ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many)
872 list<boost::shared_ptr<AudioTrack> > tracks;
873 Session::RouteList routes;
876 warning << _("You cannot add a track or bus without a session already loaded.") << endmsg;
882 tracks = session->new_audio_track (input_channels, output_channels, mode, how_many);
884 if (tracks.size() != how_many) {
886 error << _("could not create a new audio track") << endmsg;
888 error << string_compose (_("could not create %1 new audio tracks"), how_many) << endmsg;
894 routes = session->new_audio_route (input_channels, output_channels, how_many);
896 if (routes.size() != how_many) {
898 error << _("could not create a new audio track") << endmsg;
900 error << string_compose (_("could not create %1 new audio tracks"), how_many) << endmsg;
906 if (need_control_room_outs) {
912 route->set_stereo_control_outs (control_lr_channels);
913 route->control_outs()->set_stereo_pan (pans, this);
915 #endif /* CONTROLOUTS */
919 MessageDialog msg (*editor,
920 _("There are insufficient JACK ports available\n\
921 to create a new track or bus.\n\
922 You should save Ardour, exit and\n\
923 restart JACK with more ports."));
929 ARDOUR_UI::do_transport_locate (nframes_t new_position)
931 nframes_t _preroll = 0;
934 // XXX CONFIG_CHANGE FIX - requires AnyTime handling
935 // _preroll = session->convert_to_frames_at (new_position, Config->get_preroll());
937 if (new_position > _preroll) {
938 new_position -= _preroll;
943 session->request_locate (new_position);
948 ARDOUR_UI::transport_goto_start ()
951 session->goto_start();
954 /* force displayed area in editor to start no matter
955 what "follow playhead" setting is.
959 editor->reposition_x_origin (session->current_start_frame());
965 ARDOUR_UI::transport_goto_zero ()
968 session->request_locate (0);
971 /* force displayed area in editor to start no matter
972 what "follow playhead" setting is.
976 editor->reposition_x_origin (0);
982 ARDOUR_UI::transport_goto_end ()
985 nframes_t frame = session->current_end_frame();
986 session->request_locate (frame);
988 /* force displayed area in editor to start no matter
989 what "follow playhead" setting is.
993 editor->reposition_x_origin (frame);
999 ARDOUR_UI::transport_stop ()
1005 if (session->is_auditioning()) {
1006 session->cancel_audition ();
1010 if (session->get_play_loop ()) {
1011 session->request_play_loop (false);
1014 session->request_stop ();
1018 ARDOUR_UI::transport_stop_and_forget_capture ()
1021 session->request_stop (true);
1026 ARDOUR_UI::remove_last_capture()
1029 editor->remove_last_capture();
1034 ARDOUR_UI::transport_record ()
1037 switch (session->record_status()) {
1038 case Session::Disabled:
1039 if (session->ntracks() == 0) {
1040 MessageDialog msg (*editor, _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu."));
1044 session->maybe_enable_record ();
1046 case Session::Recording:
1047 case Session::Enabled:
1048 session->disable_record (true);
1054 ARDOUR_UI::transport_roll ()
1062 rolling = session->transport_rolling ();
1064 if (session->get_play_loop()) {
1065 session->request_play_loop (false);
1066 auto_loop_button.set_active (false);
1067 roll_button.set_active (true);
1068 } else if (session->get_play_range ()) {
1069 session->request_play_range (false);
1070 play_selection_button.set_active (false);
1071 } else if (rolling) {
1072 session->request_locate (session->last_transport_start(), true);
1075 session->request_transport_speed (1.0f);
1079 ARDOUR_UI::transport_loop()
1082 if (session->get_play_loop()) {
1083 if (session->transport_rolling()) {
1084 Location * looploc = session->locations()->auto_loop_location();
1086 session->request_locate (looploc->start(), true);
1091 session->request_play_loop (true);
1097 ARDOUR_UI::transport_play_selection ()
1103 if (!session->get_play_range()) {
1104 session->request_stop ();
1107 editor->play_selection ();
1111 ARDOUR_UI::transport_rewind (int option)
1113 float current_transport_speed;
1116 current_transport_speed = session->transport_speed();
1118 if (current_transport_speed >= 0.0f) {
1121 session->request_transport_speed (-1.0f);
1124 session->request_transport_speed (-4.0f);
1127 session->request_transport_speed (-0.5f);
1132 session->request_transport_speed (current_transport_speed * 1.5f);
1138 ARDOUR_UI::transport_forward (int option)
1140 float current_transport_speed;
1143 current_transport_speed = session->transport_speed();
1145 if (current_transport_speed <= 0.0f) {
1148 session->request_transport_speed (1.0f);
1151 session->request_transport_speed (4.0f);
1154 session->request_transport_speed (0.5f);
1159 session->request_transport_speed (current_transport_speed * 1.5f);
1165 ARDOUR_UI::toggle_record_enable (uint32_t dstream)
1171 boost::shared_ptr<Route> r;
1173 if ((r = session->route_by_remote_id (dstream)) != 0) {
1177 if ((t = dynamic_cast<Track*>(r.get())) != 0) {
1178 t->diskstream()->set_record_enabled (!t->diskstream()->record_enabled());
1187 ARDOUR_UI::queue_transport_change ()
1189 Gtkmm2ext::UI::instance()->call_slot (mem_fun(*this, &ARDOUR_UI::map_transport_state));
1193 ARDOUR_UI::map_transport_state ()
1195 float sp = session->transport_speed();
1198 transport_rolling ();
1199 } else if (sp < 0.0f) {
1200 transport_rewinding ();
1201 } else if (sp > 0.0f) {
1202 transport_forwarding ();
1204 transport_stopped ();
1209 ARDOUR_UI::allow_local_only ()
1215 ARDOUR_UI::allow_mmc_only ()
1221 ARDOUR_UI::allow_mmc_and_local ()
1227 ARDOUR_UI::GlobalClickBox::printer (char buf[32], Adjustment &adj, void *arg)
1229 snprintf (buf, sizeof(buf), "%s", ((GlobalClickBox *) arg)->strings[
1230 (int) adj.get_value()].c_str());
1234 ARDOUR_UI::engine_stopped ()
1236 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_stopped));
1237 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1238 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1242 ARDOUR_UI::engine_running ()
1244 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_running));
1245 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, true);
1246 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, false);
1250 ARDOUR_UI::engine_halted ()
1252 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::engine_halted));
1254 ActionManager::set_sensitive (ActionManager::jack_sensitive_actions, false);
1255 ActionManager::set_sensitive (ActionManager::jack_opposite_sensitive_actions, true);
1257 update_sample_rate (0);
1259 MessageDialog msg (*editor,
1261 JACK has either been shutdown or it\n\
1262 disconnected Ardour because Ardour\n\
1263 was not fast enough. You can save the\n\
1264 session and/or try to reconnect to JACK ."));
1269 ARDOUR_UI::do_engine_start ()
1277 error << _("Unable to start the session running")
1287 ARDOUR_UI::start_engine ()
1289 if (do_engine_start () == 0) {
1290 if (session && _session_is_new) {
1291 /* we need to retain initial visual
1292 settings for a new session
1294 session->save_state ("");
1302 ARDOUR_UI::update_clocks ()
1304 if (!editor || !editor->dragging_playhead()) {
1305 Clock (session->audible_frame()); /* EMIT_SIGNAL */
1310 ARDOUR_UI::start_clocking ()
1312 clock_signal_connection = RapidScreenUpdate.connect (mem_fun(*this, &ARDOUR_UI::update_clocks));
1316 ARDOUR_UI::stop_clocking ()
1318 clock_signal_connection.disconnect ();
1322 ARDOUR_UI::toggle_clocking ()
1325 if (clock_button.get_active()) {
1334 ARDOUR_UI::_blink (void *arg)
1337 ((ARDOUR_UI *) arg)->blink ();
1344 Blink (blink_on = !blink_on); /* EMIT_SIGNAL */
1348 ARDOUR_UI::start_blinking ()
1350 /* Start the blink signal. Everybody with a blinking widget
1351 uses Blink to drive the widget's state.
1354 if (blink_timeout_tag < 0) {
1356 blink_timeout_tag = g_timeout_add (240, _blink, this);
1361 ARDOUR_UI::stop_blinking ()
1363 if (blink_timeout_tag >= 0) {
1364 g_source_remove (blink_timeout_tag);
1365 blink_timeout_tag = -1;
1370 ARDOUR_UI::name_io_setup (AudioEngine& engine,
1376 if (io.n_inputs() == 0) {
1381 /* XXX we're not handling multiple ports yet. */
1383 const char **connections = io.input(0)->get_connections();
1385 if (connections == 0 || connections[0] == '\0') {
1388 buf = connections[0];
1395 if (io.n_outputs() == 0) {
1400 /* XXX we're not handling multiple ports yet. */
1402 const char **connections = io.output(0)->get_connections();
1404 if (connections == 0 || connections[0] == '\0') {
1407 buf = connections[0];
1415 ARDOUR_UI::snapshot_session ()
1417 ArdourPrompter prompter (true);
1424 now = now.substr (20, 4) + now.substr (3, 16) + " (" + now.substr (0, 3) + ")";
1426 prompter.set_name ("Prompter");
1427 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
1428 prompter.set_prompt (_("Name of New Snapshot"));
1429 prompter.set_initial_text (now);
1431 switch (prompter.run()) {
1432 case RESPONSE_ACCEPT:
1433 prompter.get_result (snapname);
1434 if (snapname.length()){
1435 save_state (snapname);
1445 ARDOUR_UI::save_state (const string & name)
1447 (void) save_state_canfail (name);
1451 ARDOUR_UI::save_state_canfail (string name)
1456 if (name.length() == 0) {
1457 name = session->snap_name();
1460 if ((ret = session->save_state (name)) != 0) {
1464 save_ardour_state (); /* XXX cannot fail? yeah, right ... */
1469 ARDOUR_UI::restore_state (string name)
1472 if (name.length() == 0) {
1473 name = session->name();
1475 session->restore_state (name);
1480 ARDOUR_UI::primary_clock_value_changed ()
1483 session->request_locate (primary_clock.current_time ());
1488 ARDOUR_UI::secondary_clock_value_changed ()
1491 session->request_locate (secondary_clock.current_time ());
1496 ARDOUR_UI::rec_enable_button_blink (bool onoff, AudioDiskstream *dstream, Widget *w)
1498 if (session && dstream && dstream->record_enabled()) {
1500 Session::RecordState rs;
1502 rs = session->record_status ();
1505 case Session::Disabled:
1506 case Session::Enabled:
1507 if (w->get_state() != STATE_SELECTED) {
1508 w->set_state (STATE_SELECTED);
1512 case Session::Recording:
1513 if (w->get_state() != STATE_ACTIVE) {
1514 w->set_state (STATE_ACTIVE);
1520 if (w->get_state() != STATE_NORMAL) {
1521 w->set_state (STATE_NORMAL);
1527 ARDOUR_UI::transport_rec_enable_blink (bool onoff)
1533 switch (session->record_status()) {
1534 case Session::Enabled:
1536 rec_button.set_state (1);
1538 rec_button.set_state (0);
1542 case Session::Recording:
1543 rec_button.set_state (2);
1547 rec_button.set_state (0);
1553 ARDOUR_UI::hide_and_quit (GdkEventAny *ev, ArdourDialog *window)
1561 ARDOUR_UI::start_keyboard_prefix ()
1563 keyboard->start_prefix();
1567 ARDOUR_UI::save_template ()
1570 ArdourPrompter prompter (true);
1573 prompter.set_name (X_("Prompter"));
1574 prompter.set_prompt (_("Name for mix template:"));
1575 prompter.set_initial_text(session->name() + _("-template"));
1576 prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
1578 switch (prompter.run()) {
1579 case RESPONSE_ACCEPT:
1580 prompter.get_result (name);
1582 if (name.length()) {
1583 session->save_template (name);
1593 ARDOUR_UI::new_session (std::string predetermined_path)
1595 string session_name;
1596 string session_path;
1598 int response = Gtk::RESPONSE_NONE;
1600 new_session_dialog->set_modal(true);
1601 new_session_dialog->set_name (predetermined_path);
1602 new_session_dialog->reset_recent();
1603 new_session_dialog->show();
1606 response = new_session_dialog->run ();
1608 _session_is_new = false;
1610 if (response == Gtk::RESPONSE_CANCEL || response == Gtk::RESPONSE_DELETE_EVENT) {
1615 new_session_dialog->hide ();
1618 } else if (response == Gtk::RESPONSE_NONE) {
1620 /* Clear was pressed */
1621 new_session_dialog->reset();
1623 } else if (response == Gtk::RESPONSE_YES) {
1625 /* YES == OPEN, but there's no enum for that */
1627 session_name = new_session_dialog->session_name();
1629 if (session_name.empty()) {
1630 response = Gtk::RESPONSE_NONE;
1634 if (session_name[0] == '/' ||
1635 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1636 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1637 load_session (Glib::path_get_dirname (session_name), session_name);
1639 session_path = new_session_dialog->session_folder();
1640 load_session (session_path, session_name);
1643 } else if (response == Gtk::RESPONSE_OK) {
1645 session_name = new_session_dialog->session_name();
1647 if (new_session_dialog->get_current_page() == 1) {
1649 /* XXX this is a bit of a hack..
1650 i really want the new sesion dialog to return RESPONSE_YES
1651 if we're on page 1 (the load page)
1652 Unfortunately i can't see how atm..
1655 if (session_name.empty()) {
1656 response = Gtk::RESPONSE_NONE;
1660 if (session_name[0] == '/' ||
1661 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1662 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1663 load_session (Glib::path_get_dirname (session_name), session_name);
1665 session_path = new_session_dialog->session_folder();
1666 load_session (session_path, session_name);
1671 if (session_name.empty()) {
1672 response = Gtk::RESPONSE_NONE;
1676 if (session_name[0] == '/' ||
1677 (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') ||
1678 (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) {
1680 session_path = Glib::path_get_dirname (session_name);
1681 session_name = Glib::path_get_basename (session_name);
1685 session_path = new_session_dialog->session_folder();
1689 //XXX This is needed because session constructor wants a
1690 //non-existant path. hopefully this will be fixed at some point.
1692 session_path = Glib::build_filename (session_path, session_name);
1694 if (g_file_test (session_path.c_str(), GFileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
1696 Glib::ustring str = string_compose (_("This session\n%1\nalready exists. Do you want to open it?"), session_path);
1698 MessageDialog msg (str,
1700 Gtk::MESSAGE_WARNING,
1701 Gtk::BUTTONS_YES_NO,
1705 msg.set_name (X_("CleanupDialog"));
1706 msg.set_wmclass (X_("existing_session"), "Ardour");
1707 msg.set_position (Gtk::WIN_POS_MOUSE);
1709 switch (msg.run()) {
1711 load_session (session_path, session_name);
1715 response = RESPONSE_NONE;
1716 new_session_dialog->reset ();
1721 _session_is_new = true;
1723 std::string template_name = new_session_dialog->session_template_name();
1725 if (new_session_dialog->use_session_template()) {
1727 load_session (session_path, session_name, &template_name);
1733 AutoConnectOption iconnect;
1734 AutoConnectOption oconnect;
1736 if (new_session_dialog->create_control_bus()) {
1737 cchns = (uint32_t) new_session_dialog->control_channel_count();
1742 if (new_session_dialog->create_master_bus()) {
1743 mchns = (uint32_t) new_session_dialog->master_channel_count();
1748 if (new_session_dialog->connect_inputs()) {
1749 iconnect = AutoConnectPhysical;
1751 iconnect = AutoConnectOption (0);
1754 /// @todo some minor tweaks.
1756 if (new_session_dialog->connect_outs_to_master()) {
1757 oconnect = AutoConnectMaster;
1758 } else if (new_session_dialog->connect_outs_to_physical()) {
1759 oconnect = AutoConnectPhysical;
1761 oconnect = AutoConnectOption (0);
1764 uint32_t nphysin = (uint32_t) new_session_dialog->input_limit_count();
1765 uint32_t nphysout = (uint32_t) new_session_dialog->output_limit_count();
1767 build_session (session_path,
1775 engine->frame_rate() * 60 * 5);
1780 } while (response == Gtk::RESPONSE_NONE);
1784 new_session_dialog->get_window()->set_cursor();
1785 new_session_dialog->hide();
1789 ARDOUR_UI::close_session()
1796 ARDOUR_UI::load_session (const string & path, const string & snap_name, string* mix_template)
1798 Session *new_session;
1800 session_loaded = false;
1802 x = unload_session ();
1810 /* if it already exists, we must have write access */
1812 if (::access (path.c_str(), F_OK) == 0 && ::access (path.c_str(), W_OK)) {
1813 MessageDialog msg (*editor, _("You do not have write access to this session.\n"
1814 "This prevents the session from being loaded."));
1820 new_session = new Session (*engine, path, snap_name, mix_template);
1825 error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
1829 connect_to_session (new_session);
1831 Config->set_current_owner (ConfigVariableBase::Interface);
1833 session_loaded = true;
1835 goto_editor_window ();
1838 session->set_clean ();
1845 ARDOUR_UI::build_session (const string & path, const string & snap_name,
1846 uint32_t control_channels,
1847 uint32_t master_channels,
1848 AutoConnectOption input_connect,
1849 AutoConnectOption output_connect,
1852 nframes_t initial_length)
1854 Session *new_session;
1857 session_loaded = false;
1858 x = unload_session ();
1865 _session_is_new = true;
1868 new_session = new Session (*engine, path, snap_name, input_connect, output_connect,
1869 control_channels, master_channels, nphysin, nphysout, initial_length);
1874 error << string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name) << endmsg;
1878 connect_to_session (new_session);
1880 session_loaded = true;
1888 editor->show_window ();
1899 ARDOUR_UI::show_splash ()
1902 about = new About();
1903 about->signal_response().connect(mem_fun (*this, &ARDOUR_UI::about_signal_response) );
1910 ARDOUR_UI::about_signal_response(int response)
1916 ARDOUR_UI::hide_splash ()
1919 about->get_window()->set_cursor ();
1925 ARDOUR_UI::display_cleanup_results (Session::cleanup_report& rep, const gchar* list_title, const string & msg)
1929 removed = rep.paths.size();
1932 MessageDialog msgd (*editor,
1933 _("No audio files were ready for cleanup"),
1936 (Gtk::ButtonsType)(Gtk::BUTTONS_OK) );
1937 msgd.set_secondary_text (_("If this seems suprising, \n\
1938 check for any existing snapshots.\n\
1939 These may still include regions that\n\
1940 require some unused files to continue to exist."));
1946 ArdourDialog results (_("ardour: cleanup"), true, false);
1948 struct CleanupResultsModelColumns : public Gtk::TreeModel::ColumnRecord {
1949 CleanupResultsModelColumns() {
1953 Gtk::TreeModelColumn<Glib::ustring> visible_name;
1954 Gtk::TreeModelColumn<Glib::ustring> fullpath;
1958 CleanupResultsModelColumns results_columns;
1959 Glib::RefPtr<Gtk::ListStore> results_model;
1960 Gtk::TreeView results_display;
1962 results_model = ListStore::create (results_columns);
1963 results_display.set_model (results_model);
1964 results_display.append_column (list_title, results_columns.visible_name);
1966 results_display.set_name ("CleanupResultsList");
1967 results_display.set_headers_visible (true);
1968 results_display.set_headers_clickable (false);
1969 results_display.set_reorderable (false);
1971 Gtk::ScrolledWindow list_scroller;
1974 Gtk::HBox dhbox; // the hbox for the image and text
1975 Gtk::HBox ddhbox; // the hbox we eventually pack into the dialog's vbox
1976 Gtk::Image* dimage = manage (new Gtk::Image(Stock::DIALOG_INFO, Gtk::ICON_SIZE_DIALOG));
1978 dimage->set_alignment(ALIGN_LEFT, ALIGN_TOP);
1980 if (rep.space < 1048576.0f) {
1982 txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
1984 txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1024.0f, "kilo"));
1988 txt.set_text (string_compose (msg, removed, _("files were"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
1990 txt.set_text (string_compose (msg, removed, _("file was"), session->path() + "dead_sounds", (float) rep.space / 1048576.0f, "mega"));
1994 dhbox.pack_start (*dimage, true, false, 5);
1995 dhbox.pack_start (txt, true, false, 5);
1997 for (vector<string>::iterator i = rep.paths.begin(); i != rep.paths.end(); ++i) {
1998 TreeModel::Row row = *(results_model->append());
1999 row[results_columns.visible_name] = *i;
2000 row[results_columns.fullpath] = *i;
2003 list_scroller.add (results_display);
2004 list_scroller.set_size_request (-1, 150);
2005 list_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
2007 dvbox.pack_start (dhbox, true, false, 5);
2008 dvbox.pack_start (list_scroller, true, false, 5);
2009 ddhbox.pack_start (dvbox, true, false, 5);
2011 results.get_vbox()->pack_start (ddhbox, true, false, 5);
2012 results.add_button (Stock::CLOSE, RESPONSE_CLOSE);
2013 results.set_default_response (RESPONSE_CLOSE);
2014 results.set_position (Gtk::WIN_POS_MOUSE);
2015 results.show_all_children ();
2016 results.set_resizable (false);
2023 ARDOUR_UI::cleanup ()
2026 /* shouldn't happen: menu item is insensitive */
2031 MessageDialog checker (_("Are you sure you want to cleanup?"),
2033 Gtk::MESSAGE_QUESTION,
2034 (Gtk::ButtonsType)(Gtk::BUTTONS_NONE));
2036 checker.set_secondary_text(_("Cleanup is a destructive operation.\n\
2037 ALL undo/redo information will be lost if you cleanup.\n\
2038 After cleanup, unused audio files will be moved to a \
2039 \"dead sounds\" location."));
2041 checker.add_button (Stock::CANCEL, RESPONSE_CANCEL);
2042 checker.add_button (_("Clean Up"), RESPONSE_ACCEPT);
2043 checker.set_default_response (RESPONSE_CANCEL);
2045 checker.set_name (_("CleanupDialog"));
2046 checker.set_wmclass (X_("ardour_cleanup"), "Ardour");
2047 checker.set_position (Gtk::WIN_POS_MOUSE);
2049 switch (checker.run()) {
2050 case RESPONSE_ACCEPT:
2056 Session::cleanup_report rep;
2058 editor->prepare_for_cleanup ();
2060 if (session->cleanup_sources (rep)) {
2064 display_cleanup_results (rep,
2067 The following %1 %2 not in use and \n\
2068 have been moved to:\n\
2070 Flushing the wastebasket will \n\
2071 release an additional\n\
2072 %4 %5bytes of disk space.\n"
2077 ARDOUR_UI::flush_trash ()
2080 /* shouldn't happen: menu item is insensitive */
2084 Session::cleanup_report rep;
2086 if (session->cleanup_trash_sources (rep)) {
2090 display_cleanup_results (rep,
2092 _("The following %1 %2 deleted from\n\
2094 releasing %4 %5bytes of disk space"));
2098 ARDOUR_UI::add_route ()
2106 if (add_route_dialog == 0) {
2107 add_route_dialog = new AddRouteDialog;
2108 editor->ensure_float (*add_route_dialog);
2111 if (add_route_dialog->is_visible()) {
2112 /* we're already doing this */
2116 ResponseType r = (ResponseType) add_route_dialog->run ();
2118 add_route_dialog->hide();
2121 case RESPONSE_ACCEPT:
2128 if ((count = add_route_dialog->count()) <= 0) {
2132 uint32_t input_chan = add_route_dialog->channels ();
2133 uint32_t output_chan;
2134 string name_template = add_route_dialog->name_template ();
2135 bool track = add_route_dialog->track ();
2137 AutoConnectOption oac = Config->get_output_auto_connect();
2139 if (oac & AutoConnectMaster) {
2140 output_chan = (session->master_out() ? session->master_out()->n_inputs() : input_chan);
2142 output_chan = input_chan;
2145 /* XXX do something with name template */
2148 session_add_audio_track (input_chan, output_chan, add_route_dialog->mode(), count);
2150 session_add_audio_bus (input_chan, output_chan, count);
2155 ARDOUR_UI::mixer_settings () const
2160 node = session->instant_xml(X_("Mixer"), session->path());
2162 node = Config->instant_xml(X_("Mixer"), get_user_ardour_path());
2166 node = new XMLNode (X_("Mixer"));
2173 ARDOUR_UI::editor_settings () const
2178 node = session->instant_xml(X_("Editor"), session->path());
2180 node = Config->instant_xml(X_("Editor"), get_user_ardour_path());
2184 node = new XMLNode (X_("Editor"));
2190 ARDOUR_UI::keyboard_settings () const
2194 node = Config->extra_xml(X_("Keyboard"));
2197 node = new XMLNode (X_("Keyboard"));
2203 ARDOUR_UI::halt_on_xrun_message ()
2205 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::halt_on_xrun_message));
2207 MessageDialog msg (*editor,
2208 _("Recording was stopped because your system could not keep up."));
2213 ARDOUR_UI::disk_overrun_handler ()
2215 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
2217 if (!have_disk_overrun_displayed) {
2218 have_disk_overrun_displayed = true;
2219 MessageDialog msg (*editor, X_("diskrate dialog"), _("\
2220 The disk system on your computer\n\
2221 was not able to keep up with Ardour.\n\
2223 Specifically, it failed to write data to disk\n\
2224 quickly enough to keep up with recording.\n"));
2226 have_disk_overrun_displayed = false;
2231 ARDOUR_UI::disk_underrun_handler ()
2233 ENSURE_GUI_THREAD (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler));
2235 if (!have_disk_underrun_displayed) {
2236 have_disk_underrun_displayed = true;
2237 MessageDialog msg (*editor,
2238 (_("The disk system on your computer\n\
2239 was not able to keep up with Ardour.\n\
2241 Specifically, it failed to read data from disk\n\
2242 quickly enough to keep up with playback.\n")));
2244 have_disk_underrun_displayed = false;
2249 ARDOUR_UI::disk_underrun_message_gone ()
2251 have_disk_underrun_displayed = false;
2255 ARDOUR_UI::disk_overrun_message_gone ()
2257 have_disk_underrun_displayed = false;
2261 ARDOUR_UI::pending_state_dialog ()
2263 ArdourDialog dialog ("pending state dialog");
2265 This session appears to have been in\n\
2266 middle of recording when ardour or\n\
2267 the computer was shutdown.\n\
2269 Ardour can recover any captured audio for\n\
2270 you, or it can ignore it. Please decide\n\
2271 what you would like to do.\n"));
2273 dialog.get_vbox()->pack_start (message);
2274 dialog.add_button (_("Recover from crash"), RESPONSE_ACCEPT);
2275 dialog.add_button (_("Ignore crash data"), RESPONSE_REJECT);
2277 dialog.set_position (WIN_POS_CENTER);
2280 switch (dialog.run ()) {
2281 case RESPONSE_ACCEPT:
2289 ARDOUR_UI::disconnect_from_jack ()
2292 if( engine->disconnect_from_jack ()) {
2293 MessageDialog msg (*editor, _("Could not disconnect from JACK"));
2297 update_sample_rate (0);
2302 ARDOUR_UI::reconnect_to_jack ()
2305 if (engine->reconnect_to_jack ()) {
2306 MessageDialog msg (*editor, _("Could not reconnect to JACK"));
2310 update_sample_rate (0);
2315 ARDOUR_UI::set_jack_buffer_size (nframes_t nframes)
2317 engine->request_buffer_size (nframes);
2318 update_sample_rate (0);
2322 ARDOUR_UI::cmdline_new_session (string path)
2324 if (path[0] != '/') {
2325 char buf[PATH_MAX+1];
2328 getcwd (buf, sizeof (buf));
2337 _will_create_new_session_automatically = false; /* done it */
2338 return FALSE; /* don't call it again */
2342 ARDOUR_UI::use_config ()
2344 Glib::RefPtr<Action> act;
2346 switch (Config->get_native_file_data_format ()) {
2348 act = ActionManager::get_action (X_("options"), X_("FileDataFormatFloat"));
2351 act = ActionManager::get_action (X_("options"), X_("FileDataFormat24bit"));
2356 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
2357 ract->set_active ();
2360 switch (Config->get_native_file_header_format ()) {
2362 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatBWF"));
2365 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE"));
2368 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatWAVE64"));
2371 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatiXML"));
2374 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatRF64"));
2377 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatCAF"));
2380 act = ActionManager::get_action (X_("options"), X_("FileHeaderFormatAIFF"));
2385 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
2386 ract->set_active ();
2391 ARDOUR_UI::update_transport_clocks (nframes_t pos)
2393 primary_clock.set (pos);
2394 secondary_clock.set (pos);
2396 if (big_clock_window) {
2397 big_clock.set (pos);
2402 ARDOUR_UI::record_state_changed ()
2404 ENSURE_GUI_THREAD (mem_fun (*this, &ARDOUR_UI::record_state_changed));
2406 if (!session || !big_clock_window) {
2407 /* why bother - the clock isn't visible */
2411 switch (session->record_status()) {
2412 case Session::Recording:
2413 big_clock.set_widget_name ("BigClockRecording");
2416 big_clock.set_widget_name ("BigClockNonRecording");
2422 ARDOUR_UI::set_keybindings_path (string path)
2424 keybindings_path = path;
2428 ARDOUR_UI::save_keybindings ()
2430 if (can_save_keybindings) {
2431 AccelMap::save (keybindings_path);
2436 ARDOUR_UI::first_idle ()
2438 can_save_keybindings = true;
2443 ARDOUR_UI::store_clock_modes ()
2445 XMLNode* node = new XMLNode(X_("ClockModes"));
2447 for (vector<AudioClock*>::iterator x = AudioClock::clocks.begin(); x != AudioClock::clocks.end(); ++x) {
2448 node->add_property ((*x)->name().c_str(), enum_2_string ((*x)->mode()));
2451 session->add_extra_xml (*node);
2452 session->set_dirty ();