Confirmation on overwrite for track and session templates. -fixes #6587
This commit is contained in:
parent
67f557b1f4
commit
5d50abed75
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
Loading…
Reference in New Issue