X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_export_audio.cc;h=c1def2ba29451970933ef17c0a31d3dd207a42a9;hb=05149f9bc54d0cfb8b162ba7cfac975b5eb79971;hp=15592035e55633f0c8fdcbd845ef54aa12ef207e;hpb=22b07e0233a29d9633ffa825a79503befaf2e16e;p=ardour.git diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 15592035e5..c1def2ba29 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -25,7 +25,7 @@ #include -#include +#include "pbd/gstdio_compat.h" #include "gtkmm2ext/choice.h" @@ -51,8 +51,9 @@ #include "public_editor.h" #include "selection.h" #include "time_axis_view.h" +#include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -103,6 +104,30 @@ 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()); + } + + return midi_region->do_export (path); +} + /** Export the first selected region */ void Editor::export_region () @@ -128,51 +153,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); } }