diff options
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/audio_time_axis.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/option_editor.cc | 42 | ||||
-rw-r--r-- | gtk2_ardour/option_editor.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/route_time_axis.cc | 6 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.cc | 159 | ||||
-rw-r--r-- | gtk2_ardour/sfdb_ui.h | 163 | ||||
-rw-r--r-- | gtk2_ardour/visual_time_axis.cc | 6 |
7 files changed, 132 insertions, 250 deletions
diff --git a/gtk2_ardour/audio_time_axis.cc b/gtk2_ardour/audio_time_axis.cc index 2be25f76aa..4ab0428a51 100644 --- a/gtk2_ardour/audio_time_axis.cc +++ b/gtk2_ardour/audio_time_axis.cc @@ -30,7 +30,6 @@ #include <pbd/error.h> #include <pbd/stl_delete.h> -#include <pbd/whitespace.h> #include <pbd/memento_command.h> #include <gtkmm2ext/gtk_ui.h> diff --git a/gtk2_ardour/option_editor.cc b/gtk2_ardour/option_editor.cc index 3e461a85d7..77af855845 100644 --- a/gtk2_ardour/option_editor.cc +++ b/gtk2_ardour/option_editor.cc @@ -20,7 +20,6 @@ #include <pbd/whitespace.h> -#include <ardour/audio_library.h> #include <ardour/session.h> #include <ardour/audioengine.h> #include <ardour/configuration.h> @@ -60,7 +59,6 @@ OptionEditor::OptionEditor (ARDOUR_UI& uip, PublicEditor& ed, Mixer_UI& mixui) /* Paths */ path_table (11, 2), - sfdb_path_view(), /* Fades */ @@ -224,24 +222,10 @@ OptionEditor::setup_path_options() path_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL); path_table.attach (session_raid_entry, 1, 3, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL); - label = manage(new Label(_("Soundfile Search Paths"))); - label->set_name("OptionsLabel"); - path_table.attach(*label, 0, 1, 2, 3, FILL|EXPAND, FILL); - path_table.attach(sfdb_path_view, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, FILL); - - sfdb_path_view.set_paths(Library->get_paths()); - sfdb_path_view.PathsUpdated.connect (mem_fun(*this, &OptionEditor::sfdb_paths_changed)); - path_table.show_all(); } void -OptionEditor::sfdb_paths_changed () -{ - Library->set_paths (sfdb_path_view.get_paths()); -} - -void OptionEditor::add_session_paths () { click_path_entry.set_sensitive (true); @@ -659,19 +643,12 @@ OptionEditor::click_sound_changed () return; } - if (path.empty()) { + strip_whitespace_edges (path); + if (path == _("internal")) { Config->set_click_sound (""); - } else { - - strip_whitespace_edges (path); - - if (path == _("internal")) { - Config->set_click_sound (""); - } else { - Config->set_click_sound (path); - } + Config->set_click_sound (path); } } } @@ -686,19 +663,12 @@ OptionEditor::click_emphasis_sound_changed () return; } - if (path.empty()) { + strip_whitespace_edges (path); + if (path == _("internal")) { Config->set_click_emphasis_sound (""); - } else { - - strip_whitespace_edges (path); - - if (path == _("internal")) { - Config->set_click_emphasis_sound (""); - } else { - Config->set_click_emphasis_sound (path); - } + Config->set_click_emphasis_sound (path); } } } diff --git a/gtk2_ardour/option_editor.h b/gtk2_ardour/option_editor.h index 2076da3935..cc28a74e60 100644 --- a/gtk2_ardour/option_editor.h +++ b/gtk2_ardour/option_editor.h @@ -33,8 +33,6 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/comboboxtext.h> -#include <gtkmm2ext/pathlist.h> - #include <ardour/session.h> #include "ardour_dialog.h" @@ -75,13 +73,10 @@ class OptionEditor : public Gtk::Dialog Gtk::Table path_table; Gtk::Entry session_raid_entry; - Gtkmm2ext::PathList sfdb_path_view; - void setup_path_options(); void add_session_paths (); void remove_session_paths (); void raid_path_changed (); - void sfdb_paths_changed (); /* fades */ diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 348e4fb01f..4d0b507037 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -1105,17 +1105,17 @@ RouteTimeAxisView::name_entry_changed () return; } + strip_whitespace_edges(x); + if (x.length() == 0) { name_entry.set_text (_route->name()); return; } - strip_whitespace_edges(x); - if (_session.route_name_unique (x)) { _route->set_name (x, this); } else { - ARDOUR_UI::instance()->popup_error (_("a track already exists with that name")); + ARDOUR_UI::instance()->popup_error (_("A track already exists with that name")); name_entry.set_text (_route->name()); } } diff --git a/gtk2_ardour/sfdb_ui.cc b/gtk2_ardour/sfdb_ui.cc index 150b071661..3084844f78 100644 --- a/gtk2_ardour/sfdb_ui.cc +++ b/gtk2_ardour/sfdb_ui.cc @@ -1,6 +1,5 @@ /* - 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 @@ -16,16 +15,17 @@ 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> @@ -52,14 +52,12 @@ SoundFileBox::SoundFileBox () : _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")); @@ -75,38 +73,21 @@ SoundFileBox::SoundFileBox () main_box.pack_start(channels, false, false); main_box.pack_start(samplerate, false, false); main_box.pack_start(timecode, false, false); - main_box.pack_start(field_view, true, true); + 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(); @@ -136,7 +117,7 @@ SoundFileBox::setup_labels (string filename) } 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); @@ -148,37 +129,28 @@ SoundFileBox::setup_labels (string filename) samplerate.set_text (string_compose(_("Samplerate: %1"), sf_info.samplerate)); timecode.set_alignment (0.0f, 0.0f); - timecode.set_text (string_compose (_("Timecode: %1"), PBD::length2string(sf_info.timecode, sf_info.samplerate))); - - setup_fields (); + 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 @@ -228,7 +200,6 @@ SoundFileBox::play_btn_clicked () newpair.first = path; newpair.second = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (srclist, 0, srclist[0]->length(), rname, 0, Region::DefaultFlags, false)); - res = region_cache.insert (newpair); the_region = res.first; } @@ -252,57 +223,36 @@ SoundFileBox::stop_btn_clicked () } 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) { ENSURE_GUI_THREAD(bind (mem_fun (*this, &SoundFileBox::audition_status_changed), active)); @@ -312,16 +262,6 @@ 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[] = { N_("Add to Region list"), @@ -335,6 +275,7 @@ SoundFileBrowser::SoundFileBrowser (string title, ARDOUR::Session* s) : 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); diff --git a/gtk2_ardour/sfdb_ui.h b/gtk2_ardour/sfdb_ui.h index d7c2c14014..c8a0d316a5 100644 --- a/gtk2_ardour/sfdb_ui.h +++ b/gtk2_ardour/sfdb_ui.h @@ -1,6 +1,5 @@ /* - 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 @@ -16,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ #ifndef __ardour_sfdb_ui_h__ @@ -36,8 +34,6 @@ #include <gtkmm/comboboxtext.h> #include <gtkmm/frame.h> #include <gtkmm/label.h> -#include <gtkmm/liststore.h> -#include <gtkmm/treeview.h> #include <ardour/session.h> #include <ardour/audiofilesource.h> @@ -48,117 +44,98 @@ class SoundFileBox : public Gtk::VBox { public: - SoundFileBox (); - virtual ~SoundFileBox () {}; - - void set_session (ARDOUR::Session* s); - bool setup_labels (std::string filename); + SoundFileBox (); + virtual ~SoundFileBox () {}; + + void set_session (ARDOUR::Session* s); + bool setup_labels (std::string filename); protected: ARDOUR::Session* _session; std::string path; - - struct LabelModelColumns : public Gtk::TreeModel::ColumnRecord - { - public: - Gtk::TreeModelColumn<std::string> field; - Gtk::TreeModelColumn<std::string> data; - - LabelModelColumns() { add(field); add(data); } - }; - - LabelModelColumns label_columns; - - ARDOUR::SoundFileInfo sf_info; - - pid_t current_pid; - - Gtk::Label length; - Gtk::Label format; - Gtk::Label channels; - Gtk::Label samplerate; - Gtk::Label timecode; - - Gtk::TreeView field_view; - Glib::RefPtr<Gtk::ListStore> fields; - std::string selected_field; - - Gtk::Frame border_frame; - - Gtk::VBox main_box; - Gtk::VBox path_box; - Gtk::HBox top_box; - Gtk::HBox bottom_box; - - Gtk::Button play_btn; - Gtk::Button stop_btn; - Gtk::Button add_field_btn; - Gtk::Button remove_field_btn; - - void setup_fields (); - - void play_btn_clicked (); - void stop_btn_clicked (); - void add_field_clicked (); - void remove_field_clicked (); - void field_edited (const Glib::ustring&, const Glib::ustring&); - void delete_row (const Gtk::TreeModel::iterator& iter); - - void field_selected (); - void audition_status_changed (bool state); + + ARDOUR::SoundFileInfo sf_info; + + pid_t current_pid; + + Gtk::Label length; + Gtk::Label format; + Gtk::Label channels; + Gtk::Label samplerate; + Gtk::Label timecode; + + Gtk::Frame border_frame; + + Gtk::Entry tags_entry; + + Gtk::VBox main_box; + Gtk::VBox path_box; + Gtk::HBox top_box; + Gtk::HBox bottom_box; + + Gtk::Button play_btn; + Gtk::Button stop_btn; + Gtk::Button apply_btn; + + bool tags_entry_left (GdkEventFocus* event); + void play_btn_clicked (); + void stop_btn_clicked (); + void apply_btn_clicked (); + + void audition_status_changed (bool state); }; class SoundFileBrowser : public ArdourDialog { public: - SoundFileBrowser (std::string title, ARDOUR::Session* _s = 0); - virtual ~SoundFileBrowser () {}; - - virtual void set_session (ARDOUR::Session*); + SoundFileBrowser (std::string title, ARDOUR::Session* _s = 0); + virtual ~SoundFileBrowser () {}; + + virtual void set_session (ARDOUR::Session*); protected: - Gtk::FileChooserWidget chooser; - SoundFileBox preview; - - void update_preview (); + Gtk::FileChooserWidget chooser; + SoundFileBox preview; + + void update_preview (); }; class SoundFileChooser : public SoundFileBrowser { public: - SoundFileChooser (std::string title, ARDOUR::Session* _s = 0); - virtual ~SoundFileChooser () {}; - - std::string get_filename () {return chooser.get_filename();}; + SoundFileChooser (std::string title, ARDOUR::Session* _s = 0); + virtual ~SoundFileChooser () {}; + + std::string get_filename () {return chooser.get_filename();}; }; class SoundFileOmega : public SoundFileBrowser { public: - SoundFileOmega (std::string title, ARDOUR::Session* _s); - virtual ~SoundFileOmega () {}; - - /* these are returned by the Dialog::run() method. note - that builtin GTK responses are all negative, leaving - positive values for application-defined responses. - */ - - const static int ResponseImport = 1; - const static int ResponseEmbed = 2; - - std::vector<Glib::ustring> get_paths (); - bool get_split (); - - void set_mode (Editing::ImportMode); - Editing::ImportMode get_mode (); + SoundFileOmega (std::string title, ARDOUR::Session* _s); + virtual ~SoundFileOmega () {}; + + /* these are returned by the Dialog::run() method. note + that builtin GTK responses are all negative, leaving + positive values for application-defined responses. + */ + + const static int ResponseImport = 1; + const static int ResponseEmbed = 2; + + std::vector<Glib::ustring> get_paths (); + bool get_split (); + + void set_mode (Editing::ImportMode); + Editing::ImportMode get_mode (); protected: - Gtk::CheckButton split_check; - Gtk::ComboBoxText mode_combo; - - void mode_changed (); - - static std::vector<std::string> mode_strings; + Gtk::CheckButton split_check; + Gtk::ComboBoxText mode_combo; + + void mode_changed (); + + static std::vector<std::string> mode_strings; }; #endif // __ardour_sfdb_ui_h__ diff --git a/gtk2_ardour/visual_time_axis.cc b/gtk2_ardour/visual_time_axis.cc index 24cafdbe67..20fe13603e 100644 --- a/gtk2_ardour/visual_time_axis.cc +++ b/gtk2_ardour/visual_time_axis.cc @@ -375,17 +375,17 @@ VisualTimeAxis::name_entry_changed() return; } + strip_whitespace_edges(x); + if (x.length() == 0) { name_entry.set_text (time_axis_name); return; } - strip_whitespace_edges(x); - if (!editor.get_named_time_axis(x)) { set_time_axis_name(x, this); } else { - ARDOUR_UI::instance()->popup_error (_("a track already exists with that name")); + ARDOUR_UI::instance()->popup_error (_("A track already exists with that name")); name_entry.set_text(time_axis_name); } } |