Merge branch 'chaot4-f_overwrite_dialog_improvement'
This commit is contained in:
commit
6cf7ca3a85
|
@ -2442,6 +2442,47 @@ ARDOUR_UI::save_session_as ()
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR_UI::process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it)
|
||||
{
|
||||
string snapname;
|
||||
|
||||
prompter.get_result (snapname);
|
||||
|
||||
bool do_save = (snapname.length() != 0);
|
||||
|
||||
if (do_save) {
|
||||
char illegal = Session::session_name_is_legal(snapname);
|
||||
if (illegal) {
|
||||
MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
|
||||
"snapshot names may not contain a '%1' character"), illegal));
|
||||
msg.run ();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
vector<std::string> p;
|
||||
get_state_files_in_directory (_session->session_directory().root_path(), p);
|
||||
vector<string> n = get_file_names_no_extension (p);
|
||||
|
||||
if (find (n.begin(), n.end(), snapname) != n.end()) {
|
||||
|
||||
do_save = overwrite_file_dialog (prompter,
|
||||
_("Confirm Snapshot Overwrite"),
|
||||
_("A snapshot already exists with that name. Do you want to overwrite it?"));
|
||||
}
|
||||
|
||||
if (do_save) {
|
||||
save_state (snapname, switch_to_it);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/** Ask the user for the name of a new snapshot and then take it.
|
||||
*/
|
||||
|
||||
|
@ -2449,7 +2490,6 @@ void
|
|||
ARDOUR_UI::snapshot_session (bool switch_to_it)
|
||||
{
|
||||
ArdourPrompter prompter (true);
|
||||
string snapname;
|
||||
|
||||
prompter.set_name ("Prompter");
|
||||
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
|
@ -2472,41 +2512,19 @@ ARDOUR_UI::snapshot_session (bool switch_to_it)
|
|||
prompter.set_initial_text (timebuf);
|
||||
}
|
||||
|
||||
again:
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
{
|
||||
prompter.get_result (snapname);
|
||||
|
||||
bool do_save = (snapname.length() != 0);
|
||||
|
||||
if (do_save) {
|
||||
char illegal = Session::session_name_is_legal(snapname);
|
||||
if (illegal) {
|
||||
MessageDialog msg (string_compose (_("To ensure compatibility with various systems\n"
|
||||
"snapshot names may not contain a '%1' character"), illegal));
|
||||
msg.run ();
|
||||
goto again;
|
||||
}
|
||||
bool finished = false;
|
||||
while (!finished) {
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
{
|
||||
finished = process_snapshot_session_prompter (prompter, switch_to_it);
|
||||
break;
|
||||
}
|
||||
|
||||
vector<std::string> p;
|
||||
get_state_files_in_directory (_session->session_directory().root_path(), p);
|
||||
vector<string> n = get_file_names_no_extension (p);
|
||||
if (find (n.begin(), n.end(), snapname) != n.end()) {
|
||||
|
||||
do_save = overwrite_file_dialog (_("Confirm Snapshot Overwrite"),
|
||||
_("A snapshot already exists with that name. Do you want to overwrite it?"));
|
||||
default:
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (do_save) {
|
||||
save_state (snapname, switch_to_it);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2661,11 +2679,37 @@ ARDOUR_UI::transport_rec_enable_blink (bool onoff)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ARDOUR_UI::process_save_template_prompter (ArdourPrompter& prompter)
|
||||
{
|
||||
string name;
|
||||
|
||||
prompter.get_result (name);
|
||||
|
||||
if (name.length()) {
|
||||
int failed = _session->save_template (name);
|
||||
|
||||
if (failed == -2) { /* file already exists. */
|
||||
bool overwrite = overwrite_file_dialog (prompter,
|
||||
_("Confirm Template Overwrite"),
|
||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||
|
||||
if (overwrite) {
|
||||
_session->save_template (name, true);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
ARDOUR_UI::save_template ()
|
||||
{
|
||||
ArdourPrompter prompter (true);
|
||||
string name;
|
||||
|
||||
if (!check_audioengine(*editor)) {
|
||||
return;
|
||||
|
@ -2677,26 +2721,17 @@ ARDOUR_UI::save_template ()
|
|||
prompter.set_initial_text(_session->name() + _("-template"));
|
||||
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
prompter.get_result (name);
|
||||
bool finished = false;
|
||||
while (!finished) {
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
finished = process_save_template_prompter (prompter);
|
||||
break;
|
||||
|
||||
if (name.length()) {
|
||||
int failed = _session->save_template (name);
|
||||
|
||||
if (failed == -2) { /* file already exists. */
|
||||
bool overwrite = overwrite_file_dialog (_("Confirm Template Overwrite"),
|
||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||
|
||||
if (overwrite) {
|
||||
_session->save_template (name, true);
|
||||
}
|
||||
}
|
||||
default:
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,7 @@ class ButtonJoiner;
|
|||
class ConnectionEditor;
|
||||
class MainClock;
|
||||
class Mixer_UI;
|
||||
class ArdourPrompter;
|
||||
class PublicEditor;
|
||||
class SaveAsDialog;
|
||||
class SessionDialog;
|
||||
|
@ -555,6 +556,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
|
||||
void open_session ();
|
||||
void open_recent_session ();
|
||||
bool process_save_template_prompter (ArdourPrompter& prompter);
|
||||
void save_template ();
|
||||
|
||||
void edit_metadata ();
|
||||
|
@ -598,6 +600,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
|
|||
|
||||
guint32 last_key_press_time;
|
||||
|
||||
bool process_snapshot_session_prompter (ArdourPrompter& prompter, bool switch_to_it);
|
||||
void snapshot_session (bool switch_to_it);
|
||||
|
||||
SaveAsDialog* save_as_dialog;
|
||||
|
|
|
@ -67,20 +67,21 @@ namespace Gtkmm2ext {
|
|||
}
|
||||
|
||||
namespace ARDOUR {
|
||||
class RouteGroup;
|
||||
class Playlist;
|
||||
class AudioPlaylist;
|
||||
class AudioRegion;
|
||||
class Region;
|
||||
class Location;
|
||||
class TempoSection;
|
||||
class Session;
|
||||
class Filter;
|
||||
class ChanCount;
|
||||
class MidiOperator;
|
||||
class Track;
|
||||
class MidiTrack;
|
||||
class AudioTrack;
|
||||
class ChanCount;
|
||||
class Filter;
|
||||
class Location;
|
||||
class MidiOperator;
|
||||
class MidiRegion;
|
||||
class MidiTrack;
|
||||
class Playlist;
|
||||
class Region;
|
||||
class RouteGroup;
|
||||
class Session;
|
||||
class TempoSection;
|
||||
class Track;
|
||||
}
|
||||
|
||||
namespace LADSPA {
|
||||
|
@ -113,6 +114,7 @@ class GroupedButtons;
|
|||
class GUIObjectState;
|
||||
class ArdourMarker;
|
||||
class MidiRegionView;
|
||||
class MidiExportDialog;
|
||||
class MixerStrip;
|
||||
class MouseCursors;
|
||||
class NoteBase;
|
||||
|
@ -282,6 +284,8 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void export_range ();
|
||||
void export_region ();
|
||||
|
||||
bool process_midi_export_dialog (MidiExportDialog& dialog, boost::shared_ptr<ARDOUR::MidiRegion> midi_region);
|
||||
|
||||
void add_transport_frame (Gtk::Container&);
|
||||
void add_toplevel_menu (Gtk::Container&);
|
||||
Gtk::HBox& get_status_bar_packer() { return status_bar_hpacker; }
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -619,7 +619,7 @@ ExportVideoDialog::launch_export ()
|
|||
_session->add_extra_xml (get_state());
|
||||
|
||||
std::string outfn = outfn_path_entry.get_text();
|
||||
if (!confirm_video_outfn(outfn)) { return; }
|
||||
if (!confirm_video_outfn(*this, outfn)) { return; }
|
||||
|
||||
vbox->hide();
|
||||
cancel_button->hide();
|
||||
|
|
|
@ -37,8 +37,8 @@ MidiExportDialog::MidiExportDialog (PublicEditor&, boost::shared_ptr<MidiRegion>
|
|||
{
|
||||
set_border_width (12);
|
||||
|
||||
add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
|
||||
get_vbox()->set_border_width (12);
|
||||
get_vbox()->pack_start (file_chooser);
|
||||
|
|
|
@ -1837,48 +1837,64 @@ RouteUI::adjust_latency ()
|
|||
LatencyDialog dialog (_route->name() + _(" latency"), *(_route->output()), _session->frame_rate(), AudioEngine::instance()->samples_per_cycle());
|
||||
}
|
||||
|
||||
void
|
||||
RouteUI::save_as_template ()
|
||||
bool
|
||||
RouteUI::process_save_template_prompter (ArdourPrompter& prompter, const std::string& dir)
|
||||
{
|
||||
std::string path;
|
||||
std::string safe_name;
|
||||
string name;
|
||||
std::string name;
|
||||
|
||||
path = ARDOUR::user_route_template_directory ();
|
||||
|
||||
if (g_mkdir_with_parents (path.c_str(), 0755)) {
|
||||
error << string_compose (_("Cannot create route template directory %1"), path) << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
Prompter p (true); // modal
|
||||
|
||||
p.set_title (_("Save As Template"));
|
||||
p.set_prompt (_("Template name:"));
|
||||
p.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
switch (p.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
p.get_result (name, true);
|
||||
prompter.get_result (name, true);
|
||||
|
||||
safe_name = legalize_for_path (name);
|
||||
safe_name += template_suffix;
|
||||
|
||||
path = Glib::build_filename (path, safe_name);
|
||||
path = Glib::build_filename (dir, safe_name);
|
||||
|
||||
if (Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
|
||||
bool overwrite = overwrite_file_dialog (_("Confirm Template Overwrite"),
|
||||
bool overwrite = overwrite_file_dialog (prompter,
|
||||
_("Confirm Template Overwrite"),
|
||||
_("A template already exists with that name. Do you want to overwrite it?"));
|
||||
|
||||
if (!overwrite) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_route->save_as_template (path, name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
RouteUI::save_as_template ()
|
||||
{
|
||||
std::string dir;
|
||||
|
||||
dir = ARDOUR::user_route_template_directory ();
|
||||
|
||||
if (g_mkdir_with_parents (dir.c_str(), 0755)) {
|
||||
error << string_compose (_("Cannot create route template directory %1"), dir) << endmsg;
|
||||
return;
|
||||
}
|
||||
|
||||
ArdourPrompter prompter (true); // modal
|
||||
|
||||
prompter.set_title (_("Save As Template"));
|
||||
prompter.set_prompt (_("Template name:"));
|
||||
prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
|
||||
|
||||
bool finished = false;
|
||||
while (!finished) {
|
||||
switch (prompter.run()) {
|
||||
case RESPONSE_ACCEPT:
|
||||
finished = process_save_template_prompter (prompter, dir);
|
||||
break;
|
||||
default:
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -219,6 +219,7 @@ class RouteUI : public virtual AxisView
|
|||
virtual void map_frozen ();
|
||||
|
||||
void adjust_latency ();
|
||||
bool process_save_template_prompter (ArdourPrompter& prompter, const std::string& dir);
|
||||
void save_as_template ();
|
||||
void open_remote_control_id_dialog ();
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ TranscodeVideoDialog::launch_transcode ()
|
|||
return;
|
||||
}
|
||||
std::string outfn = path_entry.get_text();
|
||||
if (!confirm_video_outfn(outfn, video_get_docroot(Config))) return;
|
||||
if (!confirm_video_outfn(*this, outfn, video_get_docroot(Config))) return;
|
||||
progress_label.set_text (_("Transcoding Video.."));
|
||||
dialog_progress_mode();
|
||||
#if 1 /* tentative debug mode */
|
||||
|
|
|
@ -929,15 +929,14 @@ ARDOUR_UI_UTILS::windows_overlap (Gtk::Window *a, Gtk::Window *b)
|
|||
}
|
||||
|
||||
bool
|
||||
ARDOUR_UI_UTILS::overwrite_file_dialog (string title, string text)
|
||||
ARDOUR_UI_UTILS::overwrite_file_dialog (Gtk::Window& parent, string title, string text)
|
||||
{
|
||||
ArdourDialog dialog (title, true);
|
||||
ArdourDialog dialog (parent, title, true);
|
||||
Label label (text);
|
||||
|
||||
dialog.get_vbox()->pack_start (label, true, true);
|
||||
dialog.add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
||||
dialog.add_button (_("Overwrite"), Gtk::RESPONSE_ACCEPT);
|
||||
dialog.set_position (Gtk::WIN_POS_MOUSE);
|
||||
dialog.show_all ();
|
||||
|
||||
switch (dialog.run()) {
|
||||
|
|
|
@ -92,7 +92,7 @@ std::string rate_as_string (float r);
|
|||
|
||||
bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
|
||||
|
||||
bool overwrite_file_dialog (std::string title, std::string text);
|
||||
bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
|
||||
|
||||
} // namespace
|
||||
#endif /* __ardour_gtk_utils_h__ */
|
||||
|
|
|
@ -46,7 +46,7 @@ using namespace ARDOUR;
|
|||
using namespace VideoUtils;
|
||||
|
||||
bool
|
||||
VideoUtils::confirm_video_outfn (std::string outfn, std::string docroot)
|
||||
VideoUtils::confirm_video_outfn (Gtk::Window& parent, std::string outfn, std::string docroot)
|
||||
{
|
||||
/* replace docroot's '/' to G_DIR_SEPARATOR for the comparison */
|
||||
size_t look_here = 0;
|
||||
|
@ -68,7 +68,8 @@ VideoUtils::confirm_video_outfn (std::string outfn, std::string docroot)
|
|||
}
|
||||
|
||||
if (Glib::file_test(outfn, Glib::FILE_TEST_EXISTS)) {
|
||||
bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (_("Confirm Overwrite"),
|
||||
bool overwrite = ARDOUR_UI_UTILS::overwrite_file_dialog (parent,
|
||||
_("Confirm Overwrite"),
|
||||
_("A file with the same name already exists. Do you want to overwrite it?"));
|
||||
|
||||
if (!overwrite) {
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace VideoUtils {
|
||||
|
||||
bool confirm_video_outfn (std::string, std::string docroot="");
|
||||
bool confirm_video_outfn (Gtk::Window& parent, std::string, std::string docroot="");
|
||||
std::string video_dest_dir (const std::string, const std::string);
|
||||
std::string video_dest_file (const std::string, const std::string);
|
||||
std::string strip_file_extension (const std::string infile);
|
||||
|
|
Loading…
Reference in New Issue
Block a user