2 Copyright (C) 2005-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
27 #include <sigc++/signal.h>
29 #include <gtkmm/stock.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/button.h>
32 #include <gtkmm/checkbutton.h>
33 #include <gtkmm/comboboxtext.h>
34 #include <gtkmm/dialog.h>
35 #include <gtkmm/entry.h>
36 #include <gtkmm/filechooserwidget.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/textview.h>
40 #include <gtkmm/table.h>
41 #include <gtkmm/liststore.h>
42 #include <gtkmm/spinbutton.h>
43 #include <gtkmm/notebook.h>
46 #include "ardour/audiofilesource.h"
47 #include "ardour/session_handle.h"
49 #include "ardour_dialog.h"
51 #include "audio_clock.h"
59 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr
62 SoundFileBox (bool persistent);
63 virtual ~SoundFileBox () {};
65 void set_session (ARDOUR::Session* s);
66 bool setup_labels (const std::string& filename);
69 bool audition_oneshot();
70 bool autoplay () const;
75 ARDOUR::SoundFileInfo sf_info;
82 Gtk::Label samplerate;
85 Gtk::Label channels_value;
86 Gtk::Label samplerate_value;
88 Gtk::Label format_text;
89 AudioClock length_clock;
90 AudioClock timecode_clock;
92 Gtk::Frame border_frame;
93 Gtk::Label preview_label;
95 Gtk::TextView tags_entry;
101 Gtk::Button play_btn;
102 Gtk::Button stop_btn;
103 Gtk::CheckButton autoplay_btn;
104 Gtk::Button apply_btn;
106 bool tags_entry_left (GdkEventFocus* event);
107 void tags_changed ();
108 void save_tags (const std::vector<std::string>&);
109 void stop_audition ();
112 class SoundFileBrowser : public ArdourDialog
115 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
118 Gtk::TreeModelColumn<std::string> pathname;
120 FoundTagColumns() { add(pathname); }
123 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
126 Gtk::TreeModelColumn<std::string> id;
127 Gtk::TreeModelColumn<std::string> uri;
128 Gtk::TreeModelColumn<std::string> filename;
130 FreesoundColumns() { add(id); add(filename); add(uri); }
133 FoundTagColumns found_list_columns;
134 Glib::RefPtr<Gtk::ListStore> found_list;
136 FreesoundColumns freesound_list_columns;
137 Glib::RefPtr<Gtk::ListStore> freesound_list;
139 Gtk::Button freesound_stop_btn;
142 SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, bool persistent);
143 virtual ~SoundFileBrowser ();
145 virtual void set_session (ARDOUR::Session*);
146 std::vector<std::string> get_paths ();
148 void clear_selection ();
150 Gtk::FileChooserWidget chooser;
152 SoundFileBox preview;
154 Gtk::Entry found_entry;
155 Gtk::Button found_search_btn;
156 Gtk::TreeView found_list_view;
158 Gtk::Entry freesound_entry;
159 Gtk::ComboBoxText freesound_sort;
160 Gtk::SpinButton freesound_page;
162 Gtk::Button freesound_search_btn;
163 Gtk::TreeView freesound_list_view;
164 Gtk::ProgressBar progress_bar;
168 void freesound_search();
171 bool resetting_ourselves;
173 Gtk::FileFilter audio_filter;
174 Gtk::FileFilter midi_filter;
175 Gtk::FileFilter custom_filter;
176 Gtk::FileFilter matchall_filter;
179 static std::string persistent_folder;
181 Gtk::Notebook notebook;
184 Gtk::VBox meter_packer;
185 void add_gain_meter ();
186 void remove_gain_meter ();
188 void start_metering ();
189 void stop_metering ();
190 sigc::connection metering_connection;
192 void update_preview ();
194 void found_list_view_selected ();
195 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
196 void found_search_clicked ();
198 void freesound_list_view_selected ();
199 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
200 void freesound_search_clicked ();
201 void freesound_stop_clicked ();
203 void chooser_file_activated ();
205 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
206 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
208 virtual bool reset_options() { return true; }
215 class SoundFileChooser : public SoundFileBrowser
218 SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
219 virtual ~SoundFileChooser () {};
221 std::string get_filename ();
227 class SoundFileOmega : public SoundFileBrowser
231 SoundFileOmega (Gtk::Window& parent, std::string title, ARDOUR::Session* _s,
232 uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
234 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
236 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
238 Gtk::ComboBoxText action_combo;
239 Gtk::ComboBoxText where_combo;
240 Gtk::ComboBoxText channel_combo;
241 Gtk::ComboBoxText src_combo;
243 Gtk::CheckButton copy_files_btn;
245 void set_mode (Editing::ImportMode);
246 Editing::ImportMode get_mode() const;
247 Editing::ImportPosition get_position() const;
248 Editing::ImportDisposition get_channel_disposition() const;
249 ARDOUR::SrcQuality get_src_quality() const;
255 uint32_t selected_audio_track_cnt;
256 uint32_t selected_midi_track_cnt;
258 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
259 DispositionMap disposition_map;
263 Gtk::VBox block_three;
264 Gtk::VBox block_four;
266 bool check_info (const std::vector<std::string>& paths,
267 bool& same_size, bool& src_needed, bool& multichannel);
269 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
271 void file_selection_changed ();
272 bool reset_options ();
273 void reset_options_noret ();
274 bool bad_file_message ();
277 #endif // __ardour_sfdb_ui_h__