mixer_snapshot_manager now collects local templates as well with sort-of hacky work around

This commit is contained in:
Nikolaus Gullotta 2019-07-29 12:26:18 -05:00 committed by Nikolaus Gullotta
parent cbb468df39
commit a432539122
No known key found for this signature in database
GPG key ID: 565F60578092AA31

View file

@ -22,12 +22,15 @@
#include <glibmm.h>
#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<TemplateInfo> global_templates;
find_route_templates(global_templates);
for(vector<TemplateInfo>::const_iterator it = global_templates.begin(); it != global_templates.end(); it++) {
TemplateInfo info = (*it);
if(!global_templates.empty()) {
for(vector<TemplateInfo>::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<string> 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<string>::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)