fb0b7da60022e96456fa6d341800b9939d84e31e
[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
26 #include <sigc++/signal.h>
27
28 #include <gtkmm/box.h>
29 #include <gtkmm/button.h>
30 #include <gtkmm/checkbutton.h>
31 #include <gtkmm/comboboxtext.h>
32 #include <gtkmm/dialog.h>
33 #include <gtkmm/entry.h>
34 #include <gtkmm/filechooserwidget.h>
35 #include <gtkmm/frame.h>
36 #include <gtkmm/label.h>
37
38 #include <ardour/session.h>
39 #include <ardour/audiofilesource.h>
40
41 #include "ardour_dialog.h"
42 #include "editing.h"
43
44 class SoundFileBox : public Gtk::VBox
45 {
46   public:
47         SoundFileBox ();
48         virtual ~SoundFileBox () {};
49         
50         void set_session (ARDOUR::Session* s);
51         bool setup_labels (std::string filename);
52
53   protected:
54         ARDOUR::Session* _session;
55         std::string path;
56         
57         ARDOUR::SoundFileInfo sf_info;
58         
59         pid_t current_pid;
60         
61         Gtk::Label length;
62         Gtk::Label format;
63         Gtk::Label channels;
64         Gtk::Label samplerate;
65         Gtk::Label timecode;
66         
67         Gtk::Frame border_frame;
68         
69         Gtk::Entry tags_entry;
70         
71         Gtk::VBox main_box;
72         Gtk::VBox path_box;
73         Gtk::HBox bottom_box;
74         
75         Gtk::Button play_btn;
76         Gtk::Button stop_btn;
77         Gtk::Button apply_btn;
78         
79         bool tags_entry_left (GdkEventFocus* event);
80         void play_btn_clicked ();
81         void stop_btn_clicked ();
82         void apply_btn_clicked ();
83         
84         void audition_status_changed (bool state);
85 };
86
87 class SoundFileBrowser : public ArdourDialog
88 {
89   public:
90         SoundFileBrowser (std::string title, ARDOUR::Session* _s = 0);
91         virtual ~SoundFileBrowser () {}; 
92         
93         virtual void set_session (ARDOUR::Session*);
94
95   protected:
96         Gtk::FileChooserWidget chooser;
97         Gtk::FileFilter filter;
98         SoundFileBox preview;
99         
100         class FoundTagColumns : public Gtk::TreeModel::ColumnRecord
101         {
102           public:
103                 Gtk::TreeModelColumn<string> pathname;
104                 
105                 FoundTagColumns() { add(pathname); }
106         };
107         
108         FoundTagColumns found_list_columns;
109         Glib::RefPtr<Gtk::ListStore> found_list;
110         Gtk::TreeView found_list_view;
111         Gtk::Entry found_entry;
112         Gtk::Button found_search_btn;
113         
114         Gtk::Notebook notebook;
115         
116         void update_preview ();
117         void found_list_view_selected ();
118         void found_search_clicked ();
119         
120         bool on_custom (const Gtk::FileFilter::Info& filter_info);
121 };
122
123 class SoundFileChooser : public SoundFileBrowser
124 {
125   public:
126         SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
127         virtual ~SoundFileChooser () {};
128         
129         std::string get_filename ();
130 };
131
132 class SoundFileOmega : public SoundFileBrowser
133 {
134   public:
135         SoundFileOmega (std::string title, ARDOUR::Session* _s);
136         virtual ~SoundFileOmega () {};
137         
138         /* these are returned by the Dialog::run() method. note
139            that builtin GTK responses are all negative, leaving
140            positive values for application-defined responses.
141         */
142         
143         const static int ResponseImport = 1;
144         const static int ResponseEmbed = 2;
145         
146         std::vector<Glib::ustring> get_paths ();
147         bool get_split ();
148         
149         void set_mode (Editing::ImportMode);
150         Editing::ImportMode get_mode ();
151
152   protected:
153         Gtk::CheckButton  split_check;
154         Gtk::ComboBoxText mode_combo;
155         
156         void mode_changed ();
157         
158         static std::vector<std::string> mode_strings;
159 };
160
161 #endif // __ardour_sfdb_ui_h__