minor polish for midi export dialog

git-svn-id: svn://localhost/ardour2/branches/3.0@12403 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-05-23 21:12:07 +00:00
parent e0d0735fa2
commit 32be58740d
3 changed files with 57 additions and 1 deletions

View File

@ -136,7 +136,42 @@ Editor::export_region ()
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);
}
}

View File

@ -19,7 +19,9 @@
#include <gtkmm/stock.h>
#include "ardour/directory_names.h"
#include "ardour/midi_region.h"
#include "ardour/session.h"
#include "midi_export_dialog.h"
@ -29,17 +31,34 @@ MidiExportDialog::MidiExportDialog (PublicEditor&, boost::shared_ptr<MidiRegion>
: 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
{

View File

@ -32,6 +32,8 @@ class MidiExportDialog : public ArdourDialog {
MidiExportDialog (PublicEditor& editor, boost::shared_ptr<ARDOUR::MidiRegion>);
~MidiExportDialog ();
void set_session (ARDOUR::Session*);
std::string get_path() const;
private: