+ SourceMap all_sources = _session->get_sources();
+ bool wave_name_exists = false;
+
+ for (SourceMap::iterator i = all_sources.begin(); i != all_sources.end(); ++i) {
+ string tmp (Glib::path_get_basename (i->second->path()));
+ if (tmp == wave_name) {
+ wave_name_exists = true;
+ break;
+ }
+ }
+
+ int function = 1;
+
+ if (wave_name_exists) {
+ string message;
+ if (all_or_nothing) {
+ // updating is still disabled
+ //message = string_compose(_("The session already contains a source file named %1. Do you want to update that file (and thus all regions using the file) or import this file as a new file?"),wave_name);
+ message = string_compose (_("The session already contains a source file named %1. Do you want to import %1 as a new file, or skip it?"), wave_name);
+ } else {
+ message = string_compose (_("The session already contains a source file named %1. Do you want to import %2 as a new source, or skip it?"), wave_name, wave_name);
+
+ }
+ MessageDialog dialog(message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE, true);
+
+ if (all_or_nothing) {
+ // disabled
+ //dialog.add_button("Update", 0);
+ dialog.add_button("Import", 1);
+ dialog.add_button("Skip", 2);
+ } else {
+ dialog.add_button("Import", 1);
+ dialog.add_button("Cancel", 2);
+ }
+
+ //dialog.add_button("Skip all", 4); // All or rest?
+
+ dialog.show();
+
+ function = dialog.run ();
+
+ dialog.hide();
+ }
+
+ return function;
+}
+
+boost::shared_ptr<AudioTrack>
+Editor::get_nth_selected_audio_track (int nth) const
+{
+ AudioTimeAxisView* atv;
+ TrackSelection::iterator x;
+
+ for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
+
+ atv = dynamic_cast<AudioTimeAxisView*>(*x);
+
+ if (!atv) {
+ continue;
+ } else if (atv->is_audio_track()) {
+ --nth;
+ }
+ }
+
+ if (x == selection->tracks.end()) {
+ atv = dynamic_cast<AudioTimeAxisView*>(selection->tracks.back());
+ } else {
+ atv = dynamic_cast<AudioTimeAxisView*>(*x);
+ }
+
+ if (!atv || !atv->is_audio_track()) {
+ return boost::shared_ptr<AudioTrack>();
+ }
+
+ return atv->audio_track();
+}
+
+boost::shared_ptr<MidiTrack>
+Editor::get_nth_selected_midi_track (int nth) const
+{
+ MidiTimeAxisView* mtv;
+ TrackSelection::iterator x;
+
+ for (x = selection->tracks.begin(); nth > 0 && x != selection->tracks.end(); ++x) {
+
+ mtv = dynamic_cast<MidiTimeAxisView*>(*x);
+
+ if (!mtv) {
+ continue;
+ } else if (mtv->is_midi_track()) {
+ --nth;
+ }
+ }
+
+ if (x == selection->tracks.end()) {
+ mtv = dynamic_cast<MidiTimeAxisView*>(selection->tracks.back());
+ } else {
+ mtv = dynamic_cast<MidiTimeAxisView*>(*x);