diff --git a/libs/ardour/mixer_snapshot_manager.cc b/libs/ardour/mixer_snapshot_manager.cc index 8ca3c6e7ea..764c710154 100644 --- a/libs/ardour/mixer_snapshot_manager.cc +++ b/libs/ardour/mixer_snapshot_manager.cc @@ -22,12 +22,15 @@ #include #include "ardour/directory_names.h" +#include "ardour/filename_extensions.h" #include "ardour/mixer_snapshot_manager.h" #include "ardour/mixer_snapshot.h" +#include "ardour/search_paths.h" #include "ardour/session_directory.h" #include "ardour/template_utils.h" #include "pbd/basename.h" +#include "pbd/file_utils.h" using namespace ARDOUR; using namespace std; @@ -51,18 +54,43 @@ void MixerSnapshotManager::refresh() vector global_templates; find_route_templates(global_templates); - for(vector::const_iterator it = global_templates.begin(); it != global_templates.end(); it++) { - TemplateInfo info = (*it); + if(!global_templates.empty()) { + for(vector::const_iterator it = global_templates.begin(); it != global_templates.end(); it++) { + TemplateInfo info = (*it); - MixerSnapshot* snap = new MixerSnapshot(_session, info.path); - snap->set_label(info.name); - _global_snapshots.insert(snap); - - printf("Snapshot name: %s\n", snap->get_label().c_str()); - printf("Path: %s\n", info.path.c_str()); + MixerSnapshot* snap = new MixerSnapshot(_session, info.path); + snap->set_label(info.name); + _global_snapshots.insert(snap); + + printf("Global - name: %s\n", snap->get_label().c_str()); + printf("Global - path: %s\n", info.path.c_str()); + } } - //TODO: the local part of this discovery + + //this should be in search_paths and then integrated into template_utils + //but having it be based on the session presents... complications + PBD::Searchpath spath (_session->session_directory().root_path()); + spath.add_subdirectory_to_paths(route_templates_dir_name); + + vector local_templates; + string pattern = "*" + string(template_suffix); + find_files_matching_pattern(local_templates, spath, pattern); + + printf("Searching for templates with pattern %s in searchpath %s\n", pattern.c_str(), spath.to_string().c_str()); + if(!local_templates.empty()) { + for(vector::const_iterator it = local_templates.begin(); it != local_templates.end(); it++) { + const string path = (*it); + const string label = PBD::basename_nosuffix(path); + + MixerSnapshot* snap = new MixerSnapshot(_session, path); + snap->set_label(label); + _local_snapshots.insert(snap); + + printf("Local - name: %s\n", snap->get_label().c_str()); + printf("Local - path: %s\n", path.c_str()); + } + } } void MixerSnapshotManager::create_snapshot(std::string const& label, RouteList& rl, bool global)