summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2015-10-12 12:29:16 +0200
committerPaul Davis <paul@linuxaudiosystems.com>2015-10-21 23:28:44 -0400
commit5d50abed75de5428c025e61224068387ab15e26d (patch)
treec1894e776615765c95ef2790f3a8f740a8e4fbda /gtk2_ardour
parent67f557b1f4fd1f1ecd9d38f14d83a12a294cb455 (diff)
Confirmation on overwrite for track and session templates. -fixes #6587
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/ardour_ui.cc23
-rw-r--r--gtk2_ardour/route_ui.cc9
-rw-r--r--gtk2_ardour/utils.cc22
-rw-r--r--gtk2_ardour/utils.h2
4 files changed, 44 insertions, 12 deletions
diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc
index e29c1bbf8d..4e016d266a 100644
--- a/gtk2_ardour/ardour_ui.cc
+++ b/gtk2_ardour/ardour_ui.cc
@@ -2495,16 +2495,8 @@ ARDOUR_UI::snapshot_session (bool switch_to_it)
vector<string> n = get_file_names_no_extension (p);
if (find (n.begin(), n.end(), snapname) != n.end()) {
- ArdourDialog confirm (_("Confirm Snapshot Overwrite"), true);
- Label m (_("A snapshot already exists with that name. Do you want to overwrite it?"));
- confirm.get_vbox()->pack_start (m, true, true);
- confirm.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
- confirm.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
- confirm.show_all ();
- switch (confirm.run()) {
- case RESPONSE_CANCEL:
- do_save = false;
- }
+ do_save = overwrite_file_dialog (_("Confirm Snapshot Overwrite"),
+ _("A snapshot already exists with that name. Do you want to overwrite it?"));
}
if (do_save) {
@@ -2690,7 +2682,16 @@ ARDOUR_UI::save_template ()
prompter.get_result (name);
if (name.length()) {
- _session->save_template (name);
+ int failed = _session->save_template (name);
+
+ if (failed == -2) { /* file already exists. */
+ bool overwrite = overwrite_file_dialog (_("Confirm Template Overwrite"),
+ _("A template already exists with that name. Do you want to overwrite it?"));
+
+ if (overwrite) {
+ _session->save_template (name, true);
+ }
+ }
}
break;
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc
index 79506f7bd3..2f45756c27 100644
--- a/gtk2_ardour/route_ui.cc
+++ b/gtk2_ardour/route_ui.cc
@@ -1863,13 +1863,20 @@ RouteUI::save_as_template ()
return;
}
- p.hide ();
p.get_result (name, true);
safe_name = legalize_for_path (name);
safe_name += template_suffix;
path = Glib::build_filename (path, safe_name);
+ if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
+ bool overwrite = overwrite_file_dialog (_("Confirm Template Overwrite"),
+ _("A template already exists with that name. Do you want to overwrite it?"));
+
+ if (!overwrite) {
+ return;
+ }
+ }
_route->save_as_template (path, name);
}
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index a047708360..cf3ca7d7dd 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -53,6 +53,7 @@
#include "rgb_macros.h"
#include "gui_thread.h"
#include "ui_config.h"
+#include "ardour_dialog.h"
using namespace std;
using namespace Gtk;
@@ -926,3 +927,24 @@ ARDOUR_UI_UTILS::windows_overlap (Gtk::Window *a, Gtk::Window *b)
}
return false;
}
+
+bool
+ARDOUR_UI_UTILS::overwrite_file_dialog (string title, string text)
+{
+ ArdourDialog dialog (title, true);
+ Label label (text);
+
+ dialog.get_vbox()->pack_start (label, true, true);
+ dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+ dialog.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
+ dialog.set_position (Gtk::WIN_POS_MOUSE);
+ dialog.show_all ();
+
+ switch (dialog.run()) {
+ case RESPONSE_ACCEPT:
+ return true;
+ case RESPONSE_CANCEL:
+ default:
+ return false;
+ }
+}
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index a7f1e16f0b..ebf966eba9 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -92,5 +92,7 @@ std::string rate_as_string (float r);
bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
+bool overwrite_file_dialog (std::string title, std::string text);
+
} // namespace
#endif /* __ardour_gtk_utils_h__ */