X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui.cc;h=4fdbe2209e930c3dc91f95b84dff102c65387ca7;hb=deb2033a346d5a4638b9ee4e8eba66cd1b9a54e4;hp=9ed6d0e599c79d685678e9803cd675efa0b91597;hpb=c86210a9d5bdb7b36ad58552a1f99f53d48781b3;p=ardour.git diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 9ed6d0e599..4fdbe2209e 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -91,6 +91,7 @@ typedef uint64_t microseconds_t; #include "gui_thread.h" #include "theme_manager.h" #include "bundle_manager.h" +#include "session_metadata_dialog.h" #include "gain_meter.h" #include "route_time_axis.h" @@ -160,7 +161,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) auditioning_alert_button (_("AUDITION")), solo_alert_button (_("SOLO")), - midi_panic_button (_("Panic")), shown_flag (false), error_log_button (_("Errors")) @@ -193,11 +193,11 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) mixer = 0; session = 0; editor = 0; + engine = 0; _session_is_new = false; big_clock_window = 0; session_selector_window = 0; last_key_press_time = 0; - connection_editor = 0; _will_create_new_session_automatically = false; new_session_dialog = 0; add_route_dialog = 0; @@ -210,6 +210,15 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) session_loaded = false; last_speed_displayed = -1.0f; ignore_dual_punch = false; + _mixer_on_top = false; + + roll_button.unset_flags (Gtk::CAN_FOCUS); + stop_button.unset_flags (Gtk::CAN_FOCUS); + goto_start_button.unset_flags (Gtk::CAN_FOCUS); + goto_end_button.unset_flags (Gtk::CAN_FOCUS); + auto_loop_button.unset_flags (Gtk::CAN_FOCUS); + play_selection_button.unset_flags (Gtk::CAN_FOCUS); + rec_button.unset_flags (Gtk::CAN_FOCUS); last_configure_time= 0; @@ -223,7 +232,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) // We do not have jack linked in yet so; last_shuttle_request = last_peak_grab = 0; // get_microseconds(); - + ARDOUR::Diskstream::DiskOverrun.connect (mem_fun(*this, &ARDOUR_UI::disk_overrun_handler)); ARDOUR::Diskstream::DiskUnderrun.connect (mem_fun(*this, &ARDOUR_UI::disk_underrun_handler)); @@ -303,8 +312,6 @@ ARDOUR_UI::create_engine () void ARDOUR_UI::post_engine () { - extern int setup_midi (); - /* Things to be done once we create the AudioEngine */ @@ -353,11 +360,12 @@ ARDOUR_UI::post_engine () /* set default clock modes */ if (Profile->get_sae()) { - primary_clock.set_mode (AudioClock::MinSec); + primary_clock.set_mode (AudioClock::BBT); + secondary_clock.set_mode (AudioClock::MinSec); } else { primary_clock.set_mode (AudioClock::SMPTE); + secondary_clock.set_mode (AudioClock::BBT); } - secondary_clock.set_mode (AudioClock::BBT); /* start the time-of-day-clock */ @@ -387,26 +395,11 @@ ARDOUR_UI::~ARDOUR_UI () { save_ardour_state (); - if (keyboard) { - delete keyboard; - } - - if (editor) { - delete editor; - } - - if (mixer) { - delete mixer; - } - - if (add_route_dialog) { - delete add_route_dialog; - } - - - if (new_session_dialog) { - delete new_session_dialog; - } + delete keyboard; + delete editor; + delete mixer; + delete add_route_dialog; + delete new_session_dialog; } void @@ -462,16 +455,16 @@ ARDOUR_UI::set_transport_controllable_state (const XMLNode& node) if ((prop = node.property ("stop")) != 0) { stop_controllable->set_id (prop->value()); } - if ((prop = node.property ("goto_start")) != 0) { + if ((prop = node.property ("goto-start")) != 0) { goto_start_controllable->set_id (prop->value()); } - if ((prop = node.property ("goto_end")) != 0) { + if ((prop = node.property ("goto-end")) != 0) { goto_end_controllable->set_id (prop->value()); } - if ((prop = node.property ("auto_loop")) != 0) { + if ((prop = node.property ("auto-loop")) != 0) { auto_loop_controllable->set_id (prop->value()); } - if ((prop = node.property ("play_selection")) != 0) { + if ((prop = node.property ("play-selection")) != 0) { play_selection_controllable->set_id (prop->value()); } if ((prop = node.property ("rec")) != 0) { @@ -522,6 +515,9 @@ ARDOUR_UI::save_ardour_state () XMLNode* node = new XMLNode (keyboard->get_state()); Config->add_extra_xml (*node); Config->add_extra_xml (get_transport_controllable_state()); + if (new_session_dialog && new_session_dialog->engine_control.was_used()) { + Config->add_extra_xml (new_session_dialog->engine_control.get_state()); + } Config->save_state(); ui_config->save_state (); @@ -638,7 +634,7 @@ void ARDOUR_UI::startup () { string name, path; - + new_session_dialog = new NewSessionDialog(); bool backend_audio_is_running = EngineControl::engine_running(); @@ -760,9 +756,9 @@ If you still wish to quit, please use the\n\n\ session->set_deletion_in_progress (); } + ArdourDialog::close_all_dialogs (); engine->stop (true); - Config->save_state(); - ARDOUR_UI::config()->save_state(); + save_ardour_state (); quit (); } @@ -932,15 +928,11 @@ ARDOUR_UI::update_disk_space() nframes_t frames = session->available_capture_duration(); char buf[64]; - + nframes_t fr = session->frame_rate(); + if (frames == max_frames) { strcpy (buf, _("Disk: 24hrs+")); } else { - int hrs; - int mins; - int secs; - nframes_t fr = session->frame_rate(); - rec_enabled_streams = 0; session->foreach_route (this, &ARDOUR_UI::count_recenabled_streams); @@ -948,16 +940,29 @@ ARDOUR_UI::update_disk_space() frames /= rec_enabled_streams; } + int hrs; + int mins; + int secs; + hrs = frames / (fr * 3600); frames -= hrs * fr * 3600; mins = frames / (fr * 60); frames -= mins * fr * 60; secs = frames / fr; - + snprintf (buf, sizeof(buf), _("Disk: %02dh:%02dm:%02ds"), hrs, mins, secs); } - + disk_space_label.set_text (buf); + + // An attempt to make the disk space label flash red when space has run out. + + if (frames < fr * 60 * 5) { + /* disk_space_box.style ("disk_space_label_empty"); */ + } else { + /* disk_space_box.style ("disk_space_label"); */ + } + } gint @@ -1267,7 +1272,7 @@ void ARDOUR_UI::session_add_audio_route (bool track, int32_t input_channels, int32_t output_channels, ARDOUR::TrackMode mode, uint32_t how_many) { list > tracks; - Session::RouteList routes; + RouteList routes; if (session == 0) { warning << _("You cannot add a track or bus without a session already loaded.") << endmsg; @@ -1726,8 +1731,8 @@ ARDOUR_UI::engine_halted () _("\ JACK has either been shutdown or it\n\ disconnected Ardour because Ardour\n\ -was not fast enough. You can save the\n\ -session and/or try to reconnect to JACK .")); +was not fast enough. Try to restart\n\ +JACK, reconnect and save the session.")); pop_back_splash (); msg.run (); } @@ -1970,14 +1975,6 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff) } } -gint -ARDOUR_UI::hide_and_quit (GdkEventAny *ev, ArdourDialog *window) -{ - window->hide(); - Gtk::Main::quit (); - return TRUE; -} - void ARDOUR_UI::save_template () @@ -2008,6 +2005,24 @@ ARDOUR_UI::save_template () } } +void +ARDOUR_UI::edit_metadata () +{ + SessionMetadataEditor dialog; + dialog.set_session (session); + editor->ensure_float (dialog); + dialog.run (); +} + +void +ARDOUR_UI::import_metadata () +{ + SessionMetadataImporter dialog; + dialog.set_session (session); + editor->ensure_float (dialog); + dialog.run (); +} + void ARDOUR_UI::fontconfig_dialog () { @@ -2214,7 +2229,7 @@ ARDOUR_UI::loading_message (const std::string& msg) splash->message (msg); flush_pending (); } - + void ARDOUR_UI::idle_load (const Glib::ustring& path) { @@ -2227,18 +2242,24 @@ ARDOUR_UI::idle_load (const Glib::ustring& path) load_session (Glib::path_get_dirname (path), basename_nosuffix (path)); } } else { + ARDOUR_COMMAND_LINE::session_name = path; + if (new_session_dialog) { + + /* make it break out of Dialog::run() and start again. */ + new_session_dialog->response (1); } } } +/** @param offer_quit true to offer a Cancel button, otherwise call it Quit */ bool -ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be_new) +ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be_new, bool offer_cancel) { bool existing_session = false; Glib::ustring session_name; @@ -2279,6 +2300,7 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be new_session_dialog->set_current_page (0); new_session_dialog->set_existing_session (existing_session); new_session_dialog->reset_recent(); + new_session_dialog->set_offer_cancel (offer_cancel); do { new_session_dialog->set_have_engine (backend_audio_is_running); @@ -2301,6 +2323,9 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be case Gtk::RESPONSE_CANCEL: case Gtk::RESPONSE_DELETE_EVENT: if (!session) { + if (engine && engine->running()) { + engine->stop (true); + } quit(); } new_session_dialog->hide (); @@ -2353,7 +2378,7 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be if (session_name[0] == '/' || (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') || (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) { - + session_path = Glib::path_get_dirname (session_name); session_name = Glib::path_get_basename (session_name); @@ -2411,7 +2436,7 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be loadit: new_session_dialog->hide (); - + if (load_session (session_path, session_name, template_name)) { /* force a retry */ response = Gtk::RESPONSE_NONE; @@ -2491,10 +2516,10 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na MessageDialog msg (err.what(), true, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK_CANCEL); + Gtk::BUTTONS_CLOSE); - msg.set_title (_("Loading Error")); - msg.set_secondary_text (_("Click the OK button to try again.")); + msg.set_title (_("Port Registration Error")); + msg.set_secondary_text (_("Click the Close button to try again.")); msg.set_position (Gtk::WIN_POS_CENTER); pop_back_splash (); msg.present (); @@ -2517,10 +2542,10 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na MessageDialog msg (string_compose(_("Session \"%1 (snapshot %2)\" did not load successfully"), path, snap_name), true, Gtk::MESSAGE_INFO, - Gtk::BUTTONS_OK_CANCEL); + Gtk::BUTTONS_CLOSE); msg.set_title (_("Loading Error")); - msg.set_secondary_text (_("Click the OK button to try again.")); + msg.set_secondary_text (_("Click the Close button to try again.")); msg.set_position (Gtk::WIN_POS_CENTER); pop_back_splash (); msg.present (); @@ -2602,6 +2627,9 @@ ARDOUR_UI::build_session (const Glib::ustring& path, const Glib::ustring& snap_n connect_to_session (new_session); session_loaded = true; + + new_session->save_state(new_session->name()); + return 0; } @@ -2919,8 +2947,6 @@ ARDOUR_UI::add_route (Gtk::Window* float_window) /* XXX do something with name template */ - cerr << "Adding with " << input_chan << " in and " << output_chan << "out\n"; - if (add_route_dialog->type() == ARDOUR::DataType::MIDI) { if (track) { session_add_midi_track(count); @@ -2967,10 +2993,17 @@ ARDOUR_UI::editor_settings () const } else { node = Config->instant_xml(X_("Editor")); } + + if (!node) { + if (getenv("ARDOUR_INSTANT_XML_PATH")) { + node = Config->instant_xml(getenv("ARDOUR_INSTANT_XML_PATH")); + } + } if (!node) { node = new XMLNode (X_("Editor")); } + return node; } @@ -3004,13 +3037,17 @@ ARDOUR_UI::halt_on_xrun_message () void ARDOUR_UI::xrun_handler(nframes_t where) { + if (!session) { + return; + } + ENSURE_GUI_THREAD (bind(mem_fun(*this, &ARDOUR_UI::xrun_handler), where)); - if (Config->get_create_xrun_marker() && session->actively_recording()) { + if (session && Config->get_create_xrun_marker() && session->actively_recording()) { create_xrun_marker(where); } - if (Config->get_stop_recording_on_xrun() && session->actively_recording()) { + if (session && Config->get_stop_recording_on_xrun() && session->actively_recording()) { halt_on_xrun_message (); } }