diff options
author | André Nusser <andre.nusser@googlemail.com> | 2015-11-01 21:00:05 +0100 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-11-04 17:52:00 -0500 |
commit | 6ccffbaf0937c7814f3c49510859d13bc033df99 (patch) | |
tree | e0ce798c754ae56e9535182d6900f8fcefee555d /gtk2_ardour/route_ui.cc | |
parent | e8a832f03f300ff532f108f24663a4bded7e7e0d (diff) |
Improve behavior of overwrite_file_dialog.
- Make overwrite file dialogs transient.
- Cancelling the overwrite dialog doesn't close initial dialog.
Diffstat (limited to 'gtk2_ardour/route_ui.cc')
-rw-r--r-- | gtk2_ardour/route_ui.cc | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 2f45756c27..8cb91020c3 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -1837,48 +1837,64 @@ RouteUI::adjust_latency () LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle()); } -void -RouteUI::save_as_template () +bool +RouteUI::process_save_template_prompter (ArdourPrompter& prompter, const std::string& dir) { std::string path; std::string safe_name; - string name; - - path = ARDOUR::user_route_template_directory (); - - if (g_mkdir_with_parents (path.c_str(), 0755)) { - error << string_compose (_("Cannot create route template directory %1"), path) << endmsg; - return; - } - - Prompter p (true); // modal + std::string name; - p.set_title (_("Save As Template")); - p.set_prompt (_("Template name:")); - p.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); - switch (p.run()) { - case RESPONSE_ACCEPT: - break; - default: - return; - } - - p.get_result (name, true); + prompter.get_result (name, true); safe_name = legalize_for_path (name); safe_name += template_suffix; - path = Glib::build_filename (path, safe_name); + path = Glib::build_filename (dir, safe_name); + if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { - bool overwrite = overwrite_file_dialog (_("Confirm Template Overwrite"), + bool overwrite = overwrite_file_dialog (prompter, + _("Confirm Template Overwrite"), _("A template already exists with that name. Do you want to overwrite it?")); if (!overwrite) { - return; + return false; } } _route->save_as_template (path, name); + + return true; +} + +void +RouteUI::save_as_template () +{ + std::string dir; + + dir = ARDOUR::user_route_template_directory (); + + if (g_mkdir_with_parents (dir.c_str(), 0755)) { + error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg; + return; + } + + ArdourPrompter prompter (true); // modal + + prompter.set_title (_("Save As Template")); + prompter.set_prompt (_("Template name:")); + prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT); + + bool finished = false; + while (!finished) { + switch (prompter.run()) { + case RESPONSE_ACCEPT: + finished = process_save_template_prompter (prompter, dir); + break; + default: + finished = true; + break; + } + } } void |