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) {
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;
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);
}
#include "rgb_macros.h"
#include "gui_thread.h"
#include "ui_config.h"
+#include "ardour_dialog.h"
using namespace std;
using namespace Gtk;
}
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;
+ }
+}
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__ */