+ if (ok) {
+ session->save_state ("");
+ }
+
+ interthread_progress_window->hide_all ();
+ }
+}
+
+bool
+Editor::idle_do_embed (vector<ustring> paths, ImportDisposition chns, ImportMode mode, nframes64_t& pos)
+{
+ _do_embed (paths, chns, mode, pos);
+ return false;
+}
+
+void
+Editor::do_embed (vector<ustring> paths, ImportDisposition chns, ImportMode mode, nframes64_t& pos)
+{
+#ifdef GTKOSX
+ Glib::signal_idle().connect (bind (mem_fun (*this, &Editor::idle_do_embed), paths, chns, mode, pos));
+#else
+ _do_embed (paths, chns, mode, pos);
+#endif
+}
+
+void
+Editor::_do_embed (vector<ustring> paths, ImportDisposition chns, ImportMode mode, nframes64_t& pos)
+{
+ boost::shared_ptr<Track> track;
+ bool check_sample_rate = true;
+ bool ok = false;
+ vector<ustring> to_embed;
+ bool multi = paths.size() > 1;
+ int nth = 0;
+
+ switch (chns) {
+ case Editing::ImportDistinctFiles:
+ for (vector<ustring>::iterator a = paths.begin(); a != paths.end(); ++a) {
+
+ to_embed.clear ();
+ to_embed.push_back (*a);
+
+ if (mode == Editing::ImportToTrack) {
+ track = get_nth_selected_audio_track (nth++);
+ }
+
+ if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, 1, -1, track) < -1) {
+ goto out;
+ }
+ }
+ break;
+
+ case Editing::ImportDistinctChannels:
+ for (vector<ustring>::iterator a = paths.begin(); a != paths.end(); ++a) {
+
+ to_embed.clear ();
+ to_embed.push_back (*a);
+
+ if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, -1, -1, track) < -1) {
+ goto out;
+ }
+ }
+ break;
+
+ case Editing::ImportMergeFiles:
+ if (embed_sndfiles (paths, multi, check_sample_rate, mode, pos, 1, 1, track) < -1) {
+ goto out;
+ }
+ break;
+
+ case Editing::ImportSerializeFiles:
+ for (vector<ustring>::iterator a = paths.begin(); a != paths.end(); ++a) {
+
+ to_embed.clear ();
+ to_embed.push_back (*a);
+
+ if (embed_sndfiles (to_embed, multi, check_sample_rate, mode, pos, 1, 1, track) < -1) {
+ goto out;