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;
77 ARDOUR::SoundFileInfo sf_info;
84 Gtk::Label samplerate;
87 Gtk::Label channels_value;
88 Gtk::Label samplerate_value;
90 Gtk::Label format_text;
91 AudioClock length_clock;
92 AudioClock timecode_clock;
94 Gtk::Frame border_frame;
95 Gtk::Label preview_label;
97 Gtk::TextView tags_entry;
101 Gtk::HBox bottom_box;
103 Gtk::Button play_btn;
104 Gtk::Button stop_btn;
105 Gtk::CheckButton autoplay_btn;
106 Gtk::Button apply_btn;
107 Gtk::HScale seek_slider;
109 PBD::ScopedConnectionList auditioner_connections;
110 void audition_active(bool);
111 void audition_progress(ARDOUR::framecnt_t, ARDOUR::framecnt_t);
113 bool tags_entry_left (GdkEventFocus* event);
114 void tags_changed ();
115 void save_tags (const std::vector<std::string>&);
116 void stop_audition ();
117 bool seek_button_press(GdkEventButton*);
118 bool seek_button_release(GdkEventButton*);
122 class SoundFileBrowser : public ArdourWindow
125 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
128 Gtk::TreeModelColumn<std::string> pathname;
130 FoundTagColumns() { add(pathname); }
133 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
136 Gtk::TreeModelColumn<std::string> id;
137 Gtk::TreeModelColumn<std::string> uri;
138 Gtk::TreeModelColumn<std::string> filename;
139 Gtk::TreeModelColumn<std::string> duration;
140 Gtk::TreeModelColumn<std::string> filesize;
141 Gtk::TreeModelColumn<std::string> smplrate;
142 Gtk::TreeModelColumn<std::string> license;
143 Gtk::TreeModelColumn<bool> started;
157 FoundTagColumns found_list_columns;
158 Glib::RefPtr<Gtk::ListStore> found_list;
160 FreesoundColumns freesound_list_columns;
161 Glib::RefPtr<Gtk::ListStore> freesound_list;
163 Gtk::Button freesound_more_btn;
164 Gtk::Button freesound_similar_btn;
166 void handle_freesound_results(std::string theString);
168 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
169 virtual ~SoundFileBrowser ();
172 int status () const { return _status; }
174 virtual void set_session (ARDOUR::Session*);
175 std::vector<std::string> get_paths ();
177 void clear_selection ();
179 Gtk::FileChooserWidget chooser;
181 SoundFileBox preview;
183 Gtk::Entry found_entry;
184 Gtk::Button found_search_btn;
185 Gtk::TreeView found_list_view;
187 Gtk::Entry freesound_entry;
188 Gtk::ComboBoxText freesound_sort;
190 Gtk::Button freesound_search_btn;
191 Gtk::TreeView freesound_list_view;
192 Gtk::Notebook notebook;
194 void freesound_search();
195 void refresh_display(std::string ID, std::string file);
198 bool resetting_ourselves;
203 Gtk::FileFilter audio_and_midi_filter;
204 Gtk::FileFilter audio_filter;
205 Gtk::FileFilter midi_filter;
206 Gtk::FileFilter custom_filter;
207 Gtk::FileFilter matchall_filter;
211 Gtk::Button ok_button;
212 Gtk::Button cancel_button;
213 Gtk::Button apply_button;
215 static std::string persistent_folder;
219 Gtk::VBox meter_packer;
220 void add_gain_meter ();
221 void remove_gain_meter ();
223 void start_metering ();
224 void stop_metering ();
225 sigc::connection metering_connection;
227 void update_preview ();
229 void found_list_view_selected ();
230 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
231 void found_search_clicked ();
233 void freesound_list_view_selected ();
234 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
235 void freesound_search_clicked ();
236 void freesound_more_clicked ();
237 void freesound_similar_clicked ();
240 void chooser_file_activated ();
241 std::string freesound_get_audio_file(Gtk::TreeIter iter);
243 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
244 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
245 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
247 void set_action_sensitive (bool);
249 virtual bool reset_options() { return true; }
253 virtual void do_something (int action);
256 class SoundFileChooser : public SoundFileBrowser
259 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
260 virtual ~SoundFileChooser () {};
262 std::string get_filename ();
268 class SoundFileOmega : public SoundFileBrowser
272 SoundFileOmega (std::string title, ARDOUR::Session* _s,
273 uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
275 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
277 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
279 Gtk::ComboBoxText action_combo;
280 Gtk::ComboBoxText where_combo;
281 Gtk::ComboBoxText channel_combo;
282 Gtk::ComboBoxText src_combo;
284 Gtk::CheckButton copy_files_btn;
286 void set_mode (Editing::ImportMode);
287 Editing::ImportMode get_mode() const;
288 Editing::ImportPosition get_position() const;
289 Editing::ImportDisposition get_channel_disposition() const;
290 ARDOUR::SrcQuality get_src_quality() const;
296 uint32_t selected_audio_track_cnt;
297 uint32_t selected_midi_track_cnt;
299 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
300 DispositionMap disposition_map;
304 Gtk::VBox block_three;
305 Gtk::VBox block_four;
307 bool check_info (const std::vector<std::string>& paths,
308 bool& same_size, bool& src_needed, bool& multichannel);
310 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
312 void file_selection_changed ();
313 bool reset_options ();
314 void reset_options_noret ();
315 bool bad_file_message ();
317 void do_something (int action);
320 #endif // __ardour_sfdb_ui_h__