X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_export_audio.cc;h=2bd607f10871a9a833aced746997eed9b4bccb61;hb=a5ae129a066747901ff1ed95368729b63cb6a70d;hp=57baf2ce2d17f3de0c9c8b977964eb174c3a7064;hpb=2397429e99d4b79ae874392665db2627674daaa0;p=ardour.git diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 57baf2ce2d..2bd607f108 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -51,6 +51,7 @@ #include "public_editor.h" #include "selection.h" #include "time_axis_view.h" +#include "utils.h" #include "i18n.h" @@ -103,6 +104,32 @@ Editor::export_range () } } +bool +Editor::process_midi_export_dialog (MidiExportDialog& dialog, boost::shared_ptr midi_region) +{ + string path = dialog.get_path (); + + if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { + bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (dialog, + _("Confirm MIDI File Overwrite"), + _("A file with the same name already exists. Do you want to overwrite it?")); + + if (!overwrite) { + return false; + } + + /* force ::g_unlink because the backend code will + go wrong if it tries to open an existing + file for writing. + */ + ::g_unlink (path.c_str()); + } + + (void) midi_region->clone (path); + + return true; +} + /** Export the first selected region */ void Editor::export_region () @@ -128,51 +155,18 @@ Editor::export_region () MidiExportDialog dialog (*this, midi_region); dialog.set_session (_session); - int ret = dialog.run (); - switch (ret) { - case Gtk::RESPONSE_ACCEPT: - break; - default: - return; - } - - dialog.hide (); - - string path = dialog.get_path (); - - if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) { - - MessageDialog checker (_("File Exists!"), - true, - Gtk::MESSAGE_WARNING, - Gtk::BUTTONS_NONE); - - checker.set_title (_("File Exists!")); - checker.add_button (Stock::CANCEL, RESPONSE_CANCEL); - checker.add_button (_("Overwrite Existing File"), RESPONSE_ACCEPT); - checker.set_default_response (RESPONSE_CANCEL); - - checker.set_wmclass (X_("midi_export_file_exists"), PROGRAM_NAME); - checker.set_position (Gtk::WIN_POS_MOUSE); - - ret = checker.run (); - - switch (ret) { + bool finished = false; + while (!finished) { + switch (dialog.run ()) { case Gtk::RESPONSE_ACCEPT: - /* force ::g_unlink because the backend code will - go wrong if it tries to open an existing - file for writing. - */ - ::g_unlink (path.c_str()); + finished = process_midi_export_dialog (dialog, midi_region); break; default: + finished = true; return; } - } - - (void) midi_region->clone (path); } }