2 Copyright (C) 1999-2002 Paul Davis
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.
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.
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.
23 #include <ardour/session.h>
24 #include <ardour/audioengine.h>
27 #include "new_session_dialog.h"
29 using namespace Gtkmm2ext;
31 using namespace ARDOUR;
35 extern std::vector<string> channel_combo_strings;
37 NewSessionDialog::NewSessionDialog (ARDOUR::AudioEngine& engine, bool startup, string given_path)
38 : ArdourDialog ("new session dialog"),
39 file_selector (_("Session name:"), _("Create")),
40 use_control_button (_("use control outs")),
41 use_master_button (_("use master outs")),
42 connect_to_physical_inputs_button (_("automatically connect track inputs to physical ports")),
43 connect_to_master_button (_("automatically connect track outputs to master outs")),
44 connect_to_physical_outputs_button (_("automatically connect track outputs to physical ports")),
45 manual_connect_outputs_button (_("manually connect track outputs")),
46 in_count_adjustment (2, 1, 1000, 1, 2),
47 out_count_adjustment (2, 1, 1000, 1, 2),
48 output_label (_("Output Connections")),
49 input_label (_("Input Connections")),
50 expansion_button (_("Advanced...")),
52 show_again (_("show again")),
53 in_count_spinner (in_count_adjustment),
54 out_count_spinner (out_count_adjustment),
55 in_count_label (_("Hardware Inputs: use")),
56 out_count_label (_("Hardware Outputs: use"))
59 using namespace Notebook_Helpers;
61 set_name ("NewSessionDialog");
62 set_title (_("new session setup"));
63 set_wmclass (_("ardour_new_session"), "Ardour");
64 set_position (Gtk::WIN_POS_MOUSE);
65 set_keyboard_input (true);
66 set_policy (false, true, false);
71 sr_label1.set_text (compose
72 (_("This session will playback and record at %1 Hz"),
73 engine.frame_rate()));
74 sr_label2.set_text (_("This rate is set by JACK and cannot be changed.\n"
75 "If you want to use a different sample rate\n"
76 "please exit and restart JACK"));
77 sr_box.set_spacing (12);
78 sr_box.set_border_width (12);
79 sr_box.pack_start (sr_label1, false, false);
80 sr_box.pack_start (sr_label2, false, false);
81 sr_frame.add (sr_box);
85 connect_to_physical_inputs_button.set_active (true);
86 connect_to_physical_inputs_button.set_name ("NewSessionDialogButton");
88 HBox* input_limit_box = manage (new HBox);
89 input_limit_box->set_spacing (7);
90 input_limit_box->pack_start (in_count_label, false, false);
91 input_limit_box->pack_start (in_count_spinner, false, false);
93 input_label.set_alignment (0.1, 0.5);
94 input_vbox.pack_start (input_label, false, false, 7);
95 input_vbox.pack_start (connect_to_physical_inputs_button, false, false);
97 if (engine.n_physical_inputs() > 2) {
98 input_vbox.pack_start (*input_limit_box, false, false);
103 use_master_button.set_active (true);
104 use_master_button.set_name ("NewSessionDialogButton");
106 connect_to_physical_outputs_button.set_group (connect_to_master_button.group());
107 manual_connect_outputs_button.set_group (connect_to_master_button.group());
108 connect_to_master_button.set_active (true);
110 connect_to_physical_outputs_button.set_name ("NewSessionDialogButton");
111 manual_connect_outputs_button.set_name ("NewSessionDialogButton");
112 connect_to_master_button.set_name ("NewSessionDialogButton");
113 use_control_button.set_name ("NewSessionDialogButton");
115 out_count_adjustment.set_value (engine.n_physical_outputs());
116 in_count_adjustment.set_value (engine.n_physical_inputs());
118 control_out_channel_combo.set_popdown_strings (channel_combo_strings);
119 control_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
120 control_out_channel_combo.get_entry()->set_name (X_("NewSessionChannelCombo"));
121 control_out_channel_combo.get_popwin()->set_name (X_("NewSessionChannelCombo"));
122 // use stereo as default
123 control_out_channel_combo.get_list()->select_item (1);
125 master_out_channel_combo.set_popdown_strings (channel_combo_strings);
126 master_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
127 master_out_channel_combo.get_entry()->set_name (X_("NewSessionChannelCombo"));
128 master_out_channel_combo.get_popwin()->set_name (X_("NewSessionChannelCombo"));
129 // use stereo as default
130 master_out_channel_combo.get_list()->select_item (1);
133 out_table.set_col_spacings (7);
134 out_table.set_row_spacings (7);
135 if (engine.n_physical_outputs() > 2) {
136 out_table.attach (out_count_label, 0, 1, 0, 1, 0, 0);
137 out_table.attach (out_count_spinner, 1, 2, 0, 1, 0, 0);
139 out_table.attach (use_control_button, 0, 1, 1, 2, 0, 0);
140 out_table.attach (control_out_channel_combo, 1, 2, 1, 2, 0, 0);
141 out_table.attach (use_master_button, 0, 1, 2, 3, 0, 0);
142 out_table.attach (master_out_channel_combo, 1, 2, 2, 3, 0, 0);
144 output_label.set_alignment (0.1, 0.5);
145 output_vbox.pack_start (output_label, true, true, 7);
146 output_vbox.pack_start (out_table, false, false, 5);
147 output_vbox.pack_start (connect_to_master_button, false);
148 output_vbox.pack_start (connect_to_physical_outputs_button, false);
149 output_vbox.pack_start (manual_connect_outputs_button, false);
151 input_hbox.pack_start (input_vbox, false, false);
152 output_hbox.pack_start (output_vbox, false, false);
154 VBox* template_vbox = manage (new VBox);
155 Label* template_label = manage (new Label (_("Session template")));
157 template_label->set_alignment (0.1, 0.5);
158 template_vbox->pack_start (*template_label, true, true, 7);
159 template_vbox->pack_start (template_combo, false, false);
161 io_box.set_border_width (12);
162 io_box.set_spacing (7);
163 io_box.pack_start (*template_vbox);
165 io_box.pack_start (input_hbox);
166 io_box.pack_start (output_hbox);
170 option_hbox.set_spacing (7);
171 option_hbox.pack_start (io_box);
173 fsbox.set_border_width (12);
174 fsbox.set_spacing (7);
175 fsbox.pack_start (file_selector.table, false, false);
177 notebook.pages().push_back (TabElem (fsbox, _("Location")));
178 notebook.pages().push_back (TabElem (option_hbox, _("Configuration")));
181 show_again.set_active(true);
182 show_again.toggled.connect (slot (*this, &NewSessionDialog::show_again_toggled));
183 file_selector.button_box.pack_end(show_again, false, false);
186 main_vbox.set_border_width (12);
187 main_vbox.set_border_width (12);
188 main_vbox.set_spacing (7);
189 main_vbox.pack_start (sr_frame, false, false);
190 main_vbox.pack_start (notebook, false, false);
191 main_vbox.pack_start (file_selector.button_box, false, false);
195 // template_selector.shift_made.connect (
196 // slot (*this, &NewSessionDialog::mix_template_shift));
197 // template_selector.control_made.connect (
198 // slot (*this, &NewSessionDialog::mix_template_control));
200 file_selector.cancel_button.signal_clicked().connect (bind (slot (*this, &ArdourDialog::stop), -1));
201 file_selector.op_button.signal_clicked().connect (bind (slot (*this, &ArdourDialog::stop), 0));
202 file_selector.Expanded.connect (slot (*this, &NewSessionDialog::file_selector_expansion));
204 delete_event.connect (slot (*this, &ArdourDialog::wm_close_event));
205 show.connect (slot (*this, &NewSessionDialog::fixup_at_show));
207 file_selector.entry_label.set_name ("NewSessionMainLabel");
208 file_selector.where_label.set_name ("NewSessionMainLabel");
209 template_label->set_name ("NewSessionIOLabel");
210 input_label.set_name ("NewSessionIOLabel");
211 output_label.set_name ("NewSessionIOLabel");
212 sr_label1.set_name ("NewSessionSR1Label");
213 sr_label2.set_name ("NewSessionSR2Label");
215 if (given_path.empty()) {
216 Session::FavoriteDirs favs;
217 Session::read_favorite_dirs (favs);
218 file_selector.set_favorites (favs);
220 file_selector.set_path (given_path, true);
221 notebook.set_page (-1);
222 notebook.show.connect (bind (slot (notebook, &Notebook::set_page), -1));
225 set_default_size(531, 358);
229 NewSessionDialog::file_selector_expansion (bool expanded)
232 fsbox.pack_start (file_selector.expansion_vbox);
233 fsbox.reorder_child (file_selector.expansion_vbox, 2);
235 fsbox.remove (file_selector.expansion_vbox);
240 NewSessionDialog::fixup_at_show ()
242 // if (template_selector.clist().rows().size() == 0) {
243 // use_template_button.set_sensitive (false);
246 Session::FavoriteDirs favs;
247 Session::read_favorite_dirs (favs);
248 file_selector.set_favorites (favs);
250 file_selector.entry.grab_focus ();
254 NewSessionDialog::_mix_template_refiller (CList &clist, void *arg)
257 ((NewSessionDialog*) arg)->mix_template_refiller (clist);
261 NewSessionDialog::mix_template_refiller (CList &clist)
263 const gchar *rowdata[2];
264 list<string> templates;
265 list<string>::iterator i;
267 Session::get_template_list(templates);
269 rowdata[0] = _("blank");
270 clist.insert_row (0, rowdata);
273 for (row=1, i=templates.begin(); i != templates.end(); ++row, ++i) {
274 rowdata[0] = (*i).c_str();
275 clist.insert_row (row, rowdata);
280 NewSessionDialog::mix_template_shift (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
282 if (res && res->text){
283 Session::delete_template(*res->text);
284 // template_selector.rescan();
289 NewSessionDialog::mix_template_control (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
292 if (res && res->text) {
293 ArdourPrompter prompter (true);
294 prompter.set_prompt(_("Name for mix template:"));
296 string old_name = *(res->text);
297 prompter.set_initial_text (old_name);
298 prompter.done.connect (Gtk::Main::quit.slot());
303 if (prompter.status == Gtkmm2ext::Prompter::entered) {
306 prompter.get_result (name);
308 if (name.length() && name != old_name) {
309 Session::rename_template(old_name, name);
310 template_selector.rescan();
318 NewSessionDialog::show_again_toggled ()
320 Config->set_no_new_session_dialog(!show_again.get_active());
321 Config->save_state();
325 NewSessionDialog::reset_templates ()
328 templates.push_back (_("No template - create tracks/busses manually"));
329 Session::get_template_list (templates);
330 template_combo.set_popdown_strings (templates);
334 NewSessionDialog::get_template_name()
336 string str = template_combo.get_entry()->get_text();
337 if (str.substr (0, 11) == _("No template")) {