Merged with trunk R1141
[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/audiofilesource.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     Gtk::Label timecode;
81
82     Gtk::TreeView field_view;
83     Glib::RefPtr<Gtk::ListStore> fields;
84     std::string selected_field;
85
86     Gtk::Frame border_frame;
87
88     Gtk::VBox main_box;
89     Gtk::VBox path_box;
90     Gtk::HBox top_box;
91     Gtk::HBox bottom_box;
92
93     Gtk::Button play_btn;
94     Gtk::Button stop_btn;
95     Gtk::Button add_field_btn;
96     Gtk::Button remove_field_btn;
97
98     void setup_fields ();
99
100     void play_btn_clicked ();
101     void stop_btn_clicked ();
102     void add_field_clicked ();
103     void remove_field_clicked ();
104         void field_edited (const Glib::ustring&, const Glib::ustring&);
105         void delete_row (const Gtk::TreeModel::iterator& iter);
106
107     void field_selected ();
108     void audition_status_changed (bool state);
109 };
110
111 class SoundFileBrowser : public ArdourDialog
112 {
113   public:
114     SoundFileBrowser (std::string title, ARDOUR::Session* _s = 0);
115     virtual ~SoundFileBrowser () {}; 
116
117     virtual void set_session (ARDOUR::Session*);
118
119   protected:
120     Gtk::FileChooserWidget chooser;
121     SoundFileBox preview;
122
123     void update_preview ();
124 };
125
126 class SoundFileChooser : public SoundFileBrowser
127 {
128   public:
129     SoundFileChooser (std::string title, ARDOUR::Session* _s = 0);
130     virtual ~SoundFileChooser () {};
131
132     std::string get_filename () {return chooser.get_filename();};
133 };
134
135 class SoundFileOmega : public SoundFileBrowser
136 {
137   public:
138     SoundFileOmega (std::string title, ARDOUR::Session* _s);
139     virtual ~SoundFileOmega () {};
140
141     /* these are returned by the Dialog::run() method. note
142        that builtin GTK responses are all negative, leaving
143        positive values for application-defined responses.
144     */
145
146     const static int ResponseImport = 1;
147     const static int ResponseEmbed = 2;
148
149     std::vector<Glib::ustring> get_paths ();
150     bool get_split ();
151
152     void set_mode (Editing::ImportMode);
153     Editing::ImportMode get_mode ();
154
155   protected:
156     Gtk::CheckButton  split_check;
157     Gtk::ComboBoxText mode_combo;
158
159     void mode_changed ();
160
161     static std::vector<std::string> mode_strings;
162 };
163
164 #endif // __ardour_sfdb_ui_h__