diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-05 20:36:44 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-05 20:36:44 +0000 |
commit | aa78fb928b116c63a883679d2d199063a68c9bce (patch) | |
tree | 219975c4b246712ab212f478845949c2ac53db32 /gtk2_ardour/editor_audio_import.cc | |
parent | e98cf169ebe49a0ca5705ed6f059c41edd117ac8 (diff) |
try to sensibly handle repeated imports of the same file. the same thing might be required for embeds
git-svn-id: svn://localhost/ardour2/branches/3.0@7975 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_audio_import.cc')
-rw-r--r-- | gtk2_ardour/editor_audio_import.cc | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index cd3c76a4ad..852958b798 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -359,6 +359,7 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode if (cancel) { ok = false; } else { + ipw.show (); ok = (import_sndfiles (paths, mode, quality, pos, 1, 1, track, false) == 0); } @@ -392,6 +393,8 @@ Editor::do_import (vector<string> paths, ImportDisposition chns, ImportMode mode pos = -1; } + ipw.show (); + switch (chns) { case Editing::ImportDistinctFiles: @@ -505,6 +508,41 @@ int Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quality, framepos_t& pos, int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace) { + /* check for existing wholefile regions of the same name, + which can happen when we import foo.wav but end up with foo-L.wav + and foo-R.wav inside the session. this case doesn't trigger + source name collisions, so we have to catch it at the region + name level. + */ + + string region_name = region_name_from_path (paths.front(), true, false); + + if (RegionFactory::wholefile_region_by_name (region_name)) { + string message = string_compose ( _("You appear to have already imported this file, since a region called %1 already exists.\nDo you really want to import it again?"), + region_name); + MessageDialog dialog (message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL, true); + int ret; + + dialog.show (); + ret = dialog.run (); + dialog.hide (); + + if (ret != RESPONSE_OK) { + return -1; + } + + int l = 0; + + while (RegionFactory::region_by_name (region_name) && ++l < 999) { + region_name = bump_name_once (region_name, '.'); + } + + if (l == 999) { + error << string_compose (_("Too many regions already named something like \"%1\""), paths.front()) << endmsg; + return -1; + } + } + import_status.paths = paths; import_status.done = false; import_status.cancel = false; @@ -749,6 +787,12 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos, region_name = region_name_from_path (paths.front(), (sources.size() > 1), false); + /* we checked in import_sndfiles() that there were not too many */ + + while (RegionFactory::region_by_name (region_name)) { + region_name = bump_name_once (region_name, '.'); + } + PropertyList plist; plist.add (ARDOUR::Properties::start, 0); @@ -929,7 +973,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region, uint32_t existing_track = mt.front(); } - + existing_track->set_name (region->name()); } |