summaryrefslogtreecommitdiff
path: root/gtk2_ardour/sfdb_ui.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2007-08-27 15:20:29 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2007-08-27 15:20:29 +0000
commit218b893464e0b5f42eda2dec42fe2b5413d6b65f (patch)
tree9b7e8d9e4c187fdcedae79c1e91ea2e47a638d89 /gtk2_ardour/sfdb_ui.cc
parent8755c7124512613f4bfa74b13887285c64146747 (diff)
fix crashing mouse-button+'s' operation (generically, not just for 's'); more import changes to support SAE goals re: embedding
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2351 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/sfdb_ui.cc')
-rw-r--r--gtk2_ardour/sfdb_ui.cc66
1 files changed, 60 insertions, 6 deletions
diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc
index 5633edf306..79fcddc6d1 100644
--- a/gtk2_ardour/sfdb_ui.cc
+++ b/gtk2_ardour/sfdb_ui.cc
@@ -21,7 +21,9 @@
#include <cerrno>
#include <sstream>
+#include <unistd.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include <gtkmm/box.h>
#include <gtkmm/stock.h>
@@ -37,6 +39,7 @@
#include <ardour/audiofilesource.h>
#include <ardour/region_factory.h>
#include <ardour/source_factory.h>
+#include <ardour/profile.h>
#include "ardour_ui.h"
#include "editing.h"
@@ -71,8 +74,7 @@ SoundFileBox::SoundFileBox ()
set_size_request (250, 250);
Label* label = manage (new Label);
- label->set_use_markup (true);
- label->set_text (_("<b>Soundfile Info</b>"));
+ label->set_markup (_("<b>Soundfile Info</b>"));
border_frame.set_label_widget (*label);
border_frame.add (main_box);
@@ -503,7 +505,7 @@ SoundFileChooser::get_filename ()
}
-SoundFileOptionsDialog::SoundFileOptionsDialog (Window& parent, const vector<Glib::ustring>& p, int selected_tracks)
+SoundFileOptionsDialog::SoundFileOptionsDialog (Window& parent, const Session& s, const vector<Glib::ustring>& p, int selected_tracks)
: ArdourDialog (parent, _("External Audio Options"), false),
mode (ImportAsTrack),
paths (p),
@@ -515,9 +517,11 @@ SoundFileOptionsDialog::SoundFileOptionsDialog (Window& parent, const vector<Gli
as_tape_tracks (rgroup1, _("Add files as new tape tracks")),
import (rgroup2, _("Copy to Ardour-native files")),
embed (rgroup2, _("Use file without copying")),
+ session (s),
selected_track_cnt (selected_tracks)
{
selection_includes_multichannel = check_multichannel_status (paths);
+ selection_can_be_embedded_with_links = check_link_status (s, paths);
block_two.set_border_width (12);
block_three.set_border_width (12);
@@ -535,9 +539,22 @@ SoundFileOptionsDialog::SoundFileOptionsDialog (Window& parent, const vector<Gli
block_three.pack_start (merge_stereo, false, false);
block_three.pack_start (split_files, false, false);
-
- block_four.pack_start (import, false, false);
- block_four.pack_start (embed, false, false);
+
+ if (Profile->get_sae()) {
+ if (selection_can_be_embedded_with_links) {
+ block_four.pack_start (import, false, false);
+ block_four.pack_start (embed, false, false);
+ } else {
+ Label* message = manage (new Label);
+ message->set_text (string_compose (_("%1 will be imported into Ardour's native format"),
+ (selected_track_cnt > 1 ? "These files" : "This file")));
+
+ block_four.pack_start (*message, false, false);
+ }
+ } else {
+ block_four.pack_start (import, false, false);
+ block_four.pack_start (embed, false, false);
+ }
get_vbox()->set_spacing (12);
get_vbox()->pack_start (block_two, false, false);
@@ -604,3 +621,40 @@ SoundFileOptionsDialog::check_multichannel_status (const vector<Glib::ustring>&
return false;
}
+bool
+SoundFileOptionsDialog::check_link_status (const Session& s, const vector<Glib::ustring>& paths)
+{
+ string tmpdir = s.sound_dir();
+ bool ret = false;
+
+ tmpdir += "/linktest";
+
+ if (mkdir (tmpdir.c_str(), 0744)) {
+ if (errno != EEXIST) {
+ return false;
+ }
+ }
+
+ for (vector<Glib::ustring>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
+
+ char tmpc[MAXPATHLEN+1];
+
+ snprintf (tmpc, sizeof(tmpc), "%s/%s", tmpdir.c_str(), Glib::path_get_basename (*i).c_str());
+
+ /* can we link ? */
+
+ if (link ((*i).c_str(), tmpc)) {
+ goto out;
+ }
+
+ unlink (tmpc);
+ }
+
+ ret = true;
+
+ out:
+ rmdir (tmpdir.c_str());
+ return ret;
+}
+
+