summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ardour_ui.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-09-13 19:31:38 +0200
committerRobin Gareus <robin@gareus.org>2016-09-13 19:31:38 +0200
commit8e995be5cfd4c0469c1c8297c7abb3a071e0adb0 (patch)
tree5cd12124b184ae394cc023802265af70af500f8d /gtk2_ardour/ardour_ui.cc
parentf57e2f2fbe9f74b70d0dbea3c0812ba87ce5e27e (diff)
copy demo sessions
Diffstat (limited to 'gtk2_ardour/ardour_ui.cc')
-rw-r--r--gtk2_ardour/ardour_ui.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index ee7d40ffab..6c349260f7 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"
@@ -1069,6 +1070,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<string> demos;
+ find_files_matching_pattern (demos, ds, "*.tar.xz");
+
+ ARDOUR::RecentSessions rs;
+ ARDOUR::read_recent_sessions (rs);
+
+ for (vector<string>::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 <session-default-dir> 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;