From e1b319a13837e80ac9193f4a02f67fcfc7655f15 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 9 Oct 2019 20:52:46 -0600 Subject: [PATCH] move copying demo sessions into NewUserWizard --- gtk2_ardour/new_user_wizard.cc | 40 +++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/new_user_wizard.cc b/gtk2_ardour/new_user_wizard.cc index 0481f0c63e..cfcb1bd591 100644 --- a/gtk2_ardour/new_user_wizard.cc +++ b/gtk2_ardour/new_user_wizard.cc @@ -35,6 +35,7 @@ #include +#include "pbd/basename.h" #include "pbd/failed_constructor.h" #include "pbd/scoped_file_descriptor.h" #include "pbd/file_utils.h" @@ -439,7 +440,8 @@ NewUserWizard::setup_final_page () } void -NewUserWizard::discover_plugins () { +NewUserWizard::discover_plugins () +{ plugin_disco_button.set_sensitive (false); PluginManager::instance().refresh(); } @@ -494,6 +496,42 @@ NewUserWizard::on_apply () } + 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, ARDOUR::session_archive_suffix); + + 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." */ + 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 (...) {} + } + } + _signal_response (int (RESPONSE_OK)); }