From 05a93ce6fd8aec639aca6205872b58c5e208d897 Mon Sep 17 00:00:00 2001 From: Nikolaus Gullotta Date: Fri, 23 Aug 2019 14:22:26 -0500 Subject: [PATCH] add description handling to MixerSnapshots and save_as_template --- gtk2_ardour/mixer_snapshots.cc | 4 ++-- gtk2_ardour/save_template_dialog.cc | 1 - libs/ardour/ardour/mixer_snapshot.h | 7 ++++++- libs/ardour/ardour/mixer_snapshot_manager.h | 4 ++-- libs/ardour/mixer_snapshot.cc | 8 ++++++++ libs/ardour/mixer_snapshot_manager.cc | 6 ++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/mixer_snapshots.cc b/gtk2_ardour/mixer_snapshots.cc index cba9f79847..0a5b9623f5 100644 --- a/gtk2_ardour/mixer_snapshots.cc +++ b/gtk2_ardour/mixer_snapshots.cc @@ -213,7 +213,7 @@ void MixerSnapshotList::new_snapshot() { //actually create the snapshot RouteList rl = PublicEditor::instance().get_selection().tracks.routelist(); - _session->snapshot_manager().create_snapshot(name, rl, _global); + _session->snapshot_manager().create_snapshot(name, string(), rl, _global); redisplay(); } } @@ -241,7 +241,7 @@ void MixerSnapshotList::choose_external_dialog_response(int response) } } - _session->snapshot_manager().create_snapshot(name, external, _global); + _session->snapshot_manager().create_snapshot(name, string(), external, _global); redisplay(); } diff --git a/gtk2_ardour/save_template_dialog.cc b/gtk2_ardour/save_template_dialog.cc index 2cfdf5154e..d4e5930a9d 100644 --- a/gtk2_ardour/save_template_dialog.cc +++ b/gtk2_ardour/save_template_dialog.cc @@ -34,7 +34,6 @@ using namespace ARDOUR; SaveTemplateDialog::SaveTemplateDialog (const std::string& name, const std::string& desc, bool local) : ArdourDialog (_("Save as template")) { -printf("saving %s\n", local ? "LOCAL" : "PREFS"); _local = local; _name_entry.get_buffer()->set_text (name); diff --git a/libs/ardour/ardour/mixer_snapshot.h b/libs/ardour/ardour/mixer_snapshot.h index 18fd91098b..fd4b7316f9 100644 --- a/libs/ardour/ardour/mixer_snapshot.h +++ b/libs/ardour/ardour/mixer_snapshot.h @@ -106,6 +106,9 @@ class LIBARDOUR_API MixerSnapshot std::string get_label() {return label;}; void set_label(const std::string& new_label) {label = new_label; LabelChanged(this);}; + std::string get_description() {return _description;} + void set_description(const std::string& new_desc) {_description = new_desc; DescriptionChanged();}; + std::string get_path() {return _path;}; void set_path(const std::string& new_path) {_path = new_path; PathChanged(this);}; @@ -122,6 +125,7 @@ class LIBARDOUR_API MixerSnapshot //signals PBD::Signal1 LabelChanged; + PBD::Signal0 DescriptionChanged; PBD::Signal1 PathChanged; private: ARDOUR::Session* _session; @@ -136,7 +140,8 @@ class LIBARDOUR_API MixerSnapshot unsigned int id; bool favorite; - std::string label; + std::string label; + std::string _description; std::time_t timestamp; std::string last_modified_with; std::string suffix; diff --git a/libs/ardour/ardour/mixer_snapshot_manager.h b/libs/ardour/ardour/mixer_snapshot_manager.h index fff31da4bc..74ffc456b7 100644 --- a/libs/ardour/ardour/mixer_snapshot_manager.h +++ b/libs/ardour/ardour/mixer_snapshot_manager.h @@ -39,8 +39,8 @@ public: MixerSnapshotManager (ARDOUR::Session*); ~MixerSnapshotManager() {} - void create_snapshot(const std::string& label, RouteList& rl, bool global); - void create_snapshot(const std::string& label, const std::string& from_path, bool global); + void create_snapshot(const std::string& label, const std::string& desc, RouteList& rl, bool global); + void create_snapshot(const std::string& label, const std::string& desc, const std::string& from_path, bool global); bool rename_snapshot(MixerSnapshot*, const std::string&); bool remove_snapshot(MixerSnapshot*); diff --git a/libs/ardour/mixer_snapshot.cc b/libs/ardour/mixer_snapshot.cc index 9e1d071e26..c7b5c3d64f 100644 --- a/libs/ardour/mixer_snapshot.cc +++ b/libs/ardour/mixer_snapshot.cc @@ -451,6 +451,14 @@ void MixerSnapshot::write(const string dir) XMLTree tree; tree.set_root(node); + + if(_description != string()) { + XMLNode* desc = new XMLNode(X_("description")); + XMLNode* dn = new XMLNode(X_("content"), _description); + desc->add_child_copy(*dn); + tree.root()->add_child_copy(*desc); + } + tree.write(path.c_str()); } diff --git a/libs/ardour/mixer_snapshot_manager.cc b/libs/ardour/mixer_snapshot_manager.cc index aab9719650..61a9e35c2c 100644 --- a/libs/ardour/mixer_snapshot_manager.cc +++ b/libs/ardour/mixer_snapshot_manager.cc @@ -197,12 +197,14 @@ MixerSnapshot* MixerSnapshotManager::get_snapshot_by_name(const string& name, bo } } -void MixerSnapshotManager::create_snapshot(const string& label, RouteList& rl, bool global) +void MixerSnapshotManager::create_snapshot(const string& label, const string& desc, RouteList& rl, bool global) { ensure_snapshot_dir(global); const string path = global ? _global_path : _local_path; MixerSnapshot* snapshot = new MixerSnapshot(_session); + snapshot->set_description(desc); + if(!rl.empty()) { //just this routelist snapshot->snap(rl); @@ -236,7 +238,7 @@ void MixerSnapshotManager::create_snapshot(const string& label, RouteList& rl, b snapshots_list.insert(snapshot); } -void MixerSnapshotManager::create_snapshot(const string& label, const string& from_path, bool global) +void MixerSnapshotManager::create_snapshot(const string& label, const string& desc, const string& from_path, bool global) { ensure_snapshot_dir(global); const string path = global ? _global_path : _local_path;