X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Feditor_export_audio.cc;h=795091fb4142e846753dd1013bd83e7b272925a4;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=e40030d671d5a7fe6a0b7b65df792a7dba6b0511;hpb=2ba58dfe65bb0c5ba7d5eb18a1566fa79eeb6993;p=ardour.git diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index e40030d671..795091fb41 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; @@ -86,11 +87,11 @@ Editor::export_selection () void Editor::export_range () { - Marker* marker; + ArdourMarker* marker; - if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ } Location* l; @@ -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 () @@ -114,65 +141,32 @@ Editor::export_region () boost::shared_ptr r = selection->regions.front()->region(); boost::shared_ptr audio_region = boost::dynamic_pointer_cast(r); boost::shared_ptr midi_region = boost::dynamic_pointer_cast(r); - + if (audio_region) { - + RouteTimeAxisView & rtv (dynamic_cast (selection->regions.front()->get_time_axis_view())); AudioTrack & track (dynamic_cast (*rtv.route())); - + ExportRegionDialog dialog (*this, *(audio_region.get()), track); dialog.set_session (_session); dialog.run (); - + } else if (midi_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); } }