Allow port matrix to show both audio and midi ports at the same time, and use that...
[ardour.git] / gtk2_ardour / sfdb_ui.cc
index 05eacd1367e57574601119c5a8ecb4891f09d8cc..2e6235e70cefe8f3650d2292680b74fb828d0752 100644 (file)
@@ -113,8 +113,7 @@ importmode2string (ImportMode mode)
 }
 
 SoundFileBox::SoundFileBox (bool persistent)
-       : _session(0),
-         table (6, 2),
+       : table (6, 2),
          length_clock ("sfboxLengthClock", !persistent, "EditCursorClock", false, false, true, false),
          timecode_clock ("sfboxTimecodeClock", !persistent, "EditCursorClock", false, false, false, false),
          main_box (false, 6),
@@ -202,16 +201,15 @@ SoundFileBox::SoundFileBox (bool persistent)
 void
 SoundFileBox::set_session(Session* s)
 {
-       _session = s;
+       SessionHandlePtr::set_session (s);
+
+       length_clock.set_session (s);
+       timecode_clock.set_session (s);
 
        if (!_session) {
                play_btn.set_sensitive (false);
                stop_btn.set_sensitive (false);
        }
-
-
-       length_clock.set_session (s);
-       timecode_clock.set_session (s);
 }
 
 bool
@@ -310,6 +308,11 @@ SoundFileBox::audition ()
                return;
        }
 
+       if (SMFSource::safe_midi_file_extension (path)) {
+               error << _("Auditioning of MIDI files is not yet supported") << endmsg;
+               return;
+       }
+
        _session->cancel_audition();
 
        if (!Glib::file_test (path, Glib::FILE_TEST_EXISTS)) {
@@ -349,9 +352,15 @@ SoundFileBox::audition ()
 
        afs = boost::dynamic_pointer_cast<AudioFileSource> (srclist[0]);
        string rname = region_name_from_path (afs->path(), false);
-       r = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0,
-                               srclist[0]->length(srclist[0]->timeline_position()),
-                               rname, 0, Region::DefaultFlags, false));
+       
+       PropertyList plist; 
+       
+       plist.add (ARDOUR::Properties::start, 0);
+       plist.add (ARDOUR::Properties::length, srclist[0]->length(srclist[0]->timeline_position()));
+       plist.add (ARDOUR::Properties::name, rname);
+       plist.add (ARDOUR::Properties::layer, 0);
+       
+       r = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, plist, false));
 
        _session->audition_region(r);
 }
@@ -419,6 +428,9 @@ SoundFileBrowser::SoundFileBrowser (Gtk::Window& parent, string title, ARDOUR::S
                chooser.add_shortcut_folder_uri("file:///Library/Application Support/GarageBand/Instrument Library/Sampler/Sampler Files");
        }
 
+#ifdef GTKOSX
+        chooser.add_shortcut_folder_uri("file:///Volumes");
+#endif
 
        //add the file chooser
        {
@@ -439,6 +451,10 @@ SoundFileBrowser::SoundFileBrowser (Gtk::Window& parent, string title, ARDOUR::S
                chooser.set_select_multiple (true);
                chooser.signal_update_preview().connect(sigc::mem_fun(*this, &SoundFileBrowser::update_preview));
                chooser.signal_file_activated().connect (sigc::mem_fun (*this, &SoundFileBrowser::chooser_file_activated));
+#ifdef GTKOSX
+                /* some broken redraw behaviour - this is a bandaid */
+                chooser.signal_selection_changed().connect (mem_fun (chooser, &Widget::queue_draw));
+#endif
 
                if (!persistent_folder.empty()) {
                        chooser.set_current_folder (persistent_folder);
@@ -582,7 +598,8 @@ SoundFileBrowser::set_session (Session* s)
 {
        ArdourDialog::set_session (s);
        preview.set_session (s);
-       if (s) {
+
+       if (_session) {
                add_gain_meter ();
        } else {
                remove_gain_meter ();
@@ -594,9 +611,9 @@ SoundFileBrowser::add_gain_meter ()
 {
        delete gm;
 
-       gm = new GainMeter (*session, 250);
+       gm = new GainMeter (_session, 250);
 
-       boost::shared_ptr<Route> r = session->the_auditioner ();
+       boost::shared_ptr<Route> r = _session->the_auditioner ();
 
        gm->set_controls (r, r->shared_peak_meter(), r->amp());
 
@@ -633,7 +650,7 @@ SoundFileBrowser::stop_metering ()
 void
 SoundFileBrowser::meter ()
 {
-       if (is_mapped () && session && gm) {
+       if (is_mapped () && _session && gm) {
                gm->update_meters ();
        }
 }
@@ -906,7 +923,7 @@ SoundFileOmega::reset_options ()
        bool same_size;
        bool src_needed;
        bool selection_includes_multichannel;
-       bool selection_can_be_embedded_with_links = check_link_status (*session, paths);
+       bool selection_can_be_embedded_with_links = check_link_status (_session, paths);
        ImportMode mode;
 
        if (check_info (paths, same_size, src_needed, selection_includes_multichannel)) {
@@ -995,7 +1012,7 @@ SoundFileOmega::reset_options ()
                                channel_strings.push_back (_("sequence files"));
                        }
                        if (same_size) {
-                               channel_strings.push_back (_("all files in one region"));
+                               channel_strings.push_back (_("all files in one track"));
                        }
 
                }
@@ -1100,7 +1117,7 @@ SoundFileOmega::check_info (const vector<ustring>& paths, bool& same_size, bool&
                                }
                        }
 
-                       if ((nframes_t) info.samplerate != session->frame_rate()) {
+                       if ((nframes_t) info.samplerate != _session->frame_rate()) {
                                src_needed = true;
                        }
 
@@ -1126,9 +1143,9 @@ SoundFileOmega::check_info (const vector<ustring>& paths, bool& same_size, bool&
 
 
 bool
-SoundFileOmega::check_link_status (const Session& s, const vector<ustring>& paths)
+SoundFileOmega::check_link_status (const Session* s, const vector<ustring>& paths)
 {
-       sys::path path = s.session_directory().sound_path() / "linktest";
+       sys::path path = s->session_directory().sound_path() / "linktest";
        string tmpdir = path.to_string();
        bool ret = false;
 
@@ -1174,8 +1191,8 @@ SoundFileChooser::on_hide ()
        ArdourDialog::on_hide();
        stop_metering ();
 
-       if (session) {
-               session->cancel_audition();
+       if (_session) {
+               _session->cancel_audition();
        }
 }
 
@@ -1321,6 +1338,7 @@ SoundFileOmega::SoundFileOmega (Gtk::Window& parent, string title, ARDOUR::Sessi
        disposition_map.insert (pair<ustring,ImportDisposition>(_("one region per file"), ImportDistinctFiles));
        disposition_map.insert (pair<ustring,ImportDisposition>(_("one region per channel"), ImportDistinctChannels));
        disposition_map.insert (pair<ustring,ImportDisposition>(_("all files in one region"), ImportMergeFiles));
+       disposition_map.insert (pair<ustring,ImportDisposition>(_("all files in one track"), ImportMergeFiles));
 
        chooser.signal_selection_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::file_selection_changed));
 
@@ -1360,8 +1378,8 @@ void
 SoundFileOmega::on_hide ()
 {
        ArdourDialog::on_hide();
-       if (session) {
-               session->cancel_audition();
+       if (_session) {
+               _session->cancel_audition();
        }
 }