summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-11-09 22:18:52 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-11-09 22:18:52 +0000
commit84ddf22169c3aee19d3420b20c0e2f1b9bbdf02f (patch)
treebd0ea7e57c143d4d88abc957bafc3941a343d8a4 /gtk2_ardour
parent2575a3907b665e0ff3f151221e5c753c84d512ee (diff)
handle multiple imports of the same file better (via better source naming); make session properties editor pretty much work for search paths
git-svn-id: svn://localhost/ardour2/branches/3.0@7989 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor_audio_import.cc50
-rw-r--r--gtk2_ardour/search_path_option.cc16
-rw-r--r--gtk2_ardour/search_path_option.h2
-rw-r--r--gtk2_ardour/session_option_editor.cc2
4 files changed, 16 insertions, 54 deletions
diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc
index 506248a6c7..dadde038a8 100644
--- a/gtk2_ardour/editor_audio_import.cc
+++ b/gtk2_ardour/editor_audio_import.cc
@@ -218,19 +218,16 @@ Editor::check_whether_and_how_to_import(string path, bool all_or_nothing)
string wave_name (Glib::path_get_basename(path));
SourceMap all_sources = _session->get_sources();
- bool wave_name_exists = false;
+ bool already_exists = false;
+ uint32_t existing;
- 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;
- }
- }
+ if ((existing = _session->count_sources_by_origin (path)) > 0) {
+ already_exists = true;
+ }
int function = 1;
- if (wave_name_exists) {
+ if (already_exists) {
string message;
if (all_or_nothing) {
// updating is still disabled
@@ -508,41 +505,6 @@ int
Editor::import_sndfiles (vector<string> paths, ImportMode mode, SrcQuality quality, framepos_t& pos,
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
{
- /* check for existing wholefile regions of the same name,
- which can happen when we import foo.wav but end up with foo-L.wav
- and foo-R.wav inside the session. this case doesn't trigger
- source name collisions, so we have to catch it at the region
- name level.
- */
-
- string region_name = region_name_from_path (paths.front(), true, false);
-
- if (RegionFactory::wholefile_region_by_name (region_name)) {
- string message = string_compose ( _("You appear to have already imported this file, since a region called %1 already exists.\nDo you really want to import it again?"),
- region_name);
- MessageDialog dialog (message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_OK_CANCEL, true);
- int ret;
-
- dialog.show ();
- ret = dialog.run ();
- dialog.hide ();
-
- if (ret != RESPONSE_OK) {
- return -1;
- }
-
- int l = 0;
-
- while (RegionFactory::region_by_name (region_name) && ++l < 999) {
- region_name = bump_name_once (region_name, '.');
- }
-
- if (l == 999) {
- error << string_compose (_("Too many regions already named something like \"%1\""), paths.front()) << endmsg;
- return -1;
- }
- }
-
import_status.paths = paths;
import_status.done = false;
import_status.cancel = false;
diff --git a/gtk2_ardour/search_path_option.cc b/gtk2_ardour/search_path_option.cc
index be01b9b1aa..eff991081b 100644
--- a/gtk2_ardour/search_path_option.cc
+++ b/gtk2_ardour/search_path_option.cc
@@ -46,6 +46,8 @@ SearchPathOption::SearchPathOption (const string& pathname, const string& label,
session_label.set_markup (string_compose ("<i>%1</i>", _("the session folder")));
session_label.set_alignment (0.0, 0.5);
session_label.show ();
+
+ path_box.pack_start (session_label);
}
SearchPathOption::~SearchPathOption()
@@ -59,6 +61,7 @@ SearchPathOption::path_chosen ()
{
string path = add_chooser.get_filename ();
add_path (path);
+ changed ();
}
void
@@ -109,12 +112,6 @@ SearchPathOption::changed ()
for (list<PathEntry*>::iterator p = paths.begin(); p != paths.end(); ++p) {
- if (p == paths.begin()) {
- /* skip first entry, its always "the session"
- */
- continue;
- }
-
if (!str.empty()) {
str += ':';
}
@@ -130,11 +127,16 @@ SearchPathOption::add_path (const string& path, bool removable)
PathEntry* pe = new PathEntry (path, removable);
paths.push_back (pe);
path_box.pack_start (pe->box, false, false);
+ pe->remove_button.signal_clicked().connect (sigc::bind (sigc::mem_fun (*this, &SearchPathOption::remove_path), pe));
}
void
-SearchPathOption::remove_path (const string& path)
+SearchPathOption::remove_path (PathEntry* pe)
{
+ path_box.remove (pe->box);
+ paths.remove (pe);
+ delete pe;
+ changed ();
}
SearchPathOption::PathEntry::PathEntry (const std::string& path, bool removable)
diff --git a/gtk2_ardour/search_path_option.h b/gtk2_ardour/search_path_option.h
index 7163924b8c..68fb649481 100644
--- a/gtk2_ardour/search_path_option.h
+++ b/gtk2_ardour/search_path_option.h
@@ -42,7 +42,7 @@ class SearchPathOption : public Option
Gtk::Label session_label;
void add_path (const std::string& path, bool removable=true);
- void remove_path (const std::string& path);
+ void remove_path (PathEntry*);
void changed ();
void path_chosen ();
};
diff --git a/gtk2_ardour/session_option_editor.cc b/gtk2_ardour/session_option_editor.cc
index ec7ee86c8d..bef5c70433 100644
--- a/gtk2_ardour/session_option_editor.cc
+++ b/gtk2_ardour/session_option_editor.cc
@@ -209,8 +209,6 @@ SessionOptionEditor::SessionOptionEditor (Session* s)
add_option (_("Media"), hf);
- add_option (_("Media"), new OptionEditorHeading (_("Media Locations")));
-
SearchPathOption* spo = new SearchPathOption ("audio-search-path", _("Search for audio files in:"),
sigc::mem_fun (*_session_config, &SessionConfiguration::get_audio_search_path),
sigc::mem_fun (*_session_config, &SessionConfiguration::set_audio_search_path));