summaryrefslogtreecommitdiff
path: root/gtk2_ardour/template_dialog.cc
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2020-04-05 15:41:37 +0200
committerJohannes Mueller <github@johannes-mueller.org>2020-04-05 16:34:48 +0200
commit605b3d83a8c48c4ffb132ca74c69d9bdc95d1890 (patch)
tree573de9bf2f8b4712cb1327db8c740a65c5f65f44 /gtk2_ardour/template_dialog.cc
parentc74cc2675e099e494ce13de2e3d7d36af0a310f0 (diff)
Fix #7971: Adjust paths of template archive entries exported on MacOS
... on Ardour5. On MacOS g_dir_make_tmp() does not return the canonical path. Thus, exported template archives end up with wrong entry paths. This has been fixed by e52bdc55ad for exporting templates. However, template archives that have been exported on Ardour5 are not affected by the fix. Therefor we need a workaround for the case we are importing legacy template archives from Ardour5.
Diffstat (limited to 'gtk2_ardour/template_dialog.cc')
-rw-r--r--gtk2_ardour/template_dialog.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/gtk2_ardour/template_dialog.cc b/gtk2_ardour/template_dialog.cc
index 46504f874e..a1a52138d6 100644
--- a/gtk2_ardour/template_dialog.cc
+++ b/gtk2_ardour/template_dialog.cc
@@ -46,6 +46,7 @@
#include "gtkmm2ext/gui_thread.h"
#include "gtkmm2ext/utils.h"
+#include "ardour/directory_names.h"
#include "ardour/filename_extensions.h"
#include "ardour/filesystem_paths.h"
#include "ardour/template_utils.h"
@@ -122,6 +123,7 @@ private:
void import_template_set ();
virtual std::string templates_dir () const = 0;
+ virtual std::string templates_dir_basename () const = 0;
virtual std::string template_file (const Gtk::TreeModel::const_iterator& item) const = 0;
virtual bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const = 0;
@@ -158,6 +160,7 @@ private:
void delete_selected_template ();
std::string templates_dir () const;
+ virtual std::string templates_dir_basename () const;
std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
@@ -179,13 +182,13 @@ private:
void delete_selected_template ();
std::string templates_dir () const;
+ virtual std::string templates_dir_basename () const;
std::string template_file (const Gtk::TreeModel::const_iterator& item) const;
bool adjust_xml_tree (XMLTree& tree, const std::string& old_name, const std::string& new_name) const;
};
-
TemplateDialog::TemplateDialog ()
: ArdourDialog ("Manage Templates")
{
@@ -591,8 +594,15 @@ TemplateManager::import_template_set ()
FileArchive ar (dialog.get_filename ());
PBD::ScopedConnectionList progress_connection;
ar.progress.connect_same_thread (progress_connection, boost::bind (&_set_progress, this, _1, _2));
- ar.inflate (user_config_directory ());
+ for (std::string fn = ar.next_file_name(); !fn.empty(); fn = ar.next_file_name()) {
+ const size_t pos = fn.find (templates_dir_basename ());
+ if (pos == string::npos) {
+ continue;
+ }
+ const std::string dest = Glib::build_filename (user_config_directory(), fn.substr (pos));
+ ar.extract_current_file (dest);
+ }
vector<string> files;
PBD::find_files_matching_regex (files, templates_dir (), string ("\\.template$"), /* recurse = */ true);
@@ -782,6 +792,12 @@ SessionTemplateManager::templates_dir () const
return user_template_directory ();
}
+string
+SessionTemplateManager::templates_dir_basename () const
+{
+ return string (templates_dir_name);
+}
+
string
SessionTemplateManager::template_file (const TreeModel::const_iterator& item) const
@@ -889,6 +905,12 @@ RouteTemplateManager::templates_dir () const
return user_route_template_directory ();
}
+string
+RouteTemplateManager::templates_dir_basename () const
+{
+ return string (route_templates_dir_name);
+}
+
string
RouteTemplateManager::template_file (const TreeModel::const_iterator& item) const