574e94ca274f99600a82b476c431679a9c0fd4f6
[ardour.git] / gtk2_ardour / sfdb_ui.cc
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 #include <gtkmm/box.h>
23 #include <gtkmm/stock.h>
24
25 #include <ardour/audio_library.h>
26
27 #include "sfdb_ui.h"
28
29 #include "i18n.h"
30
31 SoundFileBox::SoundFileBox (ARDOUR::Session* session)
32         :
33         current_pid(0),
34         fields(Gtk::ListStore::create(label_columns)),
35         main_box (false, 3),
36         top_box (true, 4),
37         bottom_box (true, 4),
38         play_btn(_("Play")),
39         stop_btn(_("Stop")),
40         add_field_btn(_("Add Field...")),
41         remove_field_btn(_("Remove Field"))
42 {
43         set_name (X_("SoundFileBox"));
44         border_frame.set_label (_("Soundfile Info"));
45         border_frame.add (main_box);
46
47         pack_start (border_frame);
48         set_border_width (4);
49
50         path_box.set_spacing (4);
51         path_box.pack_start (path, false, false);
52         path_box.pack_start (path_entry, true, true);
53
54         main_box.set_border_width (4);
55
56         main_box.pack_start(label, false, false);
57         main_box.pack_start(path_box, false, false);
58         main_box.pack_start(length, false, false);
59         main_box.pack_start(format, false, false);
60         main_box.pack_start(channels, false, false);
61         main_box.pack_start(samplerate, false, false);
62         main_box.pack_start(field_view, true, true);
63         main_box.pack_start(top_box, false, false);
64         main_box.pack_start(bottom_box, false, false);
65
66         field_view.set_size_request(200, 150);
67         top_box.set_homogeneous(true);
68         top_box.pack_start(add_field_btn);
69         top_box.pack_start(remove_field_btn);
70
71         remove_field_btn.set_sensitive(false);
72
73         bottom_box.set_homogeneous(true);
74         bottom_box.pack_start(play_btn);
75         bottom_box.pack_start(stop_btn);
76
77         play_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::play_btn_clicked));
78         stop_btn.signal_clicked().connect (mem_fun (*this, &SoundFileBox::stop_btn_clicked));
79
80         if (!session) {
81                 play_btn.set_sensitive(false);
82         } else {
83                 session->AuditionActive.connect(mem_fun (*this, &SoundFileBox::audition_status_changed));
84         }
85
86         add_field_btn.signal_clicked().connect
87                         (mem_fun (*this, &SoundFileBox::add_field_clicked));
88         remove_field_btn.signal_clicked().connect
89                         (mem_fun (*this, &SoundFileBox::remove_field_clicked));
90
91         field_view.get_selection()->signal_changed().connect (mem_fun (*this, &SoundFileBox::field_selected));
92         ARDOUR::Library->fields_changed.connect (mem_fun (*this, &SoundFileBox::setup_fields));
93
94         show_all();
95         stop_btn.hide();
96 }
97
98 int
99 SoundFileBox::setup_labels (string filename) 
100 {return 0;}
101
102 void
103 SoundFileBox::setup_fields ()
104 {}
105
106 void
107 SoundFileBox::play_btn_clicked ()
108 {}
109
110 void
111 SoundFileBox::stop_btn_clicked ()
112 {}
113
114 void
115 SoundFileBox::add_field_clicked ()
116 {}
117
118 void
119 SoundFileBox::remove_field_clicked ()
120 {}
121
122 void
123 SoundFileBox::audition_status_changed (bool state)
124 {}
125
126 void
127 SoundFileBox::field_selected ()
128 {}
129
130 bool
131 SoundFileBox::update (std::string filename)
132 {return true;}
133
134 SoundFileBrowser::SoundFileBrowser (std::string title)
135         :
136         ArdourDialog(title),
137         chooser(Gtk::FILE_CHOOSER_ACTION_OPEN),
138         preview(session)
139 {
140         get_vbox()->pack_start(chooser);
141         chooser.set_preview_widget(preview);
142
143         chooser.signal_update_preview().connect(mem_fun(*this, &SoundFileBrowser::update_preview));
144
145         show_all();
146 }
147
148 void
149 SoundFileBrowser::update_preview ()
150 {
151         chooser.set_preview_widget_active(preview.update(chooser.get_filename()));
152 }
153
154 SoundFileChooser::SoundFileChooser (std::string title)
155         :
156         SoundFileBrowser(title)
157 {
158         add_button (Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
159         add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
160
161         show_all();
162 }
163
164 SoundFileOmega::SoundFileOmega (std::string title)
165         :
166         SoundFileBrowser(title),
167         embed_btn (_("Embed")),
168         import_btn (_("Import")),
169         split_check (_("Split Channels"))
170 {
171         get_action_area()->pack_start(embed_btn);
172         get_action_area()->pack_start(import_btn);
173         add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
174
175         chooser.set_extra_widget(split_check);
176
177         embed_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::embed_clicked));
178         import_btn.signal_clicked().connect (mem_fun (*this, &SoundFileOmega::import_clicked));
179
180         show_all();
181 }
182
183 void
184 SoundFileOmega::embed_clicked ()
185 {
186         Embedded (chooser.get_filenames(), split_check.get_active());
187 }
188
189 void
190 SoundFileOmega::import_clicked ()
191 {
192         Imported (chooser.get_filenames(), split_check.get_active());
193 }
194