first pass at thorwil's mockup of import dialog; remove some JACK error messages...
[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 <glibmm/ustring.h>
26
27 #include <sigc++/signal.h>
28
29 #include <gtkmm/box.h>
30 #include <gtkmm/button.h>
31 #include <gtkmm/checkbutton.h>
32 #include <gtkmm/comboboxtext.h>
33 #include <gtkmm/dialog.h>
34 #include <gtkmm/entry.h>
35 #include <gtkmm/filechooserwidget.h>
36 #include <gtkmm/frame.h>
37 #include <gtkmm/label.h>
38
39 #include <ardour/session.h>
40 #include <ardour/audiofilesource.h>
41
42 #include "ardour_dialog.h"
43 #include "editing.h"
44
45 namespace ARDOUR {
46         class Session;
47 };
48
49 class SoundFileBox : public Gtk::VBox
50 {
51   public:
52         SoundFileBox ();
53         virtual ~SoundFileBox () {};
54         
55         void set_session (ARDOUR::Session* s);
56         bool setup_labels (const Glib::ustring& filename);
57
58         void audition();
59
60   protected:
61         ARDOUR::Session* _session;
62         Glib::ustring path;
63         
64         ARDOUR::SoundFileInfo sf_info;
65         
66         pid_t current_pid;
67         
68         Gtk::Label length;
69         Gtk::Label format;
70         Gtk::Label channels;
71         Gtk::Label samplerate;
72         Gtk::Label timecode;
73         
74         Gtk::Frame border_frame;
75         
76         Gtk::TextView tags_entry;
77         
78         Gtk::VBox main_box;
79         Gtk::VBox path_box;
80         Gtk::HBox bottom_box;
81         
82         Gtk::Button play_btn;
83         Gtk::Button stop_btn;
84         Gtk::Button apply_btn;
85         
86         bool tags_entry_left (GdkEventFocus* event);
87         void stop_btn_clicked ();
88         void tags_changed ();
89         
90         void audition_status_changed (bool state);
91 };
92
93 class SoundFileBrowser : public ArdourDialog
94 {
95   private:
96         class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
97         {
98           public:
99                 Gtk::TreeModelColumn<Glib::ustring> pathname;
100                 
101                 FoundTagColumns() { add(pathname); }
102         };
103         
104         FoundTagColumns found_list_columns;
105         Glib::RefPtr<Gtk::ListStore> found_list;
106
107         Gtk::RadioButtonGroup rgroup1;
108         Gtk::RadioButtonGroup rgroup2;
109
110   public:
111         SoundFileBrowser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s, int selected_tracks);
112         virtual ~SoundFileBrowser ();
113         
114         virtual void set_session (ARDOUR::Session*);
115         std::vector<Glib::ustring> get_paths ();
116         
117         Gtk::FileChooserWidget chooser;
118         Gtk::TreeView found_list_view;
119
120         Gtk::CheckButton split_files;
121         Gtk::CheckButton merge_stereo;
122
123         Gtk::ComboBoxText action_combo;
124         Gtk::ComboBoxText where_combo;
125         
126         Gtk::RadioButton import;
127         Gtk::RadioButton embed;
128
129         Editing::ImportMode get_mode() const;
130
131   protected:
132         Editing::ImportMode mode;
133         Gtk::FileFilter custom_filter;
134         Gtk::FileFilter matchall_filter;
135         SoundFileBox preview;
136
137         static Glib::ustring persistent_folder;
138
139         Gtk::Entry found_entry;
140         Gtk::Button found_search_btn;
141         Gtk::Notebook notebook;
142
143         void update_preview ();
144         void found_list_view_selected ();
145         void found_list_view_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn*);
146         void found_search_clicked ();
147
148         void chooser_file_activated ();
149         
150         bool on_custom (const Gtk::FileFilter::Info& filter_info);
151
152         int selected_track_cnt;
153
154         Gtk::HBox options;
155         Gtk::VBox block_two;
156         Gtk::VBox block_three;
157         Gtk::VBox block_four;
158
159         static bool check_multichannel_status (const std::vector<Glib::ustring>& paths);
160         static bool check_link_status (const ARDOUR::Session&, const std::vector<Glib::ustring>& paths);
161
162         void reset_options ();
163 };
164
165 class SoundFileChooser : public SoundFileBrowser
166 {
167   public:
168         SoundFileChooser (Gtk::Window& parent, std::string title, ARDOUR::Session* _s = 0);
169         virtual ~SoundFileChooser () {};
170         
171         Glib::ustring get_filename ();
172
173   private:
174         // SoundFileBrowser browser;
175 };
176
177 #endif // __ardour_sfdb_ui_h__