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);
67 // set_policy (false, true, false);
72 sr_label1.set_text (string_compose
73 (_("This session will playback and record at %1 Hz"),
74 engine.frame_rate()));
75 sr_label2.set_text (_("This rate is set by JACK and cannot be changed.\n"
76 "If you want to use a different sample rate\n"
77 "please exit and restart JACK"));
78 sr_box.set_spacing (12);
79 sr_box.set_border_width (12);
80 sr_box.pack_start (sr_label1, false, false);
81 sr_box.pack_start (sr_label2, false, false);
82 sr_frame.add (sr_box);
86 connect_to_physical_inputs_button.set_active (true);
87 connect_to_physical_inputs_button.set_name ("NewSessionDialogButton");
89 HBox* input_limit_box = manage (new HBox);
90 input_limit_box->set_spacing (7);
91 input_limit_box->pack_start (in_count_label, false, false);
92 input_limit_box->pack_start (in_count_spinner, false, false);
94 input_label.set_alignment (0.1, 0.5);
95 input_vbox.pack_start (input_label, false, false, 7);
96 input_vbox.pack_start (connect_to_physical_inputs_button, false, false);
98 if (engine.n_physical_inputs() > 2) {
99 input_vbox.pack_start (*input_limit_box, false, false);
104 use_master_button.set_active (true);
105 use_master_button.set_name ("NewSessionDialogButton");
107 connect_to_physical_outputs_button.set_group (connect_to_master_button.get_group());
108 manual_connect_outputs_button.set_group (connect_to_master_button.get_group());
109 connect_to_master_button.set_active (true);
111 connect_to_physical_outputs_button.set_name ("NewSessionDialogButton");
112 manual_connect_outputs_button.set_name ("NewSessionDialogButton");
113 connect_to_master_button.set_name ("NewSessionDialogButton");
114 use_control_button.set_name ("NewSessionDialogButton");
116 out_count_adjustment.set_value (engine.n_physical_outputs());
117 in_count_adjustment.set_value (engine.n_physical_inputs());
119 set_popdown_strings (control_out_channel_combo, channel_combo_strings);
120 control_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
121 // use stereo as default
122 control_out_channel_combo.set_active_text (channel_combo_strings.front());
124 set_popdown_strings (master_out_channel_combo, channel_combo_strings);
125 master_out_channel_combo.set_name (X_("NewSessionChannelCombo"));
126 // use stereo as default
127 master_out_channel_combo.set_active_text (channel_combo_strings.front());
130 out_table.set_col_spacings (7);
131 out_table.set_row_spacings (7);
132 if (engine.n_physical_outputs() > 2) {
133 out_table.attach (out_count_label, 0, 1, 0, 1, 0, 0);
134 out_table.attach (out_count_spinner, 1, 2, 0, 1, 0, 0);
136 out_table.attach (use_control_button, 0, 1, 1, 2, 0, 0);
137 out_table.attach (control_out_channel_combo, 1, 2, 1, 2, 0, 0);
138 out_table.attach (use_master_button, 0, 1, 2, 3, 0, 0);
139 out_table.attach (master_out_channel_combo, 1, 2, 2, 3, 0, 0);
141 output_label.set_alignment (0.1, 0.5);
142 output_vbox.pack_start (output_label, true, true, 7);
143 output_vbox.pack_start (out_table, false, false, 5);
144 output_vbox.pack_start (connect_to_master_button, false);
145 output_vbox.pack_start (connect_to_physical_outputs_button, false);
146 output_vbox.pack_start (manual_connect_outputs_button, false);
148 input_hbox.pack_start (input_vbox, false, false);
149 output_hbox.pack_start (output_vbox, false, false);
151 VBox* template_vbox = manage (new VBox);
152 Label* template_label = manage (new Label (_("Session template")));
154 template_label->set_alignment (0.1, 0.5);
155 template_vbox->pack_start (*template_label, true, true, 7);
156 template_vbox->pack_start (template_combo, false, false);
158 io_box.set_border_width (12);
159 io_box.set_spacing (7);
160 io_box.pack_start (*template_vbox);
162 io_box.pack_start (input_hbox);
163 io_box.pack_start (output_hbox);
167 option_hbox.set_spacing (7);
168 option_hbox.pack_start (io_box);
170 fsbox.set_border_width (12);
171 fsbox.set_spacing (7);
172 fsbox.pack_start (file_selector.table, false, false);
174 notebook.pages().push_back (TabElem (fsbox, _("Location")));
175 notebook.pages().push_back (TabElem (option_hbox, _("Configuration")));
178 show_again.set_active(true);
179 show_again.toggled.connect (mem_fun(*this, &NewSessionDialog::show_again_toggled));
180 file_selector.button_box.pack_end(show_again, false, false);
183 main_vbox.set_border_width (12);
184 main_vbox.set_border_width (12);
185 main_vbox.set_spacing (7);
186 main_vbox.pack_start (sr_frame, false, false);
187 main_vbox.pack_start (notebook, false, false);
188 main_vbox.pack_start (file_selector.button_box, false, false);
192 // template_selector.shift_made.connect (
193 // mem_fun(*this, &NewSessionDialog::mix_template_shift));
194 // template_selector.control_made.connect (
195 // mem_fun(*this, &NewSessionDialog::mix_template_control));
197 file_selector.cancel_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), -1));
198 file_selector.op_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 0));
199 file_selector.Expanded.connect (mem_fun(*this, &NewSessionDialog::file_selector_expansion));
201 delete_event.connect (mem_fun(*this, &ArdourDialog::wm_close_event));
202 show.connect (mem_fun(*this, &NewSessionDialog::fixup_at_show));
204 file_selector.entry_label.set_name ("NewSessionMainLabel");
205 file_selector.where_label.set_name ("NewSessionMainLabel");
206 template_label->set_name ("NewSessionIOLabel");
207 input_label.set_name ("NewSessionIOLabel");
208 output_label.set_name ("NewSessionIOLabel");
209 sr_label1.set_name ("NewSessionSR1Label");
210 sr_label2.set_name ("NewSessionSR2Label");
212 if (given_path.empty()) {
213 Session::FavoriteDirs favs;
214 Session::read_favorite_dirs (favs);
215 file_selector.set_favorites (favs);
217 file_selector.set_path (given_path, true);
218 notebook.set_page (-1);
219 notebook.show.connect (bind (mem_fun (notebook, &Notebook::set_page), -1));
222 set_default_size(531, 358);
226 NewSessionDialog::file_selector_expansion (bool expanded)
229 fsbox.pack_start (file_selector.expansion_vbox);
230 fsbox.reorder_child (file_selector.expansion_vbox, 2);
232 fsbox.remove (file_selector.expansion_vbox);
237 NewSessionDialog::fixup_at_show ()
239 // if (template_selector.clist().rows().size() == 0) {
240 // use_template_button.set_sensitive (false);
243 Session::FavoriteDirs favs;
244 Session::read_favorite_dirs (favs);
245 file_selector.set_favorites (favs);
247 file_selector.entry.grab_focus ();
251 NewSessionDialog::_mix_template_refiller (CList &clist, void *arg)
254 ((NewSessionDialog*) arg)->mix_template_refiller (clist);
258 NewSessionDialog::mix_template_refiller (CList &clist)
260 const gchar *rowdata[2];
261 list<string> templates;
262 list<string>::iterator i;
264 Session::get_template_list(templates);
266 rowdata[0] = _("blank");
267 clist.insert_row (0, rowdata);
270 for (row=1, i=templates.begin(); i != templates.end(); ++row, ++i) {
271 rowdata[0] = (*i).c_str();
272 clist.insert_row (row, rowdata);
277 NewSessionDialog::mix_template_shift (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
279 if (res && res->text){
280 Session::delete_template(*res->text);
281 // template_selector.rescan();
286 NewSessionDialog::mix_template_control (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res)
289 if (res && res->text) {
290 ArdourPrompter prompter (true);
291 prompter.set_prompt(_("Name for mix template:"));
293 string old_name = *(res->text);
294 prompter.set_initial_text (old_name);
295 prompter.done.connect (Gtk::Main::quit.slot());
300 if (prompter.status == Gtkmm2ext::Prompter::entered) {
303 prompter.get_result (name);
305 if (name.length() && name != old_name) {
306 Session::rename_template(old_name, name);
307 template_selector.rescan();
315 NewSessionDialog::show_again_toggled ()
317 Config->set_no_new_session_dialog(!show_again.get_active());
318 Config->save_state();
322 NewSessionDialog::reset_templates ()
325 templates.push_back (_("No template - create tracks/busses manually"));
326 Session::get_template_list (templates);
327 set_popdown_strings (template_combo, templates);
331 NewSessionDialog::get_template_name()
333 string str = template_combo.get_entry()->get_text();
334 if (str.substr (0, 11) == _("No template")) {