enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / gtk2_ardour / editor_audio_import.cc
index 6be0a7813618c002476a418775c831ee8b2dc45d..237fb6776d99d36940340b8f34e22501a55142bc 100644 (file)
@@ -58,7 +58,7 @@
 #include "mouse_cursors.h"
 #include "editor_cursors.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -80,7 +80,7 @@ Editor::add_external_audio_action (ImportMode mode_hint)
        }
 
        if (sfbrowser == 0) {
-               sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, 0, true, mode_hint);
+               sfbrowser = new SoundFileOmega (_("Add Existing Media"), _session, 0, 0, true, mode_hint);
        } else {
                sfbrowser->set_mode (mode_hint);
        }
@@ -110,7 +110,7 @@ Editor::external_audio_dialog ()
                if (atv) {
                        if (atv->is_audio_track()) {
                                audio_track_cnt++;
-                       } 
+                       }
 
                } else {
                        MidiTimeAxisView* mtv = dynamic_cast<MidiTimeAxisView*>(*x);
@@ -303,6 +303,7 @@ Editor::do_import (vector<string>        paths,
                } else {
                        ipw.show ();
                        ok = (import_sndfiles (paths, disposition, mode, quality, pos, 1, 1, track, false, instrument) == 0);
+                       import_status.sources.clear();
                }
 
        } else {
@@ -348,6 +349,7 @@ Editor::do_import (vector<string>        paths,
                                }
 
                                ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, -1, track, replace, instrument) == 0);
+                               import_status.sources.clear();
                                break;
 
                        case Editing::ImportDistinctChannels:
@@ -356,6 +358,7 @@ Editor::do_import (vector<string>        paths,
                                to_import.push_back (*a);
 
                                ok = (import_sndfiles (to_import, disposition, mode, quality, pos, -1, -1, track, replace, instrument) == 0);
+                               import_status.sources.clear();
                                break;
 
                        case Editing::ImportSerializeFiles:
@@ -364,6 +367,7 @@ Editor::do_import (vector<string>        paths,
                                to_import.push_back (*a);
 
                                ok = (import_sndfiles (to_import, disposition, mode, quality, pos, 1, 1, track, replace, instrument) == 0);
+                               import_status.sources.clear();
                                break;
 
                        case Editing::ImportMergeFiles:
@@ -503,7 +507,10 @@ Editor::import_sndfiles (vector<string>            paths,
                gtk_main_iteration ();
        }
 
-       import_status.done = true;
+       // wait for thread to terminate
+       while (!import_status.done) {
+               gtk_main_iteration ();
+       }
 
        int result = -1;
 
@@ -524,7 +531,6 @@ Editor::import_sndfiles (vector<string>            paths,
                pos = import_status.pos;
        }
 
-       import_status.sources.clear();
        return result;
 }
 
@@ -625,7 +631,7 @@ Editor::embed_sndfiles (vector<string>            paths,
 
                                        source = boost::dynamic_pointer_cast<AudioFileSource> (
                                                SourceFactory::createExternal (DataType::AUDIO, *_session,
-                                                                              path, n, 
+                                                                              path, n,
                                                                               (mode == ImportAsTapeTrack
                                                                                ? Source::Destructive
                                                                                : Source::Flag (0)),
@@ -734,7 +740,7 @@ Editor::add_sources (vector<string>            paths,
                                /* generate a per-channel region name so that things work as
                                 * intended
                                 */
-                               
+
                                string path;
 
                                if (fs) {
@@ -742,7 +748,7 @@ Editor::add_sources (vector<string>            paths,
                                } else {
                                        region_name = (*x)->name();
                                }
-                               
+
                                if (sources.size() == 2) {
                                        if (n == 0) {
                                                region_name += "-L";
@@ -752,9 +758,9 @@ Editor::add_sources (vector<string>            paths,
                                } else if (sources.size() > 2) {
                                        region_name += string_compose ("-%1", n+1);
                                }
-                               
+
                                track_names.push_back (region_name);
-                               
+
                        } else {
                                if (fs) {
                                        region_name = region_name_from_path (fs->path(), false, false, sources.size(), n);
@@ -825,7 +831,7 @@ Editor::add_sources (vector<string>            paths,
         * the API simpler.
         */
        assert (regions.size() == track_names.size());
-       
+
        for (vector<boost::shared_ptr<Region> >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) {
                boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*r);
 
@@ -857,7 +863,7 @@ Editor::add_sources (vector<string>            paths,
                                 pos = get_preferred_edit_position ();
                         }
                 }
-               
+
                finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track, track_names[n], instrument);
 
                rlen = (*r)->length();
@@ -873,7 +879,7 @@ Editor::add_sources (vector<string>            paths,
        }
 
        commit_reversible_command ();
-       
+
        /* setup peak file building in another thread */
 
        for (SourceList::iterator x = sources.begin(); x != sources.end(); ++x) {
@@ -931,24 +937,38 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
        {
                if (!existing_track) {
                        if (ar) {
-                               list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, Normal, 0, 1));
+                               list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Normal));
 
                                if (at.empty()) {
                                        return -1;
                                }
+                               if (Config->get_strict_io ()) {
+                                       for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
+                                               (*i)->set_strict_io (true);
+                                       }
+                               }
 
                                existing_track = at.front();
                        } else if (mr) {
                                list<boost::shared_ptr<MidiTrack> > mt (
                                        _session->new_midi_track (ChanCount (DataType::MIDI, 1),
                                                                  ChanCount (DataType::MIDI, 1),
-                                                                 instrument,
-                                                                 Normal, 0, 1));
+                                                                 instrument, (Plugin::PresetRecord*) 0,
+                                                                 (RouteGroup*) 0,
+                                                                 1,
+                                                                 string(),
+                                                                 PresentationInfo::max_order));
 
                                if (mt.empty()) {
                                        return -1;
                                }
+                               if (Config->get_strict_io ()) {
+                                       for (list<boost::shared_ptr<MidiTrack> >::iterator i = mt.begin(); i != mt.end(); ++i) {
+                                               (*i)->set_strict_io (true);
+                                       }
+                               }
 
+                               // TODO set strict_io from preferences
                                existing_track = mt.front();
                        }
 
@@ -973,7 +993,7 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
                        return -1;
                }
 
-               list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, Destructive));
+               list<boost::shared_ptr<AudioTrack> > at (_session->new_audio_track (in_chans, out_chans, 0, 1, string(), PresentationInfo::max_order, Destructive));
                if (!at.empty()) {
                        boost::shared_ptr<Playlist> playlist = at.front()->playlist();
                        boost::shared_ptr<Region> copy (RegionFactory::create (region, true));
@@ -981,6 +1001,11 @@ Editor::finish_bringing_in_material (boost::shared_ptr<Region> region,
                        playlist->add_region (copy, pos);
                        _session->add_command (new StatefulDiffCommand (playlist));
                }
+               if (Config->get_strict_io ()) {
+                       for (list<boost::shared_ptr<AudioTrack> >::iterator i = at.begin(); i != at.end(); ++i) {
+                               (*i)->set_strict_io (true);
+                       }
+               }
                break;
        }
        }