2005-10-27 15:46:27 -04:00
|
|
|
/*
|
2006-12-01 01:01:30 -05:00
|
|
|
Copyright (C) 2005-2006 Paul Davis
|
2005-10-27 15:46:27 -04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-01-11 16:27:59 -05:00
|
|
|
#include <map>
|
2006-01-13 14:48:55 -05:00
|
|
|
#include <cerrno>
|
2006-12-01 01:01:30 -05:00
|
|
|
#include <sstream>
|
2006-01-11 16:27:59 -05:00
|
|
|
|
2005-10-12 23:48:57 -04:00
|
|
|
#include <gtkmm/box.h>
|
|
|
|
#include <gtkmm/stock.h>
|
|
|
|
|
2006-04-25 16:23:50 -04:00
|
|
|
#include <pbd/convert.h>
|
2007-01-04 23:24:23 -05:00
|
|
|
#include <pbd/tokenizer.h>
|
2006-12-01 01:01:30 -05:00
|
|
|
#include <pbd/whitespace.h>
|
2006-03-22 12:03:00 -05:00
|
|
|
|
|
|
|
#include <gtkmm2ext/utils.h>
|
|
|
|
|
2005-10-12 23:48:57 -04:00
|
|
|
#include <ardour/audio_library.h>
|
2006-01-11 16:27:59 -05:00
|
|
|
#include <ardour/audioregion.h>
|
2006-06-14 17:17:32 -04:00
|
|
|
#include <ardour/audiofilesource.h>
|
2006-08-24 21:07:15 -04:00
|
|
|
#include <ardour/region_factory.h>
|
2006-08-28 20:23:45 -04:00
|
|
|
#include <ardour/source_factory.h>
|
2005-10-12 23:48:57 -04:00
|
|
|
|
2006-04-11 23:09:25 -04:00
|
|
|
#include "ardour_ui.h"
|
2006-08-31 21:59:41 -04:00
|
|
|
#include "editing.h"
|
2006-01-11 16:27:59 -05:00
|
|
|
#include "gui_thread.h"
|
2006-01-13 14:48:55 -05:00
|
|
|
#include "prompter.h"
|
|
|
|
#include "sfdb_ui.h"
|
2006-03-22 12:03:00 -05:00
|
|
|
#include "utils.h"
|
2005-10-12 16:06:20 -04:00
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2006-01-11 16:27:59 -05:00
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2006-03-22 12:03:00 -05:00
|
|
|
using namespace std;
|
2006-01-11 16:27:59 -05:00
|
|
|
|
2006-01-04 00:53:51 -05:00
|
|
|
SoundFileBox::SoundFileBox ()
|
2005-12-07 17:57:47 -05:00
|
|
|
:
|
2006-01-04 00:53:51 -05:00
|
|
|
_session(0),
|
2005-12-07 17:57:47 -05:00
|
|
|
current_pid(0),
|
|
|
|
main_box (false, 3),
|
|
|
|
bottom_box (true, 4),
|
|
|
|
play_btn(_("Play")),
|
|
|
|
stop_btn(_("Stop")),
|
2006-12-01 01:01:30 -05:00
|
|
|
apply_btn(_("Apply"))
|
2005-12-07 17:57:47 -05:00
|
|
|
{
|
|
|
|
set_name (X_("SoundFileBox"));
|
2007-01-04 23:24:23 -05:00
|
|
|
|
|
|
|
set_size_request (250, 500);
|
|
|
|
|
2005-12-07 17:57:47 -05:00
|
|
|
border_frame.set_label (_("Soundfile Info"));
|
|
|
|
border_frame.add (main_box);
|
|
|
|
|
|
|
|
pack_start (border_frame);
|
|
|
|
set_border_width (4);
|
|
|
|
|
2005-12-07 23:55:46 -05:00
|
|
|
main_box.set_border_width (4);
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2005-12-07 23:55:46 -05:00
|
|
|
main_box.pack_start(length, false, false);
|
|
|
|
main_box.pack_start(format, false, false);
|
|
|
|
main_box.pack_start(channels, false, false);
|
|
|
|
main_box.pack_start(samplerate, false, false);
|
2006-11-13 12:56:43 -05:00
|
|
|
main_box.pack_start(timecode, false, false);
|
2006-12-01 01:01:30 -05:00
|
|
|
main_box.pack_start(tags_entry, true, true);
|
2007-01-04 23:24:23 -05:00
|
|
|
main_box.pack_start(apply_btn, false, false);
|
2005-12-07 23:55:46 -05:00
|
|
|
main_box.pack_start(bottom_box, false, false);
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2005-12-07 23:55:46 -05:00
|
|
|
bottom_box.set_homogeneous(true);
|
|
|
|
bottom_box.pack_start(play_btn);
|
|
|
|
bottom_box.pack_start(stop_btn);
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
// tags_entry.signal_focus_out_event().connect (mem_fun (*this, &SoundFileBox::tags_entry_left));
|
2005-12-07 23:55:46 -05:00
|
|
|
play_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::play_btn_clicked));
|
|
|
|
stop_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::stop_btn_clicked));
|
2006-12-01 01:01:30 -05:00
|
|
|
apply_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::apply_btn_clicked));
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
length.set_alignment (0.0f, 0.0f);
|
|
|
|
format.set_alignment (0.0f, 0.0f);
|
|
|
|
channels.set_alignment (0.0f, 0.0f);
|
|
|
|
samplerate.set_alignment (0.0f, 0.0f);
|
|
|
|
timecode.set_alignment (0.0f, 0.0f);
|
|
|
|
|
|
|
|
stop_btn.set_no_show_all (true);
|
2005-12-07 23:55:46 -05:00
|
|
|
stop_btn.hide();
|
2007-01-04 23:24:23 -05:00
|
|
|
|
|
|
|
show_all();
|
2005-12-07 17:57:47 -05:00
|
|
|
}
|
|
|
|
|
2006-01-04 00:53:51 -05:00
|
|
|
void
|
2006-01-11 16:27:59 -05:00
|
|
|
SoundFileBox::set_session(Session* s)
|
2006-01-04 00:53:51 -05:00
|
|
|
{
|
|
|
|
_session = s;
|
|
|
|
|
2006-04-11 23:09:25 -04:00
|
|
|
if (!_session) {
|
2006-01-04 00:53:51 -05:00
|
|
|
play_btn.set_sensitive(false);
|
|
|
|
} else {
|
|
|
|
_session->AuditionActive.connect(mem_fun (*this, &SoundFileBox::audition_status_changed));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-05 00:15:29 -05:00
|
|
|
bool
|
2005-12-07 17:57:47 -05:00
|
|
|
SoundFileBox::setup_labels (string filename)
|
2005-12-07 23:55:46 -05:00
|
|
|
{
|
2006-01-11 16:27:59 -05:00
|
|
|
path = filename;
|
|
|
|
|
2006-03-10 12:09:59 -05:00
|
|
|
string error_msg;
|
2006-11-13 12:56:43 -05:00
|
|
|
|
2006-06-14 17:17:32 -04:00
|
|
|
if(!AudioFileSource::get_soundfile_info (filename, sf_info, error_msg)) {
|
2007-01-04 23:24:23 -05:00
|
|
|
length.set_text (_("Length: n/a"));
|
|
|
|
format.set_text (_("Format: n/a"));
|
|
|
|
channels.set_text (_("Channels: n/a"));
|
|
|
|
samplerate.set_text (_("Samplerate: n/a"));
|
|
|
|
timecode.set_text (_("Timecode: n/a"));
|
|
|
|
tags_entry.set_text ("");
|
|
|
|
|
|
|
|
tags_entry.set_sensitive (false);
|
|
|
|
play_btn.set_sensitive (false);
|
|
|
|
apply_btn.set_sensitive (false);
|
|
|
|
|
2006-03-08 17:24:51 -05:00
|
|
|
return false;
|
2005-12-07 23:55:46 -05:00
|
|
|
}
|
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
length.set_text (string_compose(_("Length: %1"), length2string(sf_info.length, sf_info.samplerate)));
|
2006-03-08 17:24:51 -05:00
|
|
|
format.set_text (sf_info.format_name);
|
2006-11-13 12:56:43 -05:00
|
|
|
channels.set_text (string_compose(_("Channels: %1"), sf_info.channels));
|
|
|
|
samplerate.set_text (string_compose(_("Samplerate: %1"), sf_info.samplerate));
|
2006-12-01 01:01:30 -05:00
|
|
|
timecode.set_text (string_compose (_("Timecode: %1"), length2string(sf_info.timecode, sf_info.samplerate)));
|
2006-01-11 16:27:59 -05:00
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
vector<string> tags = Library->get_tags (filename);
|
|
|
|
|
|
|
|
stringstream tag_string;
|
|
|
|
for (vector<string>::iterator i = tags.begin(); i != tags.end(); ++i) {
|
|
|
|
if (i != tags.begin()) {
|
|
|
|
tag_string << ", ";
|
|
|
|
}
|
|
|
|
tag_string << *i;
|
|
|
|
}
|
|
|
|
tags_entry.set_text (tag_string.str());
|
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
tags_entry.set_sensitive (true);
|
|
|
|
if (_session) {
|
|
|
|
play_btn.set_sensitive (true);
|
|
|
|
}
|
|
|
|
apply_btn.set_sensitive (true);
|
|
|
|
|
2006-01-05 00:15:29 -05:00
|
|
|
return true;
|
2005-12-07 23:55:46 -05:00
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
bool
|
|
|
|
SoundFileBox::tags_entry_left (GdkEventFocus* event)
|
|
|
|
{
|
|
|
|
apply_btn_clicked ();
|
|
|
|
|
|
|
|
return true;
|
2006-01-11 16:27:59 -05:00
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
SoundFileBox::play_btn_clicked ()
|
2006-01-11 16:27:59 -05:00
|
|
|
{
|
|
|
|
if (!_session) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_session->cancel_audition();
|
|
|
|
|
|
|
|
if (access(path.c_str(), R_OK)) {
|
|
|
|
warning << string_compose(_("Could not read file: %1 (%2)."), path, strerror(errno)) << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-11-06 11:05:59 -05:00
|
|
|
typedef std::map<string, boost::shared_ptr<AudioRegion> > RegionCache;
|
|
|
|
static RegionCache region_cache;
|
|
|
|
RegionCache::iterator the_region;
|
2006-01-11 16:27:59 -05:00
|
|
|
|
2006-11-06 11:05:59 -05:00
|
|
|
if ((the_region = region_cache.find (path)) == region_cache.end()) {
|
2006-08-24 21:07:15 -04:00
|
|
|
SourceList srclist;
|
2006-08-28 20:23:45 -04:00
|
|
|
boost::shared_ptr<AudioFileSource> afs;
|
|
|
|
|
2006-01-11 16:27:59 -05:00
|
|
|
for (int n = 0; n < sf_info.channels; ++n) {
|
|
|
|
try {
|
2006-09-07 11:07:14 -04:00
|
|
|
afs = boost::dynamic_pointer_cast<AudioFileSource> (SourceFactory::createReadable (*_session, path+":"+string_compose("%1", n), AudioFileSource::Flag (0)));
|
2006-06-14 17:17:32 -04:00
|
|
|
srclist.push_back(afs);
|
2006-01-11 16:27:59 -05:00
|
|
|
|
|
|
|
} catch (failed_constructor& err) {
|
|
|
|
error << _("Could not access soundfile: ") << path << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (srclist.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-11-06 11:16:24 -05:00
|
|
|
string rname;
|
2006-08-24 21:07:15 -04:00
|
|
|
|
2006-11-06 11:16:24 -05:00
|
|
|
_session->region_name (rname, Glib::path_get_basename(srclist[0]->name()), false);
|
2006-08-24 21:07:15 -04:00
|
|
|
|
2006-11-06 11:16:24 -05:00
|
|
|
pair<string,boost::shared_ptr<AudioRegion> > newpair;
|
2006-11-06 11:05:59 -05:00
|
|
|
pair<RegionCache::iterator,bool> res;
|
|
|
|
|
2006-11-06 11:16:24 -05:00
|
|
|
newpair.first = path;
|
|
|
|
newpair.second = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0, srclist[0]->length(), rname, 0, Region::DefaultFlags, false));
|
|
|
|
|
2006-11-06 11:05:59 -05:00
|
|
|
res = region_cache.insert (newpair);
|
|
|
|
the_region = res.first;
|
2006-01-11 16:27:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
play_btn.hide();
|
|
|
|
stop_btn.show();
|
|
|
|
|
2006-11-06 11:05:59 -05:00
|
|
|
boost::shared_ptr<Region> r = boost::static_pointer_cast<Region> (the_region->second);
|
|
|
|
|
|
|
|
_session->audition_region(r);
|
2006-01-11 16:27:59 -05:00
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
|
|
|
|
void
|
|
|
|
SoundFileBox::stop_btn_clicked ()
|
2006-01-11 16:27:59 -05:00
|
|
|
{
|
|
|
|
if (_session) {
|
|
|
|
_session->cancel_audition();
|
|
|
|
play_btn.show();
|
|
|
|
stop_btn.hide();
|
|
|
|
}
|
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
|
|
|
|
void
|
2006-12-01 01:01:30 -05:00
|
|
|
SoundFileBox::apply_btn_clicked ()
|
2006-01-18 16:05:59 -05:00
|
|
|
{
|
2006-12-01 01:01:30 -05:00
|
|
|
string tag_string = tags_entry.get_text ();
|
2006-01-18 16:05:59 -05:00
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
vector<string> tags;
|
2006-01-18 16:05:59 -05:00
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
if (!PBD::tokenize (tag_string, string(","), std::back_inserter (tags), true)) {
|
|
|
|
warning << _("SoundFileBox: Could not tokenize string: ") << tag_string << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
2006-08-31 12:34:42 -04:00
|
|
|
|
2006-12-01 01:01:30 -05:00
|
|
|
Library->set_tags (path, tags);
|
2006-07-26 23:30:03 -04:00
|
|
|
Library->save_changes ();
|
|
|
|
}
|
|
|
|
|
2005-12-07 17:57:47 -05:00
|
|
|
void
|
2006-01-11 16:27:59 -05:00
|
|
|
SoundFileBox::audition_status_changed (bool active)
|
|
|
|
{
|
2006-03-22 12:03:00 -05:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun (*this, &SoundFileBox::audition_status_changed), active));
|
|
|
|
|
2006-01-11 16:27:59 -05:00
|
|
|
if (!active) {
|
|
|
|
stop_btn_clicked ();
|
|
|
|
}
|
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2006-08-31 21:59:41 -04:00
|
|
|
// this needs to be kept in sync with the ImportMode enum defined in editing.h and editing_syms.h.
|
|
|
|
static const char *import_mode_strings[] = {
|
2006-10-17 21:41:40 -04:00
|
|
|
N_("Add to Region list"),
|
|
|
|
N_("Add to selected Track(s)"),
|
|
|
|
N_("Add as new Track(s)"),
|
|
|
|
N_("Add as new Tape Track(s)"),
|
2006-08-31 21:59:41 -04:00
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2006-05-07 13:17:38 -04:00
|
|
|
SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s)
|
2006-03-22 12:03:00 -05:00
|
|
|
: ArdourDialog (title, false),
|
2007-01-04 23:24:23 -05:00
|
|
|
chooser (Gtk::FILE_CHOOSER_ACTION_OPEN),
|
|
|
|
found_list (Gtk::ListStore::create(found_list_columns)),
|
|
|
|
found_list_view (found_list),
|
|
|
|
found_search_btn (_("Search"))
|
2005-10-12 23:48:57 -04:00
|
|
|
{
|
2006-12-01 01:01:30 -05:00
|
|
|
set_default_size (700, 500);
|
2007-01-04 23:24:23 -05:00
|
|
|
Gtk::HBox* hbox = manage(new Gtk::HBox);
|
|
|
|
hbox->pack_start(notebook);
|
|
|
|
hbox->pack_start(preview, Gtk::PACK_SHRINK);
|
|
|
|
get_vbox()->pack_start(*hbox);
|
|
|
|
|
|
|
|
hbox = manage(new Gtk::HBox);
|
|
|
|
hbox->pack_start (found_entry);
|
|
|
|
hbox->pack_start (found_search_btn);
|
|
|
|
|
|
|
|
Gtk::VBox* vbox = manage(new Gtk::VBox);
|
|
|
|
vbox->pack_start (*hbox, Gtk::PACK_SHRINK);
|
|
|
|
vbox->pack_start (found_list_view);
|
|
|
|
found_list_view.append_column(_("Paths"), found_list_columns.pathname);
|
|
|
|
|
|
|
|
notebook.append_page (chooser, _("Files"));
|
|
|
|
notebook.append_page (*vbox, _("Tags"));
|
2005-12-07 17:57:47 -05:00
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
filter.add_custom (Gtk::FILE_FILTER_FILENAME, mem_fun(*this, &SoundFileBrowser::on_custom));
|
|
|
|
chooser.set_filter (filter);
|
|
|
|
chooser.set_select_multiple (true);
|
2005-12-07 17:57:47 -05:00
|
|
|
chooser.signal_update_preview().connect(mem_fun(*this, &SoundFileBrowser::update_preview));
|
2007-01-04 23:24:23 -05:00
|
|
|
found_list_view.get_selection()->signal_changed().connect(mem_fun(*this, &SoundFileBrowser::found_list_view_selected));
|
|
|
|
|
|
|
|
found_search_btn.signal_clicked().connect(mem_fun(*this, &SoundFileBrowser::found_search_clicked));
|
2006-05-07 13:17:38 -04:00
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
show_all ();
|
|
|
|
|
2006-05-07 13:17:38 -04:00
|
|
|
set_session (s);
|
2006-01-04 00:53:51 -05:00
|
|
|
}
|
2005-12-02 17:12:56 -05:00
|
|
|
|
2006-01-04 00:53:51 -05:00
|
|
|
void
|
2006-01-11 16:27:59 -05:00
|
|
|
SoundFileBrowser::set_session (Session* s)
|
2006-01-04 00:53:51 -05:00
|
|
|
{
|
|
|
|
preview.set_session(s);
|
2005-10-12 23:48:57 -04:00
|
|
|
}
|
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
bool
|
|
|
|
SoundFileBrowser::on_custom (const Gtk::FileFilter::Info& filter_info)
|
|
|
|
{
|
|
|
|
return AudioFileSource::safe_file_extension(filter_info.filename);
|
|
|
|
}
|
|
|
|
|
2005-12-07 17:57:47 -05:00
|
|
|
void
|
|
|
|
SoundFileBrowser::update_preview ()
|
|
|
|
{
|
2007-01-04 23:24:23 -05:00
|
|
|
preview.setup_labels(chooser.get_filename());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SoundFileBrowser::found_list_view_selected ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SoundFileBrowser::found_search_clicked ()
|
|
|
|
{
|
|
|
|
string tag_string = found_entry.get_text ();
|
|
|
|
|
|
|
|
vector<string> tags;
|
|
|
|
|
|
|
|
if (!PBD::tokenize (tag_string, string(","), std::back_inserter (tags), true)) {
|
|
|
|
warning << _("SoundFileBox: Could not tokenize string: ") << tag_string << endmsg;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<string> results;
|
|
|
|
Library->search_members_and (results, tags);
|
|
|
|
|
|
|
|
found_list->clear();
|
|
|
|
for (vector<string>::iterator i = results.begin(); i != results.end(); ++i) {
|
|
|
|
Gtk::TreeModel::iterator new_row = found_list->append();
|
|
|
|
Gtk::TreeModel::Row row = *new_row;
|
|
|
|
cout << *i << endl;
|
|
|
|
row[found_list_columns.pathname] = *i;
|
|
|
|
}
|
2005-12-07 17:57:47 -05:00
|
|
|
}
|
|
|
|
|
2006-05-07 13:17:38 -04:00
|
|
|
SoundFileChooser::SoundFileChooser (string title, ARDOUR::Session* s)
|
2005-10-12 23:48:57 -04:00
|
|
|
:
|
2006-05-07 13:17:38 -04:00
|
|
|
SoundFileBrowser(title, s)
|
2005-10-12 23:48:57 -04:00
|
|
|
{
|
|
|
|
add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
|
|
|
|
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
|
2007-01-04 23:24:23 -05:00
|
|
|
|
2006-01-05 00:15:29 -05:00
|
|
|
show_all ();
|
2005-10-12 23:48:57 -04:00
|
|
|
}
|
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
vector<string> SoundFileOmega::mode_strings;
|
|
|
|
|
2006-05-07 13:17:38 -04:00
|
|
|
SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s)
|
|
|
|
: SoundFileBrowser (title, s),
|
2006-03-22 12:03:00 -05:00
|
|
|
split_check (_("Split Channels"))
|
2005-10-12 23:48:57 -04:00
|
|
|
{
|
2007-01-04 23:24:23 -05:00
|
|
|
// add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
|
2006-03-22 12:03:00 -05:00
|
|
|
|
2006-04-11 23:09:25 -04:00
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(split_check,
|
|
|
|
_("Create a region for each channel"));
|
|
|
|
|
|
|
|
Gtk::Button* btn = add_button (_("Embed"), ResponseEmbed);
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(*btn,
|
|
|
|
_("Link to an external file"));
|
|
|
|
|
|
|
|
btn = add_button (_("Import"), ResponseImport);
|
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(*btn,
|
|
|
|
_("Copy a file to the session folder"));
|
2007-01-04 23:24:23 -05:00
|
|
|
|
|
|
|
if (mode_strings.empty()) {
|
|
|
|
mode_strings = I18N (import_mode_strings);
|
|
|
|
}
|
2006-03-22 12:03:00 -05:00
|
|
|
Gtkmm2ext::set_popdown_strings (mode_combo, mode_strings);
|
|
|
|
|
|
|
|
set_mode (Editing::ImportAsRegion);
|
2005-10-12 23:48:57 -04:00
|
|
|
|
2007-01-04 23:24:23 -05:00
|
|
|
get_action_area()->pack_start (split_check);
|
|
|
|
get_action_area()->pack_start (mode_combo);
|
2006-01-05 00:15:29 -05:00
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
mode_combo.signal_changed().connect (mem_fun (*this, &SoundFileOmega::mode_changed));
|
|
|
|
|
2006-01-05 00:15:29 -05:00
|
|
|
show_all ();
|
2005-10-12 23:48:57 -04:00
|
|
|
}
|
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
bool
|
|
|
|
SoundFileOmega::get_split ()
|
|
|
|
{
|
|
|
|
return split_check.get_active();
|
|
|
|
}
|
|
|
|
|
|
|
|
vector<Glib::ustring>
|
|
|
|
SoundFileOmega::get_paths ()
|
2005-10-12 23:48:57 -04:00
|
|
|
{
|
2006-03-22 12:03:00 -05:00
|
|
|
return chooser.get_filenames();
|
2005-10-12 23:48:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-03-22 12:03:00 -05:00
|
|
|
SoundFileOmega::set_mode (Editing::ImportMode mode)
|
2005-10-12 23:48:57 -04:00
|
|
|
{
|
2006-03-22 12:03:00 -05:00
|
|
|
mode_combo.set_active_text (mode_strings[(int)mode]);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case Editing::ImportAsRegion:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
|
|
|
case Editing::ImportAsTrack:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
|
|
|
case Editing::ImportToTrack:
|
|
|
|
split_check.set_sensitive (false);
|
|
|
|
break;
|
2006-07-27 12:52:14 -04:00
|
|
|
case Editing::ImportAsTapeTrack:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
2006-03-22 12:03:00 -05:00
|
|
|
}
|
2005-10-12 23:48:57 -04:00
|
|
|
}
|
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
Editing::ImportMode
|
|
|
|
SoundFileOmega::get_mode ()
|
2005-12-07 23:55:46 -05:00
|
|
|
{
|
2006-03-22 12:03:00 -05:00
|
|
|
vector<string>::iterator i;
|
|
|
|
uint32_t n;
|
|
|
|
string str = mode_combo.get_active_text ();
|
2005-12-07 23:55:46 -05:00
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
for (n = 0, i = mode_strings.begin (); i != mode_strings.end(); ++i, ++n) {
|
|
|
|
if (str == (*i)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-12-07 23:55:46 -05:00
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
if (i == mode_strings.end()) {
|
|
|
|
fatal << string_compose (_("programming error: %1"), X_("unknown import mode string")) << endmsg;
|
|
|
|
/*NOTREACHED*/
|
|
|
|
}
|
2005-12-07 23:55:46 -05:00
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
return (Editing::ImportMode) (n);
|
2005-12-07 23:55:46 -05:00
|
|
|
}
|
|
|
|
|
2006-03-22 12:03:00 -05:00
|
|
|
void
|
|
|
|
SoundFileOmega::mode_changed ()
|
|
|
|
{
|
|
|
|
Editing::ImportMode mode = get_mode();
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case Editing::ImportAsRegion:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
|
|
|
case Editing::ImportAsTrack:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
|
|
|
case Editing::ImportToTrack:
|
|
|
|
split_check.set_sensitive (false);
|
|
|
|
break;
|
2006-07-27 12:52:14 -04:00
|
|
|
case Editing::ImportAsTapeTrack:
|
|
|
|
split_check.set_sensitive (true);
|
|
|
|
break;
|
2006-03-22 12:03:00 -05:00
|
|
|
}
|
|
|
|
}
|