merge from 2.0-ongoing by hand, minus key binding editor
[ardour.git] / gtk2_ardour / sfdb_ui.h
1 /*
2     Copyright (C) 2005-2006 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_sfdb_ui_h__
21 #define __ardour_sfdb_ui_h__
22
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <glibmm/ustring.h>
27
28 #include <sigc++/signal.h>
29
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
40 #include <ardour/session.h>
41 #include <ardour/audiofilesource.h>
42
43 #include "ardour_dialog.h"
44 #include "editing.h"
45
46 namespace ARDOUR {
47         class Session;
48 };
49
50 class GainMeter;
51
52 class SoundFileBox : public Gtk::VBox
53 {
54   public:
55         SoundFileBox (bool persistent);
56         virtual ~SoundFileBox () {};
57         
58         void set_session (ARDOUR::Session* s);
59         bool setup_labels (const Glib::ustring& filename);
60
61         void audition();
62         bool audition_oneshot();
63         bool autoplay () const;
64
65   protected:
66         ARDOUR::Session* _session;
67         Glib::ustring path;
68         
69         ARDOUR::SoundFileInfo sf_info;
70         
71         Gtk::Table table;
72         
73         Gtk::Label length;
74         Gtk::Label format;
75         Gtk::Label channels;
76         Gtk::Label samplerate;
77         Gtk::Label timecode;
78
79         Gtk::Label channels_value;
80         Gtk::Label samplerate_value;
81         
82         Gtk::Label format_text;
83         AudioClock length_clock;
84         AudioClock timecode_clock;
85
86         Gtk::Frame border_frame;
87         Gtk::Label preview_label;
88
89         Gtk::TextView tags_entry;
90         
91         Gtk::VBox main_box;
92         Gtk::VBox path_box;
93         Gtk::HBox bottom_box;
94         
95         Gtk::Button play_btn;
96         Gtk::Button stop_btn;
97         Gtk::CheckButton autoplay_btn;
98         Gtk::Button apply_btn;
99
100         bool tags_entry_left (GdkEventFocus* event);
101         void tags_changed ();
102         void save_tags (const std::vector<std::string>&);
103         void stop_audition ();
104 };
105
106 class SoundFileBrowser : public ArdourDialog
107 {
108   private:
109         class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
110         {
111           public:
112                 Gtk::TreeModelColumn<Glib::ustring> pathname;
113                 
114                 FoundTagColumns() { add(pathname); }
115         };
116         
117         FoundTagColumns found_list_columns;
118         Glib::RefPtr<Gtk::ListStore> found_list;
119
120   public:
121         SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, bool persistent);
122         virtual ~SoundFileBrowser ();
123         
124         virtual void set_session (ARDOUR::Session*);
125         std::vector<Glib::ustring> get_paths ();
126         
127         void clear_selection ();
128
129         Gtk::FileChooserWidget chooser;
130         Gtk::TreeView found_list_view;
131
132   protected:
133         bool resetting_ourselves;
134         
135         Gtk::FileFilter custom_filter;
136         Gtk::FileFilter matchall_filter;
137         SoundFileBox preview;
138         Gtk::HBox hpacker;
139
140         static Glib::ustring persistent_folder;
141
142         Gtk::Entry found_entry;
143         Gtk::Button found_search_btn;
144         Gtk::Notebook notebook;
145
146         GainMeter* gm;
147         Gtk::VBox meter_packer;
148         void add_gain_meter ();
149         void remove_gain_meter ();
150         void meter ();
151         void start_metering ();
152         void stop_metering ();
153         sigc::connection metering_connection;
154
155         void update_preview ();
156         void found_list_view_selected ();
157         void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
158         void found_search_clicked ();
159
160         void chooser_file_activated ();
161         
162         bool on_custom (const Gtk::FileFilter::Info& filter_info);
163
164         virtual bool reset_options() { return true; }
165
166   protected:
167         void on_show();
168
169 };
170
171 class SoundFileChooser : public SoundFileBrowser
172 {
173   public:
174         SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
175         virtual ~SoundFileChooser () {};
176         
177         Glib::ustring get_filename ();
178
179   protected:
180         void on_hide();
181 };
182
183 class SoundFileOmega : public SoundFileBrowser
184 {
185
186   public:
187         SoundFileOmega (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, int selected_tracks, bool persistent, 
188                         Editing::ImportMode mode_hint = Editing::ImportAsTrack);
189         
190         void reset (int selected_tracks);
191         
192         Gtk::ComboBoxText action_combo;
193         Gtk::ComboBoxText where_combo;
194         Gtk::ComboBoxText channel_combo;
195         Gtk::ComboBoxText src_combo;
196
197         Gtk::CheckButton copy_files_btn;
198
199         void set_mode (Editing::ImportMode);
200         Editing::ImportMode get_mode() const;
201         Editing::ImportPosition get_position() const;
202         Editing::ImportDisposition get_channel_disposition() const;
203         ARDOUR::SrcQuality get_src_quality() const;
204
205   protected:
206         void on_hide();
207
208   private:
209         uint32_t selected_track_cnt;
210
211         typedef std::map<Glib::ustring,Editing::ImportDisposition> DispositionMap;
212         DispositionMap disposition_map;
213
214         Gtk::HBox options;
215         Gtk::VBox block_two;
216         Gtk::VBox block_three;
217         Gtk::VBox block_four;
218
219         bool check_info (const std::vector<Glib::ustring>& paths, 
220                          bool& same_size, bool& src_needed, bool& multichannel);
221
222         static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths);
223
224         void file_selection_changed ();
225         bool reset_options ();
226         void reset_options_noret ();
227         bool bad_file_message ();
228 };
229
230 #endif // __ardour_sfdb_ui_h__