Fix import dialogue to correctly report (x of N) with multiple files, and slightly prettify it. Partially fixes #3064.
git-svn-id: svn://localhost/ardour2/branches/3.0@6882 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
2a4f4e2763
commit
33028f4d6d
|
@ -1162,7 +1162,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
|||
void drop_paths_part_two (const std::vector<Glib::ustring>& paths, nframes64_t frame, double ypos);
|
||||
|
||||
int import_sndfiles (std::vector<Glib::ustring> paths, Editing::ImportMode mode, ARDOUR::SrcQuality, nframes64_t& pos,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool, uint32_t total);
|
||||
int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&, bool);
|
||||
int embed_sndfiles (std::vector<Glib::ustring> paths, bool multiple_files, bool& check_sample_rate, Editing::ImportMode mode,
|
||||
nframes64_t& pos, int target_regions, int target_tracks, boost::shared_ptr<ARDOUR::Track>&);
|
||||
|
||||
|
|
|
@ -326,10 +326,20 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
vector<ustring> to_import;
|
||||
int nth = 0;
|
||||
|
||||
current_interthread_info = &import_status;
|
||||
import_status.current = 1;
|
||||
import_status.total = paths.size ();
|
||||
|
||||
if (interthread_progress_window == 0) {
|
||||
build_interthread_progress_window ();
|
||||
}
|
||||
|
||||
interthread_progress_window->set_title (_("Import"));
|
||||
interthread_progress_bar.set_fraction (0.0f);
|
||||
interthread_cancel_label.set_text (_("Cancel Import"));
|
||||
interthread_progress_connection = Glib::signal_timeout().connect
|
||||
(sigc::bind (sigc::mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 500);
|
||||
|
||||
if (chns == Editing::ImportMergeFiles) {
|
||||
|
||||
/* create 1 region from all paths, add to 1 track,
|
||||
|
@ -346,14 +356,13 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
}
|
||||
|
||||
if (!cancel) {
|
||||
import_sndfiles (paths, mode, quality, pos, 1, 1, track, false, paths.size());
|
||||
import_sndfiles (paths, mode, quality, pos, 1, 1, track, false);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
bool replace = false;
|
||||
bool ok = true;
|
||||
vector<ustring>::size_type total = paths.size();
|
||||
|
||||
for (vector<ustring>::iterator a = paths.begin(); a != paths.end(); ++a) {
|
||||
|
||||
|
@ -385,7 +394,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
track = get_nth_selected_audio_track (nth++);
|
||||
}
|
||||
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, -1, track, replace, total) == 0);
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, -1, track, replace) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportDistinctChannels:
|
||||
|
@ -393,7 +402,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, -1, -1, track, replace, total) == 0);
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, -1, -1, track, replace) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportSerializeFiles:
|
||||
|
@ -401,7 +410,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
to_import.clear ();
|
||||
to_import.push_back (*a);
|
||||
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, 1, track, replace, total) == 0);
|
||||
ok = (import_sndfiles (to_import, mode, quality, pos, 1, 1, track, replace) == 0);
|
||||
break;
|
||||
|
||||
case Editing::ImportMergeFiles:
|
||||
|
@ -412,6 +421,7 @@ Editor::do_import (vector<ustring> paths, ImportDisposition chns, ImportMode mod
|
|||
}
|
||||
|
||||
interthread_progress_window->hide_all ();
|
||||
interthread_progress_connection.disconnect ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -482,14 +492,8 @@ Editor::do_embed (vector<ustring> paths, ImportDisposition chns, ImportMode mode
|
|||
|
||||
int
|
||||
Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality quality, nframes64_t& pos,
|
||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace, uint32_t total)
|
||||
int target_regions, int target_tracks, boost::shared_ptr<Track>& track, bool replace)
|
||||
{
|
||||
interthread_progress_window->set_title (string_compose (_("Importing %1"), paths.front()));
|
||||
interthread_progress_window->set_position (Gtk::WIN_POS_MOUSE);
|
||||
interthread_progress_bar.set_fraction (0.0f);
|
||||
interthread_cancel_label.set_text (_("Cancel Import"));
|
||||
current_interthread_info = &import_status;
|
||||
|
||||
import_status.paths = paths;
|
||||
import_status.done = false;
|
||||
import_status.cancel = false;
|
||||
|
@ -497,7 +501,6 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality qual
|
|||
import_status.done = 0.0;
|
||||
import_status.quality = quality;
|
||||
import_status.replace_existing_source = replace;
|
||||
import_status.total = total;
|
||||
|
||||
import_status.mode = mode;
|
||||
import_status.pos = pos;
|
||||
|
@ -505,8 +508,6 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality qual
|
|||
import_status.target_regions = target_regions;
|
||||
import_status.track = track;
|
||||
import_status.replace = replace;
|
||||
interthread_progress_connection = Glib::signal_timeout().connect
|
||||
(sigc::bind (sigc::mem_fun(*this, &Editor::import_progress_timeout), (gpointer) 0), 500);
|
||||
|
||||
track_canvas->get_window()->set_cursor (Gdk::Cursor (Gdk::WATCH));
|
||||
gdk_flush ();
|
||||
|
@ -523,9 +524,7 @@ Editor::import_sndfiles (vector<ustring> paths, ImportMode mode, SrcQuality qual
|
|||
gtk_main_iteration ();
|
||||
}
|
||||
|
||||
interthread_progress_window->hide ();
|
||||
import_status.done = true;
|
||||
interthread_progress_connection.disconnect ();
|
||||
|
||||
if (!import_status.cancel && !import_status.sources.empty()) {
|
||||
if (add_sources (import_status.paths,
|
||||
|
@ -949,7 +948,7 @@ Editor::import_progress_timeout (void */*arg*/)
|
|||
reset = true;
|
||||
}
|
||||
|
||||
interthread_progress_label.set_text (import_status.doing_what);
|
||||
interthread_progress_label.set_markup (import_status.doing_what);
|
||||
|
||||
if (import_status.freeze) {
|
||||
interthread_cancel_button.set_sensitive(false);
|
||||
|
|
|
@ -2612,7 +2612,8 @@ Editor::build_interthread_progress_window ()
|
|||
interthread_progress_window->set_border_width (12);
|
||||
interthread_progress_window->get_vbox()->set_spacing (6);
|
||||
|
||||
interthread_progress_label.set_alignment (0.5, 0.5);
|
||||
interthread_progress_label.set_alignment (0, 0.5);
|
||||
interthread_progress_label.set_use_markup (true);
|
||||
|
||||
interthread_progress_window->get_vbox()->pack_start (interthread_progress_label, false, false);
|
||||
interthread_progress_window->get_vbox()->pack_start (interthread_progress_bar,false, false);
|
||||
|
|
|
@ -33,6 +33,7 @@ struct ImportStatus : public InterThreadInfo {
|
|||
std::string doing_what;
|
||||
|
||||
/* control info */
|
||||
uint32_t current;
|
||||
uint32_t total;
|
||||
SrcQuality quality;
|
||||
volatile bool freeze;
|
||||
|
|
|
@ -250,14 +250,14 @@ compose_status_message (const string& path,
|
|||
uint total_files)
|
||||
{
|
||||
if (file_samplerate != session_samplerate) {
|
||||
return string_compose (_("resampling %1 from %2kHz to %3kHz\n(%4 of %5)"),
|
||||
Glib::path_get_basename (path),
|
||||
return string_compose (_("<b>Resampling</b> from %1kHz to %2kHz.\n<i>%3</i>\n(%4 of %5)"),
|
||||
file_samplerate/1000.0f,
|
||||
session_samplerate/1000.0f,
|
||||
Glib::path_get_basename (path),
|
||||
current_file, total_files);
|
||||
}
|
||||
|
||||
return string_compose (_("copying %1\n(%2 of %3)"),
|
||||
return string_compose (_("<b>Copying</b>\n<i>%1</i>\n(%2 of %3)"),
|
||||
Glib::path_get_basename (path),
|
||||
current_file, total_files);
|
||||
}
|
||||
|
@ -442,7 +442,6 @@ remove_file_source (boost::shared_ptr<Source> source)
|
|||
void
|
||||
Session::import_audiofiles (ImportStatus& status)
|
||||
{
|
||||
uint32_t cnt = 1;
|
||||
typedef vector<boost::shared_ptr<Source> > Sources;
|
||||
Sources all_new_sources;
|
||||
boost::shared_ptr<AudioFileSource> afs;
|
||||
|
@ -452,8 +451,8 @@ Session::import_audiofiles (ImportStatus& status)
|
|||
status.sources.clear ();
|
||||
|
||||
for (vector<Glib::ustring>::iterator p = status.paths.begin();
|
||||
p != status.paths.end() && !status.cancel;
|
||||
++p, ++cnt)
|
||||
p != status.paths.end() && !status.cancel;
|
||||
++p)
|
||||
{
|
||||
boost::shared_ptr<ImportableSource> source;
|
||||
std::auto_ptr<Evoral::SMF> smf_reader;
|
||||
|
@ -510,12 +509,14 @@ Session::import_audiofiles (ImportStatus& status)
|
|||
|
||||
if (source) { // audio
|
||||
status.doing_what = compose_status_message (*p, source->samplerate(),
|
||||
frame_rate(), cnt, status.total);
|
||||
frame_rate(), status.current, status.total);
|
||||
write_audio_data_to_new_files (source.get(), status, newfiles);
|
||||
} else if (smf_reader.get()) { // midi
|
||||
status.doing_what = string_compose(_("Loading MIDI file %1"), *p);
|
||||
write_midi_data_to_new_files (smf_reader.get(), status, newfiles);
|
||||
}
|
||||
|
||||
++status.current;
|
||||
}
|
||||
|
||||
if (!status.cancel) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user