split SoundFileBrowser back into SoundFileOmega; make SoundFileChooser work again...
[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   public:
120         SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s);
121         virtual ~SoundFileBrowser ();
122         
123         virtual void set_session (ARDOUR::Session*);
124         std::vector<Glib::ustring> get_paths ();
125         
126         Gtk::FileChooserWidget chooser;
127         Gtk::TreeView found_list_view;
128
129   protected:
130         bool resetting_ourselves;
131         
132         Gtk::FileFilter custom_filter;
133         Gtk::FileFilter matchall_filter;
134         SoundFileBox preview;
135
136         static Glib::ustring persistent_folder;
137
138         Gtk::Entry found_entry;
139         Gtk::Button found_search_btn;
140         Gtk::Notebook notebook;
141
142         void update_preview ();
143         void found_list_view_selected ();
144         void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
145         void found_search_clicked ();
146
147         void chooser_file_activated ();
148         
149         bool on_custom (const Gtk::FileFilter::Info& filter_info);
150
151         virtual bool reset_options() { return true; }
152 };
153
154 class SoundFileChooser : public SoundFileBrowser
155 {
156   public:
157         SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
158         virtual ~SoundFileChooser () {};
159         
160         Glib::ustring get_filename ();
161
162   private:
163         // SoundFileBrowser browser;
164 };
165
166 class SoundFileOmega : public SoundFileBrowser
167 {
168   private:
169         Gtk::RadioButtonGroup rgroup1;
170         Gtk::RadioButtonGroup rgroup2;
171
172   public:
173         SoundFileOmega (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, int selected_tracks);
174         
175         void reset (int selected_tracks);
176         
177         Gtk::ComboBoxText action_combo;
178         Gtk::ComboBoxText where_combo;
179         Gtk::ComboBoxText channel_combo;
180         
181         Gtk::RadioButton import;
182         Gtk::RadioButton embed;
183
184         Editing::ImportMode get_mode() const;
185         Editing::ImportPosition get_position() const;
186         Editing::ImportDisposition get_channel_disposition() const;
187
188   private:
189         uint32_t selected_track_cnt;
190
191         typedef std::map<Glib::ustring,Editing::ImportDisposition> DispositionMap;
192         DispositionMap disposition_map;
193
194         Gtk::HBox options;
195         Gtk::VBox block_two;
196         Gtk::VBox block_three;
197         Gtk::VBox block_four;
198
199         static bool check_multichannel_status (const std::vector<Glib::ustring>& paths, bool& same_size, bool& err);
200         static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths);
201
202         void file_selection_changed ();
203         bool reset_options ();
204         void reset_options_noret ();
205         bool bad_file_message ();
206 };
207
208 #endif // __ardour_sfdb_ui_h__