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) {
+ case Gtk::RESPONSE_ACCEPT:
+ /* force unlink because the backend code will
+ go wrong if it tries to open an existing
+ file for writing.
+ */
+ ::unlink (path.c_str());
+ break;
+ default:
+ return;
+ }
+
+ }
+
(void) midi_region->clone (path);
}
}
#include <gtkmm/stock.h>
+#include "ardour/directory_names.h"
#include "ardour/midi_region.h"
+#include "ardour/session.h"
#include "midi_export_dialog.h"
: ArdourDialog (string_compose (_("Export MIDI: %1"), region->name()))
, file_chooser (Gtk::FILE_CHOOSER_ACTION_SAVE)
{
+ set_border_width (12);
+
add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
+
+ get_vbox()->set_border_width (12);
get_vbox()->pack_start (file_chooser);
- file_chooser.set_filename (region->name() + ".mid");
+
+ set_default_response (Gtk::RESPONSE_ACCEPT);
+
+ file_chooser.set_current_name (region->name() + ".mid");
file_chooser.show ();
+
+ file_chooser.signal_file_activated().connect (sigc::bind (sigc::mem_fun (*this, &MidiExportDialog::response), Gtk::RESPONSE_ACCEPT));
}
MidiExportDialog::~MidiExportDialog ()
{
}
+void
+MidiExportDialog::set_session (Session* s)
+{
+ ArdourDialog::set_session (s);
+
+ file_chooser.set_current_folder (Glib::build_filename (Glib::path_get_dirname (s->path()), ARDOUR::export_dir_name));
+}
+
std::string
MidiExportDialog::get_path () const
{