X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_export_audio.cc;h=1a4f88e2f26f04ae0ce531ccea23011e53a19884;hb=735d791e420c3e4944fdbc8ac7f6a26251d90d87;hp=c886885dd23849fd6fa5652620bd0e6316748c69;hpb=2c4e79d0a087ab1aafb5aa53ce0e88c3b74220bc;p=ardour.git diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index c886885dd2..1a4f88e2f2 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -27,8 +27,6 @@ #include "pbd/gstdio_compat.h" -#include "gtkmm2ext/choice.h" - #include "pbd/pthread_utils.h" #include "ardour/audio_track.h" @@ -53,7 +51,7 @@ #include "time_axis_view.h" #include "utils.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -104,6 +102,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 () @@ -129,34 +151,17 @@ 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)) { - bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (_("Confirm MIDI File Overwrite"), - _("A file with the same name already exists. Do you want to overwrite it?")); - - if (!overwrite) { + bool finished = false; + while (!finished) { + switch (dialog.run ()) { + case Gtk::RESPONSE_ACCEPT: + finished = process_midi_export_dialog (dialog, midi_region); + break; + default: return; } - - /* 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); } }