2ad7ebf9b60a37f5bf6b76f0fc67563264fb2b06
[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 SoundFileBox : public Gtk::VBox
51 {
52   public:
53         SoundFileBox ();
54         virtual ~SoundFileBox () {};
55         
56         void set_session (ARDOUR::Session* s);
57         bool setup_labels (const Glib::ustring& filename);
58
59         void audition();
60
61   protected:
62         ARDOUR::Session* _session;
63         Glib::ustring path;
64         
65         ARDOUR::SoundFileInfo sf_info;
66         
67         pid_t current_pid;
68
69         Gtk::Table table;
70         
71         Gtk::Label length;
72         Gtk::Label format;
73         Gtk::Label channels;
74         Gtk::Label samplerate;
75         Gtk::Label timecode;
76
77         Gtk::Label channels_value;
78         Gtk::Label samplerate_value;
79         
80         Gtk::TextView format_text;
81         AudioClock length_clock;
82         AudioClock timecode_clock;
83
84         Gtk::Frame border_frame;
85         Gtk::Label preview_label;
86
87         Gtk::TextView tags_entry;
88         
89         Gtk::VBox main_box;
90         Gtk::VBox path_box;
91         Gtk::HBox bottom_box;
92         
93         Gtk::Button play_btn;
94         Gtk::Button stop_btn;
95         Gtk::Button apply_btn;
96         
97         bool tags_entry_left (GdkEventFocus* event);
98         void stop_btn_clicked ();
99         void tags_changed ();
100         
101         void audition_status_changed (bool state);
102         sigc::connection audition_connection;
103 };
104
105 class SoundFileBrowser : public ArdourDialog
106 {
107   private:
108         class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
109         {
110           public:
111                 Gtk::TreeModelColumn<Glib::ustring> pathname;
112                 
113                 FoundTagColumns() { add(pathname); }
114         };
115         
116         FoundTagColumns found_list_columns;
117         Glib::RefPtr<Gtk::ListStore> found_list;
118
119         Gtk::RadioButtonGroup rgroup1;
120         Gtk::RadioButtonGroup rgroup2;
121
122   public:
123         SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, int selected_tracks);
124         virtual ~SoundFileBrowser ();
125         
126         virtual void set_session (ARDOUR::Session*);
127         std::vector<Glib::ustring> get_paths ();
128         
129         void reset (int selected_tracks);
130         
131         Gtk::FileChooserWidget chooser;
132         Gtk::TreeView found_list_view;
133
134         Gtk::ComboBoxText action_combo;
135         Gtk::ComboBoxText where_combo;
136         Gtk::ComboBoxText channel_combo;
137         
138         Gtk::RadioButton import;
139         Gtk::RadioButton embed;
140
141         Editing::ImportMode get_mode() const;
142         Editing::ImportPosition get_position() const;
143         Editing::ImportDisposition get_channel_disposition() const;
144
145   protected:
146         Gtk::FileFilter custom_filter;
147         Gtk::FileFilter matchall_filter;
148         SoundFileBox preview;
149
150         static Glib::ustring persistent_folder;
151
152         Gtk::Entry found_entry;
153         Gtk::Button found_search_btn;
154         Gtk::Notebook notebook;
155
156         void update_preview ();
157         void found_list_view_selected ();
158         void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
159         void found_search_clicked ();
160
161         void chooser_file_activated ();
162         
163         bool on_custom (const Gtk::FileFilter::Info& filter_info);
164         void file_selection_changed ();
165
166         int selected_track_cnt;
167
168         typedef std::map<Glib::ustring,Editing::ImportDisposition> DispositionMap;
169         DispositionMap disposition_map;
170
171         bool resetting_ourselves;
172         
173         Gtk::HBox options;
174         Gtk::VBox block_two;
175         Gtk::VBox block_three;
176         Gtk::VBox block_four;
177
178         static bool check_multichannel_status (const std::vector<Glib::ustring>& paths, bool& same_size, bool& err);
179         static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths);
180
181         bool reset_options ();
182         void reset_options_noret ();
183         bool bad_file_message ();
184 };
185
186 class SoundFileChooser : public SoundFileBrowser
187 {
188   public:
189         SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
190         virtual ~SoundFileChooser () {};
191         
192         Glib::ustring get_filename ();
193
194   private:
195         // SoundFileBrowser browser;
196 };
197
198 #endif // __ardour_sfdb_ui_h__