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; }
78 ARDOUR::SoundFileInfo sf_info;
85 Gtk::Label samplerate;
88 Gtk::Label channels_value;
89 Gtk::Label samplerate_value;
91 Gtk::Label format_text;
92 AudioClock length_clock;
93 AudioClock timecode_clock;
95 Gtk::Frame border_frame;
96 Gtk::Label preview_label;
98 Gtk::TextView tags_entry;
102 Gtk::HBox bottom_box;
104 Gtk::Button play_btn;
105 Gtk::Button stop_btn;
106 Gtk::CheckButton autoplay_btn;
107 Gtk::Button apply_btn;
108 Gtk::HScale seek_slider;
110 PBD::ScopedConnectionList auditioner_connections;
111 void audition_active(bool);
112 void audition_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t);
114 bool tags_entry_left (GdkEventFocus* event);
115 void tags_changed ();
116 void save_tags (const std::vector<std::string>&);
117 void stop_audition ();
118 bool seek_button_press(GdkEventButton*);
119 bool seek_button_release(GdkEventButton*);
121 ARDOUR::SrcQuality _src_quality;
124 class SoundFileBrowser : public ArdourWindow
127 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
130 Gtk::TreeModelColumn<std::string> pathname;
132 FoundTagColumns() { add(pathname); }
135 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
138 Gtk::TreeModelColumn<std::string> id;
139 Gtk::TreeModelColumn<std::string> uri;
140 Gtk::TreeModelColumn<std::string> filename;
141 Gtk::TreeModelColumn<std::string> duration;
142 Gtk::TreeModelColumn<std::string> filesize;
143 Gtk::TreeModelColumn<std::string> smplrate;
144 Gtk::TreeModelColumn<std::string> license;
145 Gtk::TreeModelColumn<bool> started;
159 FoundTagColumns found_list_columns;
160 Glib::RefPtr<Gtk::ListStore> found_list;
162 FreesoundColumns freesound_list_columns;
163 Glib::RefPtr<Gtk::ListStore> freesound_list;
165 Gtk::Button freesound_more_btn;
166 Gtk::Button freesound_similar_btn;
168 void handle_freesound_results(std::string theString);
170 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
171 virtual ~SoundFileBrowser ();
174 int status () const { return _status; }
176 virtual void set_session (ARDOUR::Session*);
177 std::vector<std::string> get_paths ();
179 void clear_selection ();
181 Gtk::FileChooserWidget chooser;
183 SoundFileBox preview;
185 Gtk::Entry found_entry;
186 Gtk::Button found_search_btn;
187 Gtk::TreeView found_list_view;
189 Gtk::Entry freesound_entry;
190 Gtk::ComboBoxText freesound_sort;
192 Gtk::Button freesound_search_btn;
193 Gtk::TreeView freesound_list_view;
194 Gtk::Notebook notebook;
196 void freesound_search();
197 void refresh_display(std::string ID, std::string file);
200 bool resetting_ourselves;
205 Gtk::FileFilter audio_and_midi_filter;
206 Gtk::FileFilter audio_filter;
207 Gtk::FileFilter midi_filter;
208 Gtk::FileFilter custom_filter;
209 Gtk::FileFilter matchall_filter;
213 Gtk::Button ok_button;
214 Gtk::Button cancel_button;
215 Gtk::Button apply_button;
217 static std::string persistent_folder;
221 Gtk::VBox meter_packer;
222 void add_gain_meter ();
223 void remove_gain_meter ();
225 void start_metering ();
226 void stop_metering ();
227 sigc::connection metering_connection;
229 void update_preview ();
231 void found_list_view_selected ();
232 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
233 void found_search_clicked ();
235 void freesound_list_view_selected ();
236 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
237 void freesound_search_clicked ();
238 void freesound_more_clicked ();
239 void freesound_similar_clicked ();
242 void chooser_file_activated ();
243 std::string freesound_get_audio_file(Gtk::TreeIter iter);
245 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
246 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
247 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
249 void set_action_sensitive (bool);
251 virtual bool reset_options() { return true; }
255 virtual void do_something (int action);
258 class SoundFileChooser : public SoundFileBrowser
261 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
262 virtual ~SoundFileChooser () {};
264 std::string get_filename ();
270 class SoundFileOmega : public SoundFileBrowser
274 SoundFileOmega (std::string title, ARDOUR::Session* _s,
275 uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
277 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
279 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
281 Gtk::ComboBoxText action_combo;
282 Gtk::ComboBoxText where_combo;
283 Gtk::ComboBoxText channel_combo;
284 Gtk::ComboBoxText src_combo;
286 Gtk::CheckButton copy_files_btn;
288 void set_mode (Editing::ImportMode);
289 Editing::ImportMode get_mode() const;
290 Editing::ImportPosition get_position() const;
291 Editing::ImportDisposition get_channel_disposition() const;
292 ARDOUR::SrcQuality get_src_quality() const;
298 uint32_t selected_audio_track_cnt;
299 uint32_t selected_midi_track_cnt;
301 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
302 DispositionMap disposition_map;
306 Gtk::VBox block_three;
307 Gtk::VBox block_four;
309 bool check_info (const std::vector<std::string>& paths,
310 bool& same_size, bool& src_needed, bool& multichannel);
312 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
314 void file_selection_changed ();
315 bool reset_options ();
316 void reset_options_noret ();
317 bool bad_file_message ();
318 void src_combo_changed ();
320 void do_something (int action);
323 #endif // __ardour_sfdb_ui_h__