X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fardour_ui.cc;h=fcbb5b45028c770d912b6a6e49171f266a45ad85;hb=f66f7ba136c8588e47b3381ab07353e85f4100bf;hp=a53bcf167fade968fed60d2ada97ac636ea0b682;hpb=07bb5ff34735962bcfea9751420ade3af8be5d5c;p=ardour.git diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index a53bcf167f..fcbb5b4502 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -56,6 +56,7 @@ #include "pbd/compose.h" #include "pbd/convert.h" #include "pbd/failed_constructor.h" +#include "pbd/file_archive.h" #include "pbd/enumwriter.h" #include "pbd/memento_command.h" #include "pbd/openuri.h" @@ -162,6 +163,7 @@ typedef uint64_t microseconds_t; #include "route_params_ui.h" #include "save_as_dialog.h" #include "script_selector.h" +#include "session_archive_dialog.h" #include "session_dialog.h" #include "session_metadata_dialog.h" #include "session_option_editor.h" @@ -1069,6 +1071,45 @@ ARDOUR_UI::starting () } } + // TODO: maybe IFF brand_new_user + if (ARDOUR::Profile->get_mixbus () && Config->get_copy_demo_sessions ()) { + std::string dspd (Config->get_default_session_parent_dir()); + Searchpath ds (ARDOUR::ardour_data_search_path()); + ds.add_subdirectory_to_paths ("sessions"); + vector demos; + find_files_matching_pattern (demos, ds, "*.tar.xz"); + + ARDOUR::RecentSessions rs; + ARDOUR::read_recent_sessions (rs); + + for (vector::iterator i = demos.begin(); i != demos.end (); ++i) { + /* "demo-session" must be inside "demo-session.tar.xz" + * strip ".tar.xz" + */ + std::string name = basename_nosuffix (basename_nosuffix (*i)); + std::string path = Glib::build_filename (dspd, name); + /* skip if session-dir already exists */ + if (Glib::file_test(path.c_str(), Glib::FILE_TEST_IS_DIR)) { + continue; + } + /* skip sessions that are already in 'recent'. + * eg. a new user changed shorly after installation + */ + for (ARDOUR::RecentSessions::iterator r = rs.begin(); r != rs.end(); ++r) { + if ((*r).first == name) { + continue; + } + } + try { + PBD::FileArchive ar (*i); + if (0 == ar.inflate (dspd)) { + store_recent_sessions (name, path); + info << string_compose (_("Copied Demo Session %1."), name) << endmsg; + } + } catch (...) {} + } + } + #ifdef NO_PLUGIN_STATE ARDOUR::RecentSessions rs; @@ -1284,7 +1325,9 @@ If you still wish to quit, please use the\n\n\ */ save_ardour_state (); - key_editor->disconnect (); + if (key_editor.get (false)) { + key_editor->disconnect (); + } close_all_dialogs (); @@ -2656,6 +2699,32 @@ ARDOUR_UI::save_session_as () } } +void +ARDOUR_UI::archive_session () +{ + if (!_session) { + return; + } + + time_t n; + time (&n); + Glib::DateTime gdt (Glib::DateTime::create_now_local (n)); + + SessionArchiveDialog sad; + sad.set_name (_session->name() + gdt.format ("_%F_%H%M%S")); + int response = sad.run (); + + if (response != Gtk::RESPONSE_OK) { + sad.hide (); + return; + } + + if (_session->archive_session (sad.target_folder(), sad.name(), sad.encode_option (), sad.only_used_sources (), &sad)) { + MessageDialog msg (_("Session Archiving failed.")); + msg.run (); + } +} + void ARDOUR_UI::quick_snapshot_session (bool switch_to_it) { @@ -4982,16 +5051,21 @@ ARDOUR_UI::record_state_changed () { ENSURE_GUI_THREAD (*this, &ARDOUR_UI::record_state_changed); - if (!_session || !big_clock_window) { + if (!_session) { /* why bother - the clock isn't visible */ return; } - if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) { - big_clock->set_active (true); - } else { - big_clock->set_active (false); + ActionManager::set_sensitive (ActionManager::rec_sensitive_actions, !_session->actively_recording()); + + if (big_clock_window) { + if (_session->record_status () == Session::Recording && _session->have_rec_enabled_track ()) { + big_clock->set_active (true); + } else { + big_clock->set_active (false); + } } + } bool