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_window.h"
51 #include "audio_clock.h"
60 class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr
63 SoundFileBox (bool persistent);
64 virtual ~SoundFileBox () {};
66 void set_session (ARDOUR::Session* s);
67 bool setup_labels (const std::string& filename);
70 bool audition_oneshot();
71 bool autoplay () const;
76 ARDOUR::SoundFileInfo sf_info;
83 Gtk::Label samplerate;
86 Gtk::Label channels_value;
87 Gtk::Label samplerate_value;
89 Gtk::Label format_text;
90 AudioClock length_clock;
91 AudioClock timecode_clock;
93 Gtk::Frame border_frame;
94 Gtk::Label preview_label;
96 Gtk::TextView tags_entry;
100 Gtk::HBox bottom_box;
102 Gtk::Button play_btn;
103 Gtk::Button stop_btn;
104 Gtk::CheckButton autoplay_btn;
105 Gtk::Button apply_btn;
107 bool tags_entry_left (GdkEventFocus* event);
108 void tags_changed ();
109 void save_tags (const std::vector<std::string>&);
110 void stop_audition ();
113 class SoundFileBrowser : public ArdourWindow
116 class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
119 Gtk::TreeModelColumn<std::string> pathname;
121 FoundTagColumns() { add(pathname); }
124 class FreesoundColumns : public Gtk::TreeModel::ColumnRecord
127 Gtk::TreeModelColumn<std::string> id;
128 Gtk::TreeModelColumn<std::string> uri;
129 Gtk::TreeModelColumn<std::string> filename;
130 Gtk::TreeModelColumn<std::string> duration;
131 Gtk::TreeModelColumn<std::string> filesize;
132 Gtk::TreeModelColumn<std::string> smplrate;
133 Gtk::TreeModelColumn<std::string> license;
134 Gtk::TreeModelColumn<bool> started;
148 FoundTagColumns found_list_columns;
149 Glib::RefPtr<Gtk::ListStore> found_list;
151 FreesoundColumns freesound_list_columns;
152 Glib::RefPtr<Gtk::ListStore> freesound_list;
154 Gtk::Button freesound_more_btn;
155 Gtk::Button freesound_similar_btn;
157 void handle_freesound_results(std::string theString);
159 SoundFileBrowser (std::string title, ARDOUR::Session* _s, bool persistent);
160 virtual ~SoundFileBrowser ();
163 int status () const { return _status; }
165 virtual void set_session (ARDOUR::Session*);
166 std::vector<std::string> get_paths ();
168 void clear_selection ();
170 Gtk::FileChooserWidget chooser;
172 SoundFileBox preview;
174 Gtk::Entry found_entry;
175 Gtk::Button found_search_btn;
176 Gtk::TreeView found_list_view;
178 Gtk::Entry freesound_entry;
179 Gtk::ComboBoxText freesound_sort;
181 Gtk::Button freesound_search_btn;
182 Gtk::TreeView freesound_list_view;
183 Gtk::Notebook notebook;
185 void freesound_search();
186 void refresh_display(std::string ID, std::string file);
189 bool resetting_ourselves;
194 Gtk::FileFilter audio_and_midi_filter;
195 Gtk::FileFilter audio_filter;
196 Gtk::FileFilter midi_filter;
197 Gtk::FileFilter custom_filter;
198 Gtk::FileFilter matchall_filter;
202 Gtk::Button ok_button;
203 Gtk::Button cancel_button;
204 Gtk::Button apply_button;
206 static std::string persistent_folder;
210 Gtk::VBox meter_packer;
211 void add_gain_meter ();
212 void remove_gain_meter ();
214 void start_metering ();
215 void stop_metering ();
216 sigc::connection metering_connection;
218 void update_preview ();
220 void found_list_view_selected ();
221 void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
222 void found_search_clicked ();
224 void freesound_list_view_selected ();
225 void freesound_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
226 void freesound_search_clicked ();
227 void freesound_more_clicked ();
228 void freesound_similar_clicked ();
231 void chooser_file_activated ();
232 std::string freesound_get_audio_file(Gtk::TreeIter iter);
234 bool on_audio_filter (const Gtk::FileFilter::Info& filter_info);
235 bool on_midi_filter (const Gtk::FileFilter::Info& filter_info);
236 bool on_audio_and_midi_filter (const Gtk::FileFilter::Info& filter_info);
238 void set_action_sensitive (bool);
240 virtual bool reset_options() { return true; }
244 virtual void do_something (int action);
247 class SoundFileChooser : public SoundFileBrowser
250 SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
251 virtual ~SoundFileChooser () {};
253 std::string get_filename ();
259 class SoundFileOmega : public SoundFileBrowser
263 SoundFileOmega (std::string title, ARDOUR::Session* _s,
264 uint32_t selected_audio_tracks, uint32_t selected_midi_tracks,
266 Editing::ImportMode mode_hint = Editing::ImportAsTrack);
268 void reset (uint32_t selected_audio_tracks, uint32_t selected_midi_tracks);
270 Gtk::ComboBoxText action_combo;
271 Gtk::ComboBoxText where_combo;
272 Gtk::ComboBoxText channel_combo;
273 Gtk::ComboBoxText src_combo;
275 Gtk::CheckButton copy_files_btn;
277 void set_mode (Editing::ImportMode);
278 Editing::ImportMode get_mode() const;
279 Editing::ImportPosition get_position() const;
280 Editing::ImportDisposition get_channel_disposition() const;
281 ARDOUR::SrcQuality get_src_quality() const;
287 uint32_t selected_audio_track_cnt;
288 uint32_t selected_midi_track_cnt;
290 typedef std::map<std::string,Editing::ImportDisposition> DispositionMap;
291 DispositionMap disposition_map;
295 Gtk::VBox block_three;
296 Gtk::VBox block_four;
298 bool check_info (const std::vector<std::string>& paths,
299 bool& same_size, bool& src_needed, bool& multichannel);
301 static bool check_link_status (const ARDOUR::Session*, const std::vector<std::string>& paths);
303 void file_selection_changed ();
304 bool reset_options ();
305 void reset_options_noret ();
306 bool bad_file_message ();
308 void do_something (int action);
311 #endif // __ardour_sfdb_ui_h__