summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_export_audio.cc
diff options
context:
space:
mode:
authorAndré Nusser <andre.nusser@googlemail.com>2015-11-01 21:00:05 +0100
committerPaul Davis <paul@linuxaudiosystems.com>2015-11-04 17:52:00 -0500
commit6ccffbaf0937c7814f3c49510859d13bc033df99 (patch)
treee0ce798c754ae56e9535182d6900f8fcefee555d /gtk2_ardour/editor_export_audio.cc
parente8a832f03f300ff532f108f24663a4bded7e7e0d (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/editor_export_audio.cc')
-rw-r--r--gtk2_ardour/editor_export_audio.cc58
1 files changed, 34 insertions, 24 deletions
diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc
index c886885dd2..2bd607f108 100644
--- a/gtk2_ardour/editor_export_audio.cc
+++ b/gtk2_ardour/editor_export_audio.cc
@@ -104,6 +104,32 @@ Editor::export_range ()
}
}
+bool
+Editor::process_midi_export_dialog (MidiExportDialog& dialog, boost::shared_ptr<MidiRegion> 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 ()
@@ -129,34 +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)) {
- 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:
+ finished = true;
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);
}
}