769e4ff02d9e4c587e735570f140b0ff49a4ff45
[ardour.git] / gtk2_ardour / sfdb_ui.h
1 /*
2     Copyright (C) 2005 Paul Davis 
3     Written by Taybin Rutkin
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19
20 */
21
22 #ifndef __ardour_sfdb_ui_h__
23 #define __ardour_sfdb_ui_h__
24
25 #include <string>
26 #include <vector>
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/dialog.h>
34 #include <gtkmm/entry.h>
35 #include <gtkmm/filechooserwidget.h>
36 #include <gtkmm/comboboxtext.h>
37 #include <gtkmm/frame.h>
38 #include <gtkmm/label.h>
39 #include <gtkmm/liststore.h>
40 #include <gtkmm/treeview.h>
41
42 #include <ardour/session.h>
43 #include <ardour/externalsource.h>
44
45 #include "ardour_dialog.h"
46 #include "editing.h"
47
48 class SoundFileBox : public Gtk::VBox
49 {
50   public:
51     SoundFileBox ();
52     virtual ~SoundFileBox () {};
53
54     void set_session (ARDOUR::Session* s);
55     bool setup_labels (std::string filename);
56
57   protected:
58         ARDOUR::Session* _session;
59         std::string path;
60
61     struct LabelModelColumns : public Gtk::TreeModel::ColumnRecord
62     {
63     public:
64       Gtk::TreeModelColumn<std::string> field;
65       Gtk::TreeModelColumn<std::string> data;
66
67       LabelModelColumns() { add(field); add(data); }
68     };
69
70     LabelModelColumns label_columns;
71     
72         ARDOUR::SoundFileInfo sf_info;
73
74     pid_t current_pid;
75
76     Gtk::Label length;
77     Gtk::Label format;
78     Gtk::Label channels;
79     Gtk::Label samplerate;
80
81     Gtk::TreeView field_view;
82     Glib::RefPtr<Gtk::ListStore> fields;
83     std::string selected_field;
84
85     Gtk::Frame border_frame;
86
87     Gtk::VBox main_box;
88     Gtk::VBox path_box;
89     Gtk::HBox top_box;
90     Gtk::HBox bottom_box;
91
92     Gtk::Button play_btn;
93     Gtk::Button stop_btn;
94     Gtk::Button add_field_btn;
95     Gtk::Button remove_field_btn;
96
97     void setup_fields ();
98
99     void play_btn_clicked ();
100     void stop_btn_clicked ();
101     void add_field_clicked ();
102     void remove_field_clicked ();
103         void delete_row (const Gtk::TreeModel::iterator& iter);
104
105     void field_selected ();
106     void audition_status_changed (bool state);
107 };
108
109 class SoundFileBrowser : public ArdourDialog
110 {
111   public:
112     SoundFileBrowser (std::string title, ARDOUR::Session* _s = 0);
113     virtual ~SoundFileBrowser () {}; 
114
115     virtual void set_session (ARDOUR::Session*);
116
117   protected:
118     Gtk::FileChooserWidget chooser;
119     SoundFileBox preview;
120
121     void update_preview ();
122 };
123
124 class SoundFileChooser : public SoundFileBrowser
125 {
126   public:
127     SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
128     virtual ~SoundFileChooser () {};
129
130     std::string get_filename () {return chooser.get_filename();};
131 };
132
133 class SoundFileOmega : public SoundFileBrowser
134 {
135   public:
136     SoundFileOmega (std::string title, ARDOUR::Session* _s);
137     virtual ~SoundFileOmega () {};
138
139     /* these are returned by the Dialog::run() method. note
140        that builtin GTK responses are all negative, leaving
141        positive values for application-defined responses.
142     */
143
144     const static int ResponseImport = 1;
145     const static int ResponseEmbed = 2;
146
147     std::vector<Glib::ustring> get_paths ();
148     bool get_split ();
149
150     void set_mode (Editing::ImportMode);
151     Editing::ImportMode get_mode ();
152
153   protected:
154     Gtk::CheckButton  split_check;
155     Gtk::ComboBoxText mode_combo;
156
157     void mode_changed ();
158
159     static std::vector<std::string> mode_strings;
160 };
161
162 #endif // __ardour_sfdb_ui_h__