/*
- Copyright (C) 2005 Paul Davis
- Written by Taybin Rutkin
+ Copyright (C) 2005-2006 Paul Davis
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
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
*/
#include <map>
#include <cerrno>
+#include <sstream>
#include <gtkmm/box.h>
#include <gtkmm/stock.h>
#include <pbd/convert.h>
+#include <pbd/whitespace.h>
#include <gtkmm2ext/utils.h>
:
_session(0),
current_pid(0),
- fields(Gtk::ListStore::create(label_columns)),
main_box (false, 3),
top_box (true, 4),
bottom_box (true, 4),
play_btn(_("Play")),
stop_btn(_("Stop")),
- add_field_btn(_("Add Field...")),
- remove_field_btn(_("Remove Field"))
+ apply_btn(_("Apply"))
{
set_name (X_("SoundFileBox"));
border_frame.set_label (_("Soundfile Info"));
main_box.pack_start(format, false, false);
main_box.pack_start(channels, false, false);
main_box.pack_start(samplerate, false, false);
- main_box.pack_start(field_view, true, true);
+ main_box.pack_start(timecode, false, false);
+ main_box.pack_start(tags_entry, true, true);
main_box.pack_start(top_box, false, false);
main_box.pack_start(bottom_box, false, false);
- field_view.set_model (fields);
- field_view.set_size_request(200, 150);
- field_view.append_column (_("Field"), label_columns.field);
- field_view.append_column_editable (_("Value"), label_columns.data);
-
top_box.set_homogeneous(true);
- top_box.pack_start(add_field_btn);
- top_box.pack_start(remove_field_btn);
-
- remove_field_btn.set_sensitive(false);
+ top_box.pack_start(apply_btn);
bottom_box.set_homogeneous(true);
bottom_box.pack_start(play_btn);
bottom_box.pack_start(stop_btn);
+// tags_entry.signal_focus_out_event().connect (mem_fun (*this, &SoundFileBox::tags_entry_left));
play_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::play_btn_clicked));
stop_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::stop_btn_clicked));
-
- add_field_btn.signal_clicked().connect
- (mem_fun (*this, &SoundFileBox::add_field_clicked));
- remove_field_btn.signal_clicked().connect
- (mem_fun (*this, &SoundFileBox::remove_field_clicked));
-
- Gtk::CellRendererText* cell(dynamic_cast<Gtk::CellRendererText*>(field_view.get_column_cell_renderer(1)));
- cell->signal_edited().connect (mem_fun (*this, &SoundFileBox::field_edited));
-
- field_view.get_selection()->signal_changed().connect (mem_fun (*this, &SoundFileBox::field_selected));
- Library->fields_changed.connect (mem_fun (*this, &SoundFileBox::setup_fields));
+ apply_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::apply_btn_clicked));
show_all();
stop_btn.hide();
path = filename;
string error_msg;
+
if(!AudioFileSource::get_soundfile_info (filename, sf_info, error_msg)) {
return false;
}
length.set_alignment (0.0f, 0.0f);
- length.set_text (string_compose("Length: %1", PBD::length2string(sf_info.length, sf_info.samplerate)));
+ length.set_text (string_compose(_("Length: %1"), length2string(sf_info.length, sf_info.samplerate)));
format.set_alignment (0.0f, 0.0f);
format.set_text (sf_info.format_name);
channels.set_alignment (0.0f, 0.0f);
- channels.set_text (string_compose("Channels: %1", sf_info.channels));
+ channels.set_text (string_compose(_("Channels: %1"), sf_info.channels));
samplerate.set_alignment (0.0f, 0.0f);
- samplerate.set_text (string_compose("Samplerate: %1", sf_info.samplerate));
+ samplerate.set_text (string_compose(_("Samplerate: %1"), sf_info.samplerate));
- setup_fields ();
+ timecode.set_alignment (0.0f, 0.0f);
+ timecode.set_text (string_compose (_("Timecode: %1"), length2string(sf_info.timecode, sf_info.samplerate)));
+ 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());
+
return true;
}
-void
-SoundFileBox::setup_fields ()
-{
- ENSURE_GUI_THREAD(mem_fun (*this, &SoundFileBox::setup_fields));
-
- fields->clear ();
-
- vector<string> field_list;
- Library->get_fields(field_list);
-
- vector<string>::iterator i;
- Gtk::TreeModel::iterator iter;
- Gtk::TreeModel::Row row;
- for (i = field_list.begin(); i != field_list.end(); ++i) {
- if (!(*i == _("channels") || *i == _("samplerate") ||
- *i == _("resolution") || *i == _("format"))) {
- iter = fields->append();
- row = *iter;
-
- string value = Library->get_field(path, *i);
- row[label_columns.field] = *i;
- row[label_columns.data] = value;
- }
- }
+bool
+SoundFileBox::tags_entry_left (GdkEventFocus* event)
+{
+ apply_btn_clicked ();
+
+ return true;
}
void
return;
}
- static std::map<string, boost::shared_ptr<AudioRegion> > region_cache;
+ typedef std::map<string, boost::shared_ptr<AudioRegion> > RegionCache;
+ static RegionCache region_cache;
+ RegionCache::iterator the_region;
- if (region_cache.find (path) == region_cache.end()) {
+ if ((the_region = region_cache.find (path)) == region_cache.end()) {
SourceList srclist;
boost::shared_ptr<AudioFileSource> afs;
return;
}
+ string rname;
+
+ _session->region_name (rname, Glib::path_get_basename(srclist[0]->name()), false);
+
pair<string,boost::shared_ptr<AudioRegion> > newpair;
+ pair<RegionCache::iterator,bool> res;
- _session->region_name (newpair.first, Glib::path_get_basename(srclist[0]->name()), false);
- newpair.second = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0, srclist[0]->length(), newpair.first, 0, Region::DefaultFlags, false));
+ newpair.first = path;
+ newpair.second = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0, srclist[0]->length(), rname, 0, Region::DefaultFlags, false));
- region_cache.insert (newpair);
+ res = region_cache.insert (newpair);
+ the_region = res.first;
}
play_btn.hide();
stop_btn.show();
- _session->audition_region(region_cache[path]);
+ boost::shared_ptr<Region> r = boost::static_pointer_cast<Region> (the_region->second);
+
+ _session->audition_region(r);
}
void
}
void
-SoundFileBox::add_field_clicked ()
-{
- ArdourPrompter prompter (true);
- string name;
-
- prompter.set_prompt (_("Name for Field"));
- prompter.add_button (Gtk::Stock::ADD, Gtk::RESPONSE_ACCEPT);
- prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
-
- switch (prompter.run ()) {
- case Gtk::RESPONSE_ACCEPT:
- prompter.get_result (name);
- if (name.length()) {
- Library->add_field (name);
- Library->save_changes ();
- }
- break;
-
- default:
- break;
- }
-}
-
-void
-SoundFileBox::remove_field_clicked ()
+SoundFileBox::apply_btn_clicked ()
{
- field_view.get_selection()->selected_foreach_iter(mem_fun(*this, &SoundFileBox::delete_row));
+ string tag_string = tags_entry.get_text ();
- Library->save_changes ();
-}
+ vector<string> tags;
-void
-SoundFileBox::field_edited (const Glib::ustring& str1, const Glib::ustring& str2)
-{
- Gtk::TreeModel::Children rows(fields->children());
- Gtk::TreeModel::Row row(rows[atoi(str1.c_str())]);
-
- Library->set_field (path, row[label_columns.field], str2);
+ static const string DELIMITERS = ",";
+ // Skip delimiters at beginning.
+ string::size_type last_pos = tag_string.find_first_not_of(DELIMITERS, 0);
+ // Find first "non-delimiter".
+ string::size_type pos = tag_string.find_first_of(DELIMITERS, last_pos);
+
+ while (string::npos != pos || string::npos != last_pos) {
+ string x = tag_string.substr(last_pos, pos - last_pos);
+ strip_whitespace_edges (x);
+ if (x.length()) {
+ tags.push_back (x);
+ }
+ // Skip delimiters. Note the "not_of"
+ last_pos = tag_string.find_first_not_of(DELIMITERS, pos);
+ // Find next "non-delimiter"
+ pos = tag_string.find_first_of(DELIMITERS, last_pos);
+ }
+
+ Library->set_tags (path, tags);
Library->save_changes ();
}
-void
-SoundFileBox::delete_row (const Gtk::TreeModel::iterator& iter)
-{
- Gtk::TreeModel::Row row = *iter;
-
- Library->remove_field(row[label_columns.field]);
-}
-
void
SoundFileBox::audition_status_changed (bool active)
{
}
}
-void
-SoundFileBox::field_selected ()
-{
- if (field_view.get_selection()->count_selected_rows()) {
- remove_field_btn.set_sensitive(true);
- } else {
- remove_field_btn.set_sensitive(false);
- }
-}
-
// 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[] = {
- X_("Add to Region list"),
- X_("Add to selected Track(s)"),
- X_("Add as new Track(s)"),
- X_("Add as new Tape Track(s)"),
+ N_("Add to Region list"),
+ N_("Add to selected Track(s)"),
+ N_("Add as new Track(s)"),
+ N_("Add as new Tape Track(s)"),
0
};
: ArdourDialog (title, false),
chooser (Gtk::FILE_CHOOSER_ACTION_OPEN)
{
+ set_default_size (700, 500);
get_vbox()->pack_start(chooser);
chooser.set_preview_widget(preview);
chooser.set_select_multiple (true);
split_check (_("Split Channels"))
{
if (mode_strings.empty()) {
- mode_strings = PBD::internationalize (import_mode_strings);
+ mode_strings = I18N (import_mode_strings);
}
ARDOUR_UI::instance()->tooltips().set_tip(split_check,
ARDOUR_UI::instance()->tooltips().set_tip(*btn,
_("Link to an external file"));
+ add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
+
btn = add_button (_("Import"), ResponseImport);
ARDOUR_UI::instance()->tooltips().set_tip(*btn,
_("Copy a file to the session folder"));
- add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
-
Gtk::HBox *box = manage (new Gtk::HBox());
Gtkmm2ext::set_popdown_strings (mode_combo, mode_strings);