summaryrefslogtreecommitdiff
path: root/gtk2_ardour/template_dialog.cc
diff options
context:
space:
mode:
authorJohannes Mueller <github@johannes-mueller.org>2017-07-12 19:57:53 +0200
committerRobin Gareus <robin@gareus.org>2017-07-15 11:37:27 +0200
commit66964aaab290501987a6ee781127c8b42e60b626 (patch)
treee31f23caae986c53e3553ac28c66daf1b8031072 /gtk2_ardour/template_dialog.cc
parentccff1c5dbd4da2f63ee6ba9ce6af09a93f8f1b2c (diff)
Force filename suffix and ask confirmation before overwriting ...
... existing files, when exporting template archives.
Diffstat (limited to 'gtk2_ardour/template_dialog.cc')
-rw-r--r--gtk2_ardour/template_dialog.cc25
1 files changed, 24 insertions, 1 deletions
diff --git a/gtk2_ardour/template_dialog.cc b/gtk2_ardour/template_dialog.cc
index 52db6fb1db..53277e62aa 100644
--- a/gtk2_ardour/template_dialog.cc
+++ b/gtk2_ardour/template_dialog.cc
@@ -265,9 +265,32 @@ TemplateManager::export_all_templates ()
int result = dialog.run ();
if (result != RESPONSE_OK || !dialog.get_filename().length()) {
+ PBD::remove_directory (tmpdir);
return;
}
+ string filename = dialog.get_filename ();
+ if (filename.compare (filename.size () - 7, 7, ".tar.xz")) {
+ filename += ".tar.xz";
+ }
+
+ if (g_file_test (filename.c_str(), G_FILE_TEST_EXISTS)) {
+ ArdourDialog dlg (_("File exists"), true);
+ Label msg (string_compose (_("The file %1 already exists."), filename));
+ dlg.get_vbox()->pack_start (msg);
+ msg.show ();
+ dlg.add_button (_("Overwrite"), RESPONSE_ACCEPT);
+ dlg.add_button (_("Cancel"), RESPONSE_REJECT);
+ dlg.set_default_response (RESPONSE_REJECT);
+
+ result = dlg.run ();
+
+ if (result == RESPONSE_REJECT) {
+ PBD::remove_directory (tmpdir);
+ return;
+ }
+ }
+
PBD::copy_recurse (templates_dir (), Glib::build_filename (tmpdir, Glib::path_get_basename (templates_dir ())));
vector<string> files;
@@ -297,7 +320,7 @@ TemplateManager::export_all_templates ()
_current_action = _("Exporting templates");
- PBD::FileArchive ar (dialog.get_filename());
+ PBD::FileArchive ar (filename);
PBD::ScopedConnectionList progress_connection;
ar.progress.connect_same_thread (progress_connection, boost::bind (&_set_progress, this, _1, _2));
ar.create (filemap);