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/scale.h>
40 #include <gtkmm/textview.h>
41 #include <gtkmm/table.h>
42 #include <gtkmm/liststore.h>
43 #include <gtkmm/spinbutton.h>
44 #include <gtkmm/notebook.h>
47 #include "ardour/audiofilesource.h"
48 #include "ardour/session_handle.h"
50 #include "ardour_window.h"
52 #include "audio_clock.h"
61 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public PBD::ScopedConnectionList
64 SoundFileBox (bool persistent);
65 virtual ~SoundFileBox () {};
67 void set_session (ARDOUR::Session* s);
68 bool setup_labels (const std::string& filename);
71 bool audition_oneshot();
72 bool autoplay () const;
73 void set_src_quality(ARDOUR::SrcQuality q) { _src_quality = q; }
74 void set_import_position(Editing::ImportPosition p) { _import_position = p; }
79 ARDOUR::SoundFileInfo sf_info;
86 Gtk::Label samplerate;
89 Gtk::Label channels_value;
90 Gtk::Label samplerate_value;
92 Gtk::Label format_text;
93 AudioClock length_clock;
94 AudioClock timecode_clock;
96 Gtk::Frame border_frame;
97 Gtk::Label preview_label;
99 Gtk::TextView tags_entry;
103 Gtk::HBox bottom_box;
105 Gtk::Button play_btn;
106 Gtk::Button stop_btn;
107 Gtk::CheckButton autoplay_btn;
108 Gtk::Button apply_btn;
109 Gtk::HScale seek_slider;
111 PBD::ScopedConnectionList auditioner_connections;
112 void audition_active(bool);
113 void audition_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t);
115 bool tags_entry_left (GdkEventFocus* event);
116 void tags_changed ();
117 void save_tags (const std::vector<std::string>&);
118 void stop_audition ();
119 bool seek_button_press(GdkEventButton*);
120 bool seek_button_release(GdkEventButton*);
122 ARDOUR::SrcQuality _src_quality;
123 Editing::ImportPosition _import_position;
126 class SoundFileBrowser : public ArdourWindow
129 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
132 Gtk::TreeModelColumn<std::string> pathname;
134 FoundTagColumns() { add(pathname); }
137 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
140 Gtk::TreeModelColumn<std::string> id;
141 Gtk::TreeModelColumn<std::string> uri;
142 Gtk::TreeModelColumn<std::string> filename;
143 Gtk::TreeModelColumn<std::string> duration;
144 Gtk::TreeModelColumn<std::string> filesize;
145 Gtk::TreeModelColumn<std::string> smplrate;
146 Gtk::TreeModelColumn<std::string> license;
147 Gtk::TreeModelColumn<bool> started;
161 FoundTagColumns found_list_columns;
162 Glib::RefPtr<Gtk::ListStore> found_list;
164 FreesoundColumns freesound_list_columns;
165 Glib::RefPtr<Gtk::ListStore> freesound_list;
167 Gtk::Button freesound_more_btn;
168 Gtk::Button freesound_similar_btn;
170 void handle_freesound_results(std::string theString);
172 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
173 virtual ~SoundFileBrowser ();
176 int status () const { return _status; }
178 virtual void set_session (ARDOUR::Session*);
179 std::vector<std::string> get_paths ();
181 void clear_selection ();
183 Gtk::FileChooserWidget chooser;
185 SoundFileBox preview;
187 Gtk::Entry found_entry;
188 Gtk::Button found_search_btn;
189 Gtk::TreeView found_list_view;
191 Gtk::Entry freesound_entry;
192 Gtk::ComboBoxText freesound_sort;
194 Gtk::Button freesound_search_btn;
195 Gtk::TreeView freesound_list_view;
196 Gtk::Notebook notebook;
198 void freesound_search();
199 void refresh_display(std::string ID, std::string file);
202 bool resetting_ourselves;
207 Gtk::FileFilter audio_and_midi_filter;
208 Gtk::FileFilter audio_filter;
209 Gtk::FileFilter midi_filter;
210 Gtk::FileFilter custom_filter;
211 Gtk::FileFilter matchall_filter;
215 Gtk::Button ok_button;
216 Gtk::Button cancel_button;
217 Gtk::Button apply_button;
219 static std::string persistent_folder;
223 Gtk::VBox meter_packer;
224 void add_gain_meter ();
225 void remove_gain_meter ();
227 void start_metering ();
228 void stop_metering ();
229 sigc::connection metering_connection;
231 void update_preview ();
233 void found_list_view_selected ();
234 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
235 void found_search_clicked ();
237 void freesound_list_view_selected ();
238 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
239 void freesound_search_clicked ();
240 void freesound_more_clicked ();
241 void freesound_similar_clicked ();
244 void chooser_file_activated ();
245 std::string freesound_get_audio_file(Gtk::TreeIter iter);
247 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
248 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
249 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
251 void set_action_sensitive (bool);
253 virtual bool reset_options() { return true; }
257 virtual void do_something (int action);
260 class SoundFileChooser : public SoundFileBrowser
263 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
264 virtual ~SoundFileChooser () {};
266 std::string get_filename ();
272 class SoundFileOmega : public SoundFileBrowser
276 SoundFileOmega (std::string title, ARDOUR::Session* _s,
277 uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
279 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
281 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
283 Gtk::ComboBoxText action_combo;
284 Gtk::ComboBoxText where_combo;
285 Gtk::ComboBoxText channel_combo;
286 Gtk::ComboBoxText src_combo;
288 Gtk::CheckButton copy_files_btn;
290 void set_mode (Editing::ImportMode);
291 Editing::ImportMode get_mode() const;
292 Editing::ImportPosition get_position() const;
293 Editing::ImportDisposition get_channel_disposition() const;
294 ARDOUR::SrcQuality get_src_quality() const;
300 uint32_t selected_audio_track_cnt;
301 uint32_t selected_midi_track_cnt;
303 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
304 DispositionMap disposition_map;
308 Gtk::VBox block_three;
309 Gtk::VBox block_four;
311 bool check_info (const std::vector<std::string>& paths,
312 bool& same_size, bool& src_needed, bool& multichannel);
314 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
316 void file_selection_changed ();
317 bool reset_options ();
318 void reset_options_noret ();
319 bool bad_file_message ();
320 void src_combo_changed ();
321 void where_combo_changed ();
323 void do_something (int action);
326 #endif // __ardour_sfdb_ui_h__