From 05134740723a098b62d00559d89c39bd631516a8 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 20 Apr 2009 18:41:46 +0000 Subject: [PATCH] farewell NSD, we loved you sometimes, almost never git-svn-id: svn://localhost/ardour2/branches/3.0@4992 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/SConscript | 1 - gtk2_ardour/ardour_ui.cc | 299 +++----- gtk2_ardour/ardour_ui.h | 4 - gtk2_ardour/engine_dialog.cc | 9 +- gtk2_ardour/main.cc | 2 - gtk2_ardour/new_session_dialog.cc | 1055 ----------------------------- gtk2_ardour/new_session_dialog.h | 226 ------ gtk2_ardour/startup.cc | 560 +++++++++++++-- gtk2_ardour/startup.h | 111 ++- gtk2_ardour/wscript | 1 - 10 files changed, 717 insertions(+), 1551 deletions(-) delete mode 100644 gtk2_ardour/new_session_dialog.cc delete mode 100644 gtk2_ardour/new_session_dialog.h diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index e413be6eed..0d0161d456 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -204,7 +204,6 @@ midi_time_axis.cc mixer_strip.cc mixer_ui.cc nag.cc -new_session_dialog.cc option_editor.cc opts.cc panner.cc diff --git a/gtk2_ardour/ardour_ui.cc b/gtk2_ardour/ardour_ui.cc index 0c44a7829e..9731501474 100644 --- a/gtk2_ardour/ardour_ui.cc +++ b/gtk2_ardour/ardour_ui.cc @@ -84,7 +84,6 @@ typedef uint64_t microseconds_t; #include "prompter.h" #include "opts.h" #include "add_route_dialog.h" -#include "new_session_dialog.h" #include "about.h" #include "splash.h" #include "utils.h" @@ -95,6 +94,7 @@ typedef uint64_t microseconds_t; #include "gain_meter.h" #include "route_time_axis.h" #include "startup.h" +#include "engine_dialog.h" #include "i18n.h" @@ -196,7 +196,6 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[]) session_selector_window = 0; last_key_press_time = 0; _will_create_new_session_automatically = false; - new_session_dialog = 0; add_route_dialog = 0; route_params = 0; option_editor = 0; @@ -285,7 +284,12 @@ ARDOUR_UI::run_startup () } _startup->present (); + main().run(); + + /* we don't return here until the startup assistant is finished */ + + _startup->hide (); } int @@ -407,7 +411,6 @@ ARDOUR_UI::~ARDOUR_UI () delete editor; delete mixer; delete add_route_dialog; - delete new_session_dialog; } void @@ -523,8 +526,8 @@ ARDOUR_UI::save_ardour_state () XMLNode* node = new XMLNode (keyboard->get_state()); Config->add_extra_xml (*node); Config->add_extra_xml (get_transport_controllable_state()); - if (new_session_dialog && new_session_dialog->engine_control.was_used()) { - Config->add_extra_xml (new_session_dialog->engine_control.get_state()); + if (_startup && _startup->engine_control().was_used()) { + Config->add_extra_xml (_startup->engine_control().get_state()); } Config->save_state(); ui_config->save_state (); @@ -643,13 +646,11 @@ ARDOUR_UI::startup () { string name, path; - new_session_dialog = new NewSessionDialog(); - bool backend_audio_is_running = EngineControl::engine_running(); XMLNode* audio_setup = Config->extra_xml ("AudioSetup"); if (audio_setup) { - new_session_dialog->engine_control.set_state (*audio_setup); + _startup->engine_control().set_state (*audio_setup); } if (!get_session_parameters (backend_audio_is_running, ARDOUR_COMMAND_LINE::new_session)) { @@ -2035,7 +2036,7 @@ ARDOUR_UI::fontconfig_dialog () Glib::ustring fontconfig = Glib::build_filename (Glib::get_home_dir(), ".fontconfig"); if (!Glib::file_test (fontconfig, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) { - MessageDialog msg (*new_session_dialog, + MessageDialog msg (*_startup, _("Welcome to Ardour.\n\n" "The program will take a bit longer to start up\n" "while the system fonts are checked.\n\n" @@ -2113,7 +2114,7 @@ ARDOUR_UI::load_cmdline_session (const Glib::ustring& session_name, const Glib:: /* lets just try to load it */ if (create_engine ()) { - backend_audio_error (false, new_session_dialog); + backend_audio_error (false, _startup); return -1; } @@ -2169,19 +2170,19 @@ ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib /* get settings from advanced section of NSD */ - if (new_session_dialog->create_control_bus()) { - cchns = (uint32_t) new_session_dialog->control_channel_count(); + if (_startup->create_control_bus()) { + cchns = (uint32_t) _startup->control_channel_count(); } else { cchns = 0; } - if (new_session_dialog->create_master_bus()) { - mchns = (uint32_t) new_session_dialog->master_channel_count(); + if (_startup->create_master_bus()) { + mchns = (uint32_t) _startup->master_channel_count(); } else { mchns = 0; } - if (new_session_dialog->connect_inputs()) { + if (_startup->connect_inputs()) { iconnect = AutoConnectPhysical; } else { iconnect = AutoConnectOption (0); @@ -2189,16 +2190,16 @@ ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib /// @todo some minor tweaks. - if (new_session_dialog->connect_outs_to_master()) { + if (_startup->connect_outs_to_master()) { oconnect = AutoConnectMaster; - } else if (new_session_dialog->connect_outs_to_physical()) { + } else if (_startup->connect_outs_to_physical()) { oconnect = AutoConnectPhysical; } else { oconnect = AutoConnectOption (0); } - nphysin = (uint32_t) new_session_dialog->input_limit_count(); - nphysout = (uint32_t) new_session_dialog->output_limit_count(); + nphysin = (uint32_t) _startup->input_limit_count(); + nphysout = (uint32_t) _startup->output_limit_count(); } if (build_session (session_path, @@ -2231,33 +2232,6 @@ ARDOUR_UI::loading_message (const std::string& msg) flush_pending (); } -void -ARDOUR_UI::idle_load (const Glib::ustring& path) -{ - if (session) { - if (Glib::file_test (path, Glib::FILE_TEST_IS_DIR)) { - /* /path/to/foo => /path/to/foo, foo */ - load_session (path, basename_nosuffix (path)); - } else { - /* /path/to/foo/foo.ardour => /path/to/foo, foo */ - load_session (Glib::path_get_dirname (path), basename_nosuffix (path)); - } - } else { - - ARDOUR_COMMAND_LINE::session_name = path; - - if (new_session_dialog) { - - - /* make it break out of Dialog::run() and - start again. - */ - - new_session_dialog->response (1); - } - } -} - /** @param offer_quit true to offer a Cancel button, otherwise call it Quit */ bool ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be_new, bool offer_cancel) @@ -2268,194 +2242,79 @@ ARDOUR_UI::get_session_parameters (bool backend_audio_is_running, bool should_be Glib::ustring template_name; int response; - begin: - response = Gtk::RESPONSE_NONE; + _session_is_new = false; - if (!ARDOUR_COMMAND_LINE::session_name.empty()) { + session_name = _startup->session_name (should_be_new); - parse_cmdline_path (ARDOUR_COMMAND_LINE::session_name, session_name, session_path, existing_session); - - /* don't ever reuse this */ - - ARDOUR_COMMAND_LINE::session_name = string(); - - if (existing_session && backend_audio_is_running) { - - /* just load the thing already */ - - if (load_cmdline_session (session_name, session_path, existing_session) == 0) { - return true; - } - } - - /* make the NSD use whatever information we have */ - - new_session_dialog->set_session_name (session_name); - new_session_dialog->set_session_folder (session_path); + if (session_name.empty()) { + response = Gtk::RESPONSE_NONE; + goto try_again; + } + + /* if the user mistakenly typed path information into the session filename entry, + convert what they typed into a path & a name + */ + + if (session_name[0] == '/' || + (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') || + (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) { + + session_path = Glib::path_get_dirname (session_name); + session_name = Glib::path_get_basename (session_name); + + } else { + + session_path = _startup->session_folder(); } + + template_name = Glib::ustring(); - /* loading failed, or we need the NSD for something */ + if (create_engine ()) { + /* FAIL */ + } + + if (should_be_new) { - new_session_dialog->set_modal (false); - new_session_dialog->set_position (WIN_POS_CENTER); - new_session_dialog->set_current_page (0); - new_session_dialog->set_existing_session (existing_session); - new_session_dialog->reset_recent(); - new_session_dialog->set_offer_cancel (offer_cancel); - - do { - new_session_dialog->set_have_engine (backend_audio_is_running); - new_session_dialog->present (); - end_loading_messages (); - response = new_session_dialog->run (); + //XXX This is needed because session constructor wants a + //non-existant path. hopefully this will be fixed at some point. - _session_is_new = false; + session_path = Glib::build_filename (session_path, session_name); - /* handle possible negative responses */ - - switch (response) { - case 1: - /* sent by idle_load, meaning restart the whole process again */ - new_session_dialog->hide(); - new_session_dialog->reset(); - goto begin; - break; - - case Gtk::RESPONSE_CANCEL: - case Gtk::RESPONSE_DELETE_EVENT: - if (!session) { - if (engine && engine->running()) { - engine->stop (true); - } - quit(); - } - new_session_dialog->hide (); - return false; + if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - case Gtk::RESPONSE_NONE: - /* "Clear" was pressed */ - goto try_again; - } - - fontconfig_dialog(); - - if (!backend_audio_is_running) { - int ret = new_session_dialog->engine_control.setup_engine (); - if (ret < 0) { - return false; - } else if (ret > 0) { - response = Gtk::RESPONSE_REJECT; - goto try_again; - } - } - - if (create_engine ()) { - - backend_audio_error (!backend_audio_is_running, new_session_dialog); - flush_pending (); - - new_session_dialog->set_existing_session (false); - new_session_dialog->set_current_page (2); - - response = Gtk::RESPONSE_NONE; - goto try_again; - } - - backend_audio_is_running = true; - - if (response == Gtk::RESPONSE_OK) { - - session_name = new_session_dialog->session_name(); - - if (session_name.empty()) { - response = Gtk::RESPONSE_NONE; + if (ask_about_loading_existing_session (session_path)) { + goto loadit; + } else { + response = RESPONSE_NONE; goto try_again; } - - /* if the user mistakenly typed path information into the session filename entry, - convert what they typed into a path & a name - */ - - if (session_name[0] == '/' || - (session_name.length() > 2 && session_name[0] == '.' && session_name[1] == '/') || - (session_name.length() > 3 && session_name[0] == '.' && session_name[1] == '.' && session_name[2] == '/')) { - - session_path = Glib::path_get_dirname (session_name); - session_name = Glib::path_get_basename (session_name); - - } else { - - session_path = new_session_dialog->session_folder(); - } - - template_name = Glib::ustring(); - switch (new_session_dialog->which_page()) { - - case NewSessionDialog::OpenPage: - case NewSessionDialog::EnginePage: - goto loadit; - break; - - case NewSessionDialog::NewPage: /* nominally the "new" session creator, but could be in use for an old session */ - - should_be_new = true; - - //XXX This is needed because session constructor wants a - //non-existant path. hopefully this will be fixed at some point. - - session_path = Glib::build_filename (session_path, session_name); - - if (Glib::file_test (session_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) { - - if (ask_about_loading_existing_session (session_path)) { - goto loadit; - } else { - response = RESPONSE_NONE; - goto try_again; - } - } - - _session_is_new = true; - - if (new_session_dialog->use_session_template()) { - - template_name = new_session_dialog->session_template_name(); - goto loadit; - - } else { - if (build_session_from_nsd (session_path, session_name)) { - response = RESPONSE_NONE; - goto try_again; - } - goto done; - } - break; - - default: - break; - } - - loadit: - new_session_dialog->hide (); - - if (load_session (session_path, session_name, template_name)) { - /* force a retry */ - response = Gtk::RESPONSE_NONE; - } - - try_again: - if (response == Gtk::RESPONSE_NONE) { - new_session_dialog->set_existing_session (false); - new_session_dialog->reset (); - } } + + _session_is_new = true; - } while (response == Gtk::RESPONSE_NONE || response == Gtk::RESPONSE_REJECT); + + if (_startup->use_session_template()) { + + template_name = _startup->session_template_name(); + goto loadit; + + } else { + if (build_session_from_nsd (session_path, session_name)) { + response = RESPONSE_NONE; + goto try_again; + } + goto done; + } + } + + loadit: + if (load_session (session_path, session_name, template_name)) { + /* force a retry */ + } + + try_again: done: - show(); - new_session_dialog->hide(); - new_session_dialog->reset(); goto_editor_window (); return true; } diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 79643e23d0..d9082882f8 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -78,7 +78,6 @@ class RouteParams_UI; class About; class Splash; class AddRouteDialog; -class NewSessionDialog; class LocationUI; class ThemeManager; class BundleManager; @@ -122,7 +121,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI void show_about (); void hide_about (); - void idle_load (const Glib::ustring& path); void finish(); int load_session (const Glib::ustring& path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring()); @@ -532,8 +530,6 @@ class ARDOUR_UI : public Gtkmm2ext::UI bool _will_create_new_session_automatically; - NewSessionDialog* new_session_dialog; - void open_session (); void open_recent_session (); void save_template (); diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 8ab92033c2..be57c3389c 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -218,6 +218,8 @@ EngineControl::EngineControl () realtime_button.signal_toggled().connect (mem_fun (*this, &EngineControl::realtime_changed)); realtime_changed (); +#if PROVIDE_TOO_MANY_OPTIONS + #ifndef __APPLE__ label = manage (new Label (_("Realtime Priority"))); label->set_alignment (1.0, 0.5); @@ -262,6 +264,7 @@ EngineControl::EngineControl () options_packer.attach (*label, 0, 1, row, row + 1, FILL|EXPAND, (AttachOptions) 0); ++row; +#endif /* PROVIDE_TOO_MANY_OPTIONS */ label = manage (new Label (_("Number of ports"))); label->set_alignment (1.0, 0.5); options_packer.attach (ports_spinner, 1, 2, row, row + 1, FILL|EXPAND, AttachOptions(0)); @@ -377,8 +380,10 @@ EngineControl::build_command_line (vector& cmd) uint32_t msecs; secs = atof (str); msecs = (uint32_t) floor (secs * 1000.0); - cmd.push_back ("-t"); - cmd.push_back (to_string (msecs, std::dec)); + if (msecs > 0) { + cmd.push_back ("-t"); + cmd.push_back (to_string (msecs, std::dec)); + } } if (no_memory_lock_button.get_active()) { diff --git a/gtk2_ardour/main.cc b/gtk2_ardour/main.cc index 21bc398c86..f43cc03cf2 100644 --- a/gtk2_ardour/main.cc +++ b/gtk2_ardour/main.cc @@ -382,9 +382,7 @@ int main (int argc, char *argv[]) exit (1); } -#ifdef SOMEBODY_WANTS_TO_FIX_THIS ui->run_startup (); -#endif ui->run (text_receiver); ui = 0; diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc deleted file mode 100644 index 7e5345290c..0000000000 --- a/gtk2_ardour/new_session_dialog.cc +++ /dev/null @@ -1,1055 +0,0 @@ -/* - Copyright (C) 2005 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "pbd/error.h" - -#include "ardour/recent_sessions.h" -#include "ardour/session_state_utils.h" -#include "ardour/template_utils.h" -#include "ardour/session.h" -#include "ardour/profile.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace Gtk; -using namespace Gtkmm2ext; -using namespace PBD; -using namespace ARDOUR; - -#include "opts.h" -#include "utils.h" -#include "i18n.h" -#include "new_session_dialog.h" - -NewSessionDialog::NewSessionDialog() - : ArdourDialog ("session control") -{ - in_destructor = false; - session_name_label = new Gtk::Label(_("Name:")); - m_name = new Gtk::Entry(); - m_name->set_text(ARDOUR_COMMAND_LINE::session_name); - - chan_count_label_1 = new Gtk::Label(_("channels")); - chan_count_label_2 = new Gtk::Label(_("channels")); - chan_count_label_3 = new Gtk::Label(_("channels")); - chan_count_label_4 = new Gtk::Label(_("channels")); - - chan_count_label_1->set_alignment(0,0.5); - chan_count_label_1->set_padding(0,0); - chan_count_label_1->set_line_wrap(false); - - chan_count_label_2->set_alignment(0,0.5); - chan_count_label_2->set_padding(0,0); - chan_count_label_2->set_line_wrap(false); - - chan_count_label_3->set_alignment(0,0.5); - chan_count_label_3->set_padding(0,0); - chan_count_label_3->set_line_wrap(false); - - chan_count_label_4->set_alignment(0,0.5); - chan_count_label_4->set_padding(0,0); - chan_count_label_4->set_line_wrap(false); - - bus_label = new Gtk::Label(_("Busses")); - input_label = new Gtk::Label(_("Inputs")); - output_label = new Gtk::Label(_("Outputs")); - - session_location_label = new Gtk::Label(_("Create folder in:")); - m_folder = new Gtk::FileChooserButton(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER); - session_template_label = new Gtk::Label(_("Template:")); - m_template = new Gtk::FileChooserButton(); - m_create_control_bus = new Gtk::CheckButton(_("Create monitor bus")); - - Gtk::Adjustment *m_control_bus_channel_count_adj = Gtk::manage(new Gtk::Adjustment(2, 0, 100, 1, 10, 0)); - m_control_bus_channel_count = new Gtk::SpinButton(*m_control_bus_channel_count_adj, 1, 0); - - Gtk::Adjustment *m_master_bus_channel_count_adj = Gtk::manage(new Gtk::Adjustment(2, 0, 100, 1, 10, 0)); - m_master_bus_channel_count = new Gtk::SpinButton(*m_master_bus_channel_count_adj, 1, 0); - m_create_master_bus = new Gtk::CheckButton(_("Create master bus")); - advanced_table = new Gtk::Table(2, 2, true); - m_connect_inputs = new Gtk::CheckButton(_("Automatically connect to physical inputs")); - m_limit_input_ports = new Gtk::CheckButton(_("Use only")); - - Gtk::Adjustment *m_input_limit_count_adj = Gtk::manage(new Gtk::Adjustment(1, 0, 100, 1, 10, 0)); - m_input_limit_count = new Gtk::SpinButton(*m_input_limit_count_adj, 1, 0); - input_port_limit_hbox = new Gtk::HBox(false, 0); - input_port_vbox = new Gtk::VBox(false, 0); - input_table = new Gtk::Table(2, 2, false); - - bus_frame = new Gtk::Frame(); - bus_table = new Gtk::Table (2, 3, false); - - input_frame = new Gtk::Frame(); - m_connect_outputs = new Gtk::CheckButton(_("Automatically connect outputs")); - m_limit_output_ports = new Gtk::CheckButton(_("Use only")); - - Gtk::Adjustment *m_output_limit_count_adj = Gtk::manage(new Gtk::Adjustment(1, 0, 100, 1, 10, 0)); - m_output_limit_count = new Gtk::SpinButton(*m_output_limit_count_adj, 1, 0); - output_port_limit_hbox = new Gtk::HBox(false, 0); - output_port_vbox = new Gtk::VBox(false, 0); - - Gtk::RadioButton::Group _RadioBGroup_m_connect_outputs_to_master; - m_connect_outputs_to_master = new Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to master bus")); - m_connect_outputs_to_physical = new Gtk::RadioButton(_RadioBGroup_m_connect_outputs_to_master, _("... to physical outputs")); - output_conn_vbox = new Gtk::VBox(false, 0); - output_vbox = new Gtk::VBox(false, 0); - - output_frame = new Gtk::Frame(); - advanced_vbox = new Gtk::VBox(false, 0); - advanced_label = new Gtk::Label(_("Advanced options")); - advanced_expander = new Gtk::Expander(); - new_session_table = new Gtk::Table(2, 2, false); - m_open_filechooser = new Gtk::FileChooserButton(); - open_session_hbox = new Gtk::HBox(false, 0); - m_treeview = new Gtk::TreeView(); - recent_scrolledwindow = new Gtk::ScrolledWindow(); - - recent_sesion_label = new Gtk::Label(_("Recent:")); - recent_frame = new Gtk::Frame(); - open_session_vbox = new Gtk::VBox(false, 0); - m_notebook = new Gtk::Notebook(); - session_name_label->set_alignment(0, 0.5); - session_name_label->set_padding(6,0); - session_name_label->set_line_wrap(false); - session_name_label->set_selectable(false); - m_name->set_editable(true); - m_name->set_max_length(0); - m_name->set_has_frame(true); - m_name->set_activates_default(true); - m_name->set_width_chars (40); - session_location_label->set_alignment(0,0.5); - session_location_label->set_padding(6,0); - session_location_label->set_line_wrap(false); - session_location_label->set_selectable(false); - session_template_label->set_alignment(0,0.5); - session_template_label->set_padding(6,0); - session_template_label->set_line_wrap(false); - session_template_label->set_selectable(false); - m_create_control_bus->set_flags(Gtk::CAN_FOCUS); - m_create_control_bus->set_relief(Gtk::RELIEF_NORMAL); - m_create_control_bus->set_mode(true); - m_create_control_bus->set_active(false); - m_create_control_bus->set_border_width(0); - m_control_bus_channel_count->set_flags(Gtk::CAN_FOCUS); - m_control_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS); - m_control_bus_channel_count->set_numeric(true); - m_control_bus_channel_count->set_digits(0); - m_control_bus_channel_count->set_wrap(false); - m_control_bus_channel_count->set_sensitive(false); - m_master_bus_channel_count->set_flags(Gtk::CAN_FOCUS); - m_master_bus_channel_count->set_update_policy(Gtk::UPDATE_ALWAYS); - m_master_bus_channel_count->set_numeric(true); - m_master_bus_channel_count->set_digits(0); - m_master_bus_channel_count->set_wrap(false); - open_session_file_label = new Gtk::Label(_("Browse:")); - open_session_file_label->set_alignment(0, 0.5); - m_create_master_bus->set_flags(Gtk::CAN_FOCUS); - m_create_master_bus->set_relief(Gtk::RELIEF_NORMAL); - m_create_master_bus->set_mode(true); - m_create_master_bus->set_active(true); - m_create_master_bus->set_border_width(0); - advanced_table->set_row_spacings(0); - advanced_table->set_col_spacings(0); - - m_connect_inputs->set_flags(Gtk::CAN_FOCUS); - m_connect_inputs->set_relief(Gtk::RELIEF_NORMAL); - m_connect_inputs->set_mode(true); - m_connect_inputs->set_active(true); - m_connect_inputs->set_border_width(0); - - m_limit_input_ports->set_flags(Gtk::CAN_FOCUS); - m_limit_input_ports->set_relief(Gtk::RELIEF_NORMAL); - m_limit_input_ports->set_mode(true); - m_limit_input_ports->set_sensitive(true); - m_limit_input_ports->set_border_width(0); - m_input_limit_count->set_flags(Gtk::CAN_FOCUS); - m_input_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS); - m_input_limit_count->set_numeric(true); - m_input_limit_count->set_digits(0); - m_input_limit_count->set_wrap(false); - m_input_limit_count->set_sensitive(false); - - bus_hbox = new Gtk::HBox (false, 0); - bus_hbox->pack_start (*bus_table, Gtk::PACK_SHRINK, 18); - - bus_label->set_alignment(0, 0.5); - bus_label->set_padding(0,0); - bus_label->set_line_wrap(false); - bus_label->set_selectable(false); - bus_label->set_use_markup(true); - bus_frame->set_shadow_type(Gtk::SHADOW_NONE); - bus_frame->set_label_align(0,0.5); - bus_frame->add(*bus_hbox); - bus_frame->set_label_widget(*bus_label); - - bus_table->set_row_spacings (0); - bus_table->set_col_spacings (0); - bus_table->attach (*m_create_master_bus, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - bus_table->attach (*m_master_bus_channel_count, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - bus_table->attach (*chan_count_label_1, 2, 3, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0); - bus_table->attach (*m_create_control_bus, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - bus_table->attach (*m_control_bus_channel_count, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); - bus_table->attach (*chan_count_label_2, 2, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0); - - input_port_limit_hbox->pack_start(*m_limit_input_ports, Gtk::PACK_SHRINK, 6); - input_port_limit_hbox->pack_start(*m_input_limit_count, Gtk::PACK_SHRINK, 0); - input_port_limit_hbox->pack_start(*chan_count_label_3, Gtk::PACK_SHRINK, 6); - input_port_vbox->pack_start(*m_connect_inputs, Gtk::PACK_SHRINK, 0); - input_port_vbox->pack_start(*input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0); - input_table->set_row_spacings(0); - input_table->set_col_spacings(0); - input_table->attach(*input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6); - - input_hbox = new Gtk::HBox (false, 0); - input_hbox->pack_start (*input_table, Gtk::PACK_SHRINK, 18); - - input_label->set_alignment(0, 0.5); - input_label->set_padding(0,0); - input_label->set_line_wrap(false); - input_label->set_selectable(false); - input_label->set_use_markup(true); - input_frame->set_shadow_type(Gtk::SHADOW_NONE); - input_frame->set_label_align(0,0.5); - input_frame->add(*input_hbox); - input_frame->set_label_widget(*input_label); - - m_connect_outputs->set_flags(Gtk::CAN_FOCUS); - m_connect_outputs->set_relief(Gtk::RELIEF_NORMAL); - m_connect_outputs->set_mode(true); - m_connect_outputs->set_active(true); - m_connect_outputs->set_border_width(0); - m_limit_output_ports->set_flags(Gtk::CAN_FOCUS); - m_limit_output_ports->set_relief(Gtk::RELIEF_NORMAL); - m_limit_output_ports->set_mode(true); - m_limit_output_ports->set_sensitive(true); - m_limit_output_ports->set_border_width(0); - m_output_limit_count->set_flags(Gtk::CAN_FOCUS); - m_output_limit_count->set_update_policy(Gtk::UPDATE_ALWAYS); - m_output_limit_count->set_numeric(false); - m_output_limit_count->set_digits(0); - m_output_limit_count->set_wrap(false); - m_output_limit_count->set_sensitive(false); - output_port_limit_hbox->pack_start(*m_limit_output_ports, Gtk::PACK_SHRINK, 6); - output_port_limit_hbox->pack_start(*m_output_limit_count, Gtk::PACK_SHRINK, 0); - output_port_limit_hbox->pack_start(*chan_count_label_4, Gtk::PACK_SHRINK, 6); - m_connect_outputs_to_master->set_flags(Gtk::CAN_FOCUS); - m_connect_outputs_to_master->set_relief(Gtk::RELIEF_NORMAL); - m_connect_outputs_to_master->set_mode(true); - m_connect_outputs_to_master->set_active(false); - m_connect_outputs_to_master->set_border_width(0); - m_connect_outputs_to_physical->set_flags(Gtk::CAN_FOCUS); - m_connect_outputs_to_physical->set_relief(Gtk::RELIEF_NORMAL); - m_connect_outputs_to_physical->set_mode(true); - m_connect_outputs_to_physical->set_active(false); - m_connect_outputs_to_physical->set_border_width(0); - output_conn_vbox->pack_start(*m_connect_outputs, Gtk::PACK_SHRINK, 0); - output_conn_vbox->pack_start(*m_connect_outputs_to_master, Gtk::PACK_SHRINK, 0); - output_conn_vbox->pack_start(*m_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0); - output_vbox->set_border_width(6); - - output_port_vbox->pack_start(*output_port_limit_hbox, Gtk::PACK_SHRINK, 0); - - output_vbox->pack_start(*output_conn_vbox); - output_vbox->pack_start(*output_port_vbox); - - output_label->set_alignment(0, 0.5); - output_label->set_padding(0,0); - output_label->set_line_wrap(false); - output_label->set_selectable(false); - output_label->set_use_markup(true); - output_frame->set_shadow_type(Gtk::SHADOW_NONE); - output_frame->set_label_align(0,0.5); - - output_hbox = new Gtk::HBox (false, 0); - output_hbox->pack_start (*output_vbox, Gtk::PACK_SHRINK, 18); - - output_frame->add(*output_hbox); - output_frame->set_label_widget(*output_label); - - advanced_vbox->pack_start(*advanced_table, Gtk::PACK_SHRINK, 0); - advanced_vbox->pack_start(*bus_frame, Gtk::PACK_SHRINK, 6); - advanced_vbox->pack_start(*input_frame, Gtk::PACK_SHRINK, 6); - advanced_vbox->pack_start(*output_frame, Gtk::PACK_SHRINK, 0); - advanced_label->set_padding(0,0); - advanced_label->set_line_wrap(false); - advanced_label->set_selectable(false); - advanced_label->set_alignment(0, 0.5); - advanced_expander->set_flags(Gtk::CAN_FOCUS); - advanced_expander->set_border_width(0); - advanced_expander->set_expanded(false); - advanced_expander->set_spacing(0); - advanced_expander->add(*advanced_vbox); - advanced_expander->set_label_widget(*advanced_label); - new_session_table->set_border_width(12); - new_session_table->set_row_spacings(6); - new_session_table->set_col_spacings(0); - new_session_table->attach(*session_name_label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 0, 0); - new_session_table->attach(*m_name, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0); - new_session_table->attach(*session_location_label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL, 0, 0); - new_session_table->attach(*m_folder, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0); - new_session_table->attach(*session_template_label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL, 0, 0); - new_session_table->attach(*m_template, 1, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::FILL, 0, 0); - - if (!ARDOUR::Profile->get_sae()) { - new_session_table->attach(*advanced_expander, 0, 2, 3, 4, Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 6); - } - - open_session_hbox->pack_start(*open_session_file_label, false, false, 12); - open_session_hbox->pack_start(*m_open_filechooser, true, true, 12); - m_treeview->set_flags(Gtk::CAN_FOCUS); - m_treeview->set_headers_visible(true); - m_treeview->set_rules_hint(false); - m_treeview->set_reorderable(false); - m_treeview->set_enable_search(true); - m_treeview->set_fixed_height_mode(false); - m_treeview->set_hover_selection(false); - m_treeview->set_size_request(-1, 150); - recent_scrolledwindow->set_flags(Gtk::CAN_FOCUS); - recent_scrolledwindow->set_border_width(6); - recent_scrolledwindow->set_shadow_type(Gtk::SHADOW_IN); - recent_scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - recent_scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT); - recent_scrolledwindow->add(*m_treeview); - - recent_sesion_label->set_padding(0,0); - recent_sesion_label->set_line_wrap(false); - recent_sesion_label->set_selectable(false); - recent_frame->set_border_width(12); - recent_frame->set_shadow_type(Gtk::SHADOW_NONE); - recent_frame->add(*recent_scrolledwindow); - recent_frame->set_label_widget(*recent_sesion_label); - open_session_vbox->pack_start(*recent_frame, Gtk::PACK_EXPAND_WIDGET, 0); - open_session_vbox->pack_start(*open_session_hbox, Gtk::PACK_SHRINK, 12); - m_notebook->set_flags(Gtk::CAN_FOCUS); - m_notebook->set_scrollable(true); - get_vbox()->set_homogeneous(false); - get_vbox()->set_spacing(0); - get_vbox()->pack_start(*m_notebook, Gtk::PACK_SHRINK, 0); - - /* - icon setting is done again in the editor (for the whole app), - but its all chickens and eggs at this point. - */ - - list > window_icons; - Glib::RefPtr icon; - - if ((icon = ::get_icon ("ardour_icon_16px")) != 0) { - window_icons.push_back (icon); - } - if ((icon = ::get_icon ("ardour_icon_22px")) != 0) { - window_icons.push_back (icon); - } - if ((icon = ::get_icon ("ardour_icon_32px")) != 0) { - window_icons.push_back (icon); - } - if ((icon = ::get_icon ("ardour_icon_48px")) != 0) { - window_icons.push_back (icon); - } - if (!window_icons.empty()) { - set_icon_list (window_icons); - } - - WindowTitle title(Glib::get_application_name()); - title += _("Session Control"); - set_title(title.get_string()); - - set_position (Gtk::WIN_POS_MOUSE); - set_resizable(false); - set_has_separator(false); - quit_or_cancel_button = add_button(Gtk::Stock::QUIT, Gtk::RESPONSE_CANCEL); - add_button(Gtk::Stock::CLEAR, Gtk::RESPONSE_NONE); - m_okbutton = add_button(Gtk::Stock::NEW, Gtk::RESPONSE_OK); - - recent_model = Gtk::TreeStore::create (recent_columns); - m_treeview->set_model (recent_model); - m_treeview->append_column (_("Recent sessions"), recent_columns.visible_name); - m_treeview->set_headers_visible (false); - m_treeview->get_selection()->set_mode (Gtk::SELECTION_SINGLE); - - if (is_directory (user_template_directory ())) - { - m_template->set_current_folder (user_template_directory().to_string()); - } - else if (is_directory (system_template_directory ())) - { - m_template->set_current_folder (system_template_directory().to_string()); - } - - if (is_directory (system_template_directory ())) - { - m_template->add_shortcut_folder (system_template_directory().to_string()); - } - - m_template->set_title(_("select template")); - Gtk::FileFilter* session_filter = manage (new (Gtk::FileFilter)); - session_filter->add_pattern(X_("*.ardour")); - session_filter->add_pattern(X_("*.ardour.bak")); - m_open_filechooser->set_filter (*session_filter); - m_open_filechooser->set_current_folder(getenv ("HOME")); - m_open_filechooser->set_title(_("select session file")); - - Gtk::FileFilter* template_filter = manage (new (Gtk::FileFilter)); - template_filter->add_pattern(X_("*.template")); - m_template->set_filter (*template_filter); - - m_folder->set_current_folder(getenv ("HOME")); - m_folder->set_title(_("select directory")); - - m_notebook->set_current_page(0); - m_notebook->show(); - m_notebook->show_all_children(); - - engine_page_session_folder = X_(""); - engine_page_session_name = X_(""); - - set_default_response (Gtk::RESPONSE_OK); - if (!ARDOUR_COMMAND_LINE::session_name.length()) { - set_response_sensitive (Gtk::RESPONSE_OK, false); - set_response_sensitive (Gtk::RESPONSE_NONE, false); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, true); - set_response_sensitive (Gtk::RESPONSE_NONE, true); - } - - ///@ connect some signals - - m_connect_inputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_inputs_clicked)); - m_connect_outputs->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::connect_outputs_clicked)); - m_limit_input_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_inputs_clicked)); - m_limit_output_ports->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::limit_outputs_clicked)); - m_create_master_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::master_bus_button_clicked)); - m_create_control_bus->signal_clicked().connect (mem_fun (*this, &NewSessionDialog::monitor_bus_button_clicked)); - m_name->signal_changed().connect(mem_fun (*this, &NewSessionDialog::on_new_session_name_entry_changed)); - m_notebook->signal_switch_page().connect (mem_fun (*this, &NewSessionDialog::notebook_page_changed)); - m_treeview->get_selection()->signal_changed().connect (mem_fun (*this, &NewSessionDialog::treeview_selection_changed)); - m_treeview->signal_row_activated().connect (mem_fun (*this, &NewSessionDialog::recent_row_activated)); - m_open_filechooser->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::file_chosen)); - m_template->signal_selection_changed ().connect (mem_fun (*this, &NewSessionDialog::template_chosen)); - - page_set = Pages (0); -} - -NewSessionDialog::~NewSessionDialog() -{ - in_destructor = true; -} - -int -NewSessionDialog::run () -{ - if (!page_set) { - /* nothing to display */ - return Gtk::RESPONSE_OK; - } - if (!(page_set & NewPage) && !(page_set & OpenPage)) { - set_response_sensitive (Gtk::RESPONSE_OK, true); - } - return ArdourDialog::run (); -} - -void -NewSessionDialog::set_have_engine (bool yn) -{ - if (yn) { - m_notebook->remove_page (engine_control); - page_set = Pages (page_set & ~EnginePage); - } else { - if (!(page_set & EnginePage)) { - m_notebook->append_page (engine_control, _("Audio Setup")); - m_notebook->show_all_children(); - page_set = Pages (page_set | EnginePage); - } - } -} - - -void -NewSessionDialog::set_existing_session (bool yn) -{ - if (yn) { - - if (page_set & NewPage) { - m_notebook->remove_page (*new_session_table); - page_set = Pages (page_set & ~NewPage); - } - - if (page_set & OpenPage) { - m_notebook->remove_page (*open_session_vbox); - page_set = Pages (page_set & ~OpenPage); - } - - } else { - if (!(page_set & NewPage)) { - m_notebook->append_page(*new_session_table, _("New Session")); - m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START); - page_set = Pages (page_set | NewPage); - } - if (!(page_set & OpenPage)) { - m_notebook->append_page(*open_session_vbox, _("Open Session")); - m_notebook->pages().back().set_tab_label_packing(false, true, Gtk::PACK_START); - page_set = Pages (page_set | OpenPage); - } - - m_notebook->show_all_children(); - } -} - -void -NewSessionDialog::set_session_name (const Glib::ustring& name) -{ - m_name->set_text (name); - engine_page_session_name = name; -} - -void -NewSessionDialog::set_session_folder(const Glib::ustring& dir) -{ - Glib::ustring realdir = dir; - - /* this little tangled mess is a result of 4 things: - - 1) GtkFileChooser vomits when given a non-absolute directory - argument to set_current_folder() - 2) canonicalize_file_name() doesn't exist on OS X - 3) linux man page for realpath() says "do not use this function" - 4) canonicalize_file_name() & realpath() have entirely - different semantics on OS X and Linux when given - a non-existent path. - - as result of all this, we take two distinct pathways through the code. - */ - - -#ifdef __APPLE__ - - char buf[PATH_MAX]; - - if(realpath (dir.c_str(), buf) != 0) { - if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) { - realdir = Glib::path_get_dirname (realdir); - } - m_folder->set_current_folder (realdir); - engine_page_session_folder = realdir; - } - - -#else - char* res; - if (!Glib::file_test (dir, Glib::FILE_TEST_IS_DIR)) { - realdir = Glib::path_get_dirname (realdir); - cerr << "didn't exist, use " << realdir << endl; - } - - if ((res = canonicalize_file_name (realdir.c_str())) != 0) { - cerr << "canonical, use " << res << endl; - m_folder->set_current_folder (res); - engine_page_session_folder = res; - free (res); - } - -#endif - -} - -std::string -NewSessionDialog::session_name() const -{ - std::string str = Glib::filename_from_utf8(m_open_filechooser->get_filename()); - std::string::size_type position = str.find_last_of ('/'); - str = str.substr (position+1); - position = str.find_last_of ('.'); - str = str.substr (0, position); - - /* - XXX what to do if it's a .bak file? - load_session doesn't allow it! - - if ((position = str.rfind(".bak")) != string::npos) { - str = str.substr (0, position); - } - */ - - switch (which_page()) { - case NewPage: - case EnginePage: - /* new or audio setup pages */ - if (!(page_set & OpenPage) && !(page_set & NewPage)) { - return Glib::filename_from_utf8(engine_page_session_name); - } - return Glib::filename_from_utf8(m_name->get_text()); - default: - break; - } - - if (m_treeview->get_selection()->count_selected_rows() == 0) { - return Glib::filename_from_utf8(str); - } - Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected(); - return (*i)[recent_columns.visible_name]; -} - -std::string -NewSessionDialog::session_folder() const -{ - switch (which_page()) { - case NewPage: - return Glib::filename_from_utf8(m_folder->get_filename()); - - case EnginePage: - if (!(page_set & OpenPage) && !(page_set & NewPage)) { - /* just engine page, nothing else */ - return Glib::filename_from_utf8(engine_page_session_folder); - } - if (page_set == EnginePage) { - /* use m_folder since it should be set */ - return Glib::filename_from_utf8(m_folder->get_filename()); - } - break; - - default: - break; - } - - if (m_treeview->get_selection()->count_selected_rows() == 0) { - const string filename(Glib::filename_from_utf8(m_open_filechooser->get_filename())); - return Glib::path_get_dirname(filename); - } - - Gtk::TreeModel::iterator i = m_treeview->get_selection()->get_selected(); - return (*i)[recent_columns.fullpath]; -} - -bool -NewSessionDialog::use_session_template() const -{ - if (m_template->get_filename().empty() && (which_page() == NewPage)) - return false; - return true; -} - -std::string -NewSessionDialog::session_template_name() const -{ - return Glib::filename_from_utf8(m_template->get_filename()); -} - -bool -NewSessionDialog::create_master_bus() const -{ - return m_create_master_bus->get_active(); -} - -int -NewSessionDialog::master_channel_count() const -{ - return m_master_bus_channel_count->get_value_as_int(); -} - -bool -NewSessionDialog::create_control_bus() const -{ - return m_create_control_bus->get_active(); -} - -int -NewSessionDialog::control_channel_count() const -{ - return m_control_bus_channel_count->get_value_as_int(); -} - -bool -NewSessionDialog::connect_inputs() const -{ - return m_connect_inputs->get_active(); -} - -bool -NewSessionDialog::limit_inputs_used_for_connection() const -{ - return m_limit_input_ports->get_active(); -} - -int -NewSessionDialog::input_limit_count() const -{ - return m_input_limit_count->get_value_as_int(); -} - -bool -NewSessionDialog::connect_outputs() const -{ - return m_connect_outputs->get_active(); -} - -bool -NewSessionDialog::limit_outputs_used_for_connection() const -{ - return m_limit_output_ports->get_active(); -} - -int -NewSessionDialog::output_limit_count() const -{ - return m_output_limit_count->get_value_as_int(); -} - -bool -NewSessionDialog::connect_outs_to_master() const -{ - return m_connect_outputs_to_master->get_active(); -} - -bool -NewSessionDialog::connect_outs_to_physical() const -{ - return m_connect_outputs_to_physical->get_active(); -} - -int -NewSessionDialog::get_current_page() -{ - return m_notebook->get_current_page(); -} - -NewSessionDialog::Pages -NewSessionDialog::which_page () const -{ - int num = m_notebook->get_current_page(); - - if (page_set == NewPage) { - return NewPage; - - } else if (page_set == OpenPage) { - return OpenPage; - - } else if (page_set == EnginePage) { - return EnginePage; - - } else if (page_set == (NewPage|OpenPage)) { - switch (num) { - case 0: - return NewPage; - default: - return OpenPage; - } - - } else if (page_set == (NewPage|EnginePage)) { - switch (num) { - case 0: - return NewPage; - default: - return EnginePage; - } - - } else if (page_set == (NewPage|EnginePage|OpenPage)) { - switch (num) { - case 0: - return NewPage; - case 1: - return OpenPage; - default: - return EnginePage; - } - - } else if (page_set == (OpenPage|EnginePage)) { - switch (num) { - case 0: - return OpenPage; - default: - return EnginePage; - } - } - - return NewPage; /* shouldn't get here */ -} - -void -NewSessionDialog::set_current_page(int page) -{ - return m_notebook->set_current_page (page); -} - -void -NewSessionDialog::reset_name() -{ - m_name->set_text(""); - set_response_sensitive (Gtk::RESPONSE_OK, false); -} - -void -NewSessionDialog::on_new_session_name_entry_changed () -{ - if (m_name->get_text() != "") { - set_response_sensitive (Gtk::RESPONSE_OK, true); - set_response_sensitive (Gtk::RESPONSE_NONE, true); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, false); - } -} - -void -NewSessionDialog::notebook_page_changed (GtkNotebookPage* np, uint pagenum) -{ - if (in_destructor) { - return; - } - - switch (which_page()) { - case OpenPage: - on_new_session_page = false; - m_okbutton->set_label(_("Open")); - m_okbutton->set_image (*(manage (new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)))); - set_response_sensitive (Gtk::RESPONSE_NONE, false); - if (m_treeview->get_selection()->count_selected_rows() == 0) { - set_response_sensitive (Gtk::RESPONSE_OK, false); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, true); - } - break; - - case EnginePage: - on_new_session_page = false; - m_okbutton->set_label(_("Open")); - m_okbutton->set_image (*(manage (new Gtk::Image (Gtk::Stock::OPEN, Gtk::ICON_SIZE_BUTTON)))); - set_response_sensitive (Gtk::RESPONSE_NONE, false); - set_response_sensitive (Gtk::RESPONSE_OK, true); - break; - - default: - on_new_session_page = true; - m_okbutton->set_label(_("New")); - m_okbutton->set_image (*(new Gtk::Image (Gtk::Stock::NEW, Gtk::ICON_SIZE_BUTTON))); - if (m_name->get_text() == "") { - set_response_sensitive (Gtk::RESPONSE_OK, false); - m_name->grab_focus(); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, true); - } - } -} - -void -NewSessionDialog::treeview_selection_changed () -{ - if (m_treeview->get_selection()->count_selected_rows() == 0) { - if (!m_open_filechooser->get_filename().empty()) { - set_response_sensitive (Gtk::RESPONSE_OK, true); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, false); - } - } else { - set_response_sensitive (Gtk::RESPONSE_OK, true); - } -} - -void -NewSessionDialog::file_chosen () -{ - switch (which_page()) { - case OpenPage: - break; - case NewPage: - case EnginePage: - return; - } - - m_treeview->get_selection()->unselect_all(); - - Glib::RefPtr win (get_window()); - - if (win) { - win->set_cursor(Gdk::Cursor(Gdk::WATCH)); - } - - if (!m_open_filechooser->get_filename().empty()) { - set_response_sensitive (Gtk::RESPONSE_OK, true); - response (Gtk::RESPONSE_OK); - } else { - set_response_sensitive (Gtk::RESPONSE_OK, false); - } -} - -void -NewSessionDialog::template_chosen () -{ - if (m_template->get_filename() != "" ) {; - set_response_sensitive (Gtk::RESPONSE_NONE, true); - } else { - set_response_sensitive (Gtk::RESPONSE_NONE, false); - } -} - -void -NewSessionDialog::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col) -{ - response (Gtk::RESPONSE_OK); -} - -void -NewSessionDialog::connect_inputs_clicked () -{ - m_limit_input_ports->set_sensitive(m_connect_inputs->get_active()); - - if (m_connect_inputs->get_active() && m_limit_input_ports->get_active()) { - m_input_limit_count->set_sensitive(true); - } else { - m_input_limit_count->set_sensitive(false); - } -} - -void -NewSessionDialog::connect_outputs_clicked () -{ - m_limit_output_ports->set_sensitive(m_connect_outputs->get_active()); - - if (m_connect_outputs->get_active() && m_limit_output_ports->get_active()) { - m_output_limit_count->set_sensitive(true); - } else { - m_output_limit_count->set_sensitive(false); - } -} - -void -NewSessionDialog::limit_inputs_clicked () -{ - m_input_limit_count->set_sensitive(m_limit_input_ports->get_active()); -} - -void -NewSessionDialog::limit_outputs_clicked () -{ - m_output_limit_count->set_sensitive(m_limit_output_ports->get_active()); -} - -void -NewSessionDialog::master_bus_button_clicked () -{ - m_master_bus_channel_count->set_sensitive(m_create_master_bus->get_active()); -} - -void -NewSessionDialog::monitor_bus_button_clicked () -{ - m_control_bus_channel_count->set_sensitive(m_create_control_bus->get_active()); -} - -void -NewSessionDialog::reset_template() -{ - m_template->unselect_all (); -} - -void -NewSessionDialog::reset_recent() -{ - /* Shamelessly ripped from ardour_ui.cc */ - std::vector *sessions; - std::vector::iterator i; - RecentSessionsSorter cmp; - - recent_model->clear (); - - ARDOUR::RecentSessions rs; - ARDOUR::read_recent_sessions (rs); - - /* sort them alphabetically */ - sort (rs.begin(), rs.end(), cmp); - sessions = new std::vector; - - for (ARDOUR::RecentSessions::iterator i = rs.begin(); i != rs.end(); ++i) { - sessions->push_back (new string ((*i).second)); - } - - for (i = sessions->begin(); i != sessions->end(); ++i) { - - std::vector* states; - std::vector item; - std::string fullpath = *(*i); - - /* remove any trailing / */ - - if (fullpath[fullpath.length()-1] == '/') { - fullpath = fullpath.substr (0, fullpath.length()-1); - } - - /* check whether session still exists */ - if (!Glib::file_test(fullpath, Glib::FILE_TEST_EXISTS)) { - /* session doesn't exist */ - continue; - } - - /* now get available states for this session */ - - if ((states = ARDOUR::Session::possible_states (fullpath)) == 0) { - /* no state file? */ - continue; - } - - Gtk::TreeModel::Row row = *(recent_model->append()); - - row[recent_columns.visible_name] = Glib::path_get_basename (fullpath); - row[recent_columns.fullpath] = fullpath; - - if (states->size()) { - - /* add the children */ - - for (std::vector::iterator i2 = states->begin(); i2 != states->end(); ++i2) { - - Gtk::TreeModel::Row child_row = *(recent_model->append (row.children())); - - child_row[recent_columns.visible_name] = **i2; - child_row[recent_columns.fullpath] = fullpath; - - delete *i2; - } - } - - delete states; - } - delete sessions; -} - -void -NewSessionDialog::reset() -{ - reset_name(); - reset_template(); - set_response_sensitive (Gtk::RESPONSE_NONE, false); -} - -void -NewSessionDialog::set_offer_cancel (bool yn) -{ - if (yn) { - quit_or_cancel_button->set_label (X_("gtk-cancel")); - } else { - quit_or_cancel_button->set_label (X_("gtk-quit")); - } -} diff --git a/gtk2_ardour/new_session_dialog.h b/gtk2_ardour/new_session_dialog.h deleted file mode 100644 index 465faa797e..0000000000 --- a/gtk2_ardour/new_session_dialog.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - Copyright (C) 2005 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -// -*- c++ -*- - -#ifndef NEW_SESSION_DIALOG_H -#define NEW_SESSION_DIALOG_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ardour/utils.h" - -#include - -#include "ardour_dialog.h" -#include "engine_dialog.h" - -namespace Gtk { - class Entry; - class FileChooserButton; - class SpinButton; - class CheckButton; - class RadioButton; - class TreeView; - class Notebook; -} - -class NewSessionDialog : public ArdourDialog -{ -public: - - enum Pages { - NewPage = 0x1, - OpenPage = 0x2, - EnginePage = 0x4 - }; - - NewSessionDialog(); - ~NewSessionDialog (); - - int run (); - - void set_session_name(const Glib::ustring& name); - void set_session_folder(const Glib::ustring& folder); - - std::string session_name() const; - std::string session_folder() const; - - bool use_session_template() const; - std::string session_template_name() const; - - // advanced. - - bool create_master_bus() const; - int master_channel_count() const; - - bool create_control_bus() const; - int control_channel_count() const; - - bool connect_inputs() const; - bool limit_inputs_used_for_connection() const; - int input_limit_count() const; - - bool connect_outputs() const; - bool limit_outputs_used_for_connection() const; - int output_limit_count() const; - - bool connect_outs_to_master() const; - bool connect_outs_to_physical() const ; - Pages which_page () const; - - int get_current_page(); - void set_current_page (int); - void reset_recent(); - - // reset everything to default values. - void reset(); - - EngineControl engine_control; - void set_have_engine (bool yn); - void set_existing_session (bool yn); - void set_offer_cancel (bool yn); - -protected: - - void reset_name(); - void reset_template(); - - Gtk::Label * session_name_label; - Gtk::Label * session_location_label; - Gtk::Label * session_template_label; - Gtk::Label * chan_count_label_1; - Gtk::Label * chan_count_label_2; - Gtk::Label * chan_count_label_3; - Gtk::Label * chan_count_label_4; - Gtk::Table * advanced_table; - Gtk::HBox * input_port_limit_hbox; - Gtk::VBox * input_port_vbox; - Gtk::Table * input_table; - Gtk::HBox * input_hbox; - - Gtk::Label * bus_label; - Gtk::Frame * bus_frame; - Gtk::Table * bus_table; - Gtk::HBox * bus_hbox; - - Gtk::Label * input_label; - Gtk::Frame * input_frame; - Gtk::HBox * output_port_limit_hbox; - Gtk::VBox * output_port_vbox; - Gtk::VBox * output_conn_vbox; - Gtk::VBox * output_vbox; - Gtk::HBox * output_hbox; - - Gtk::Label * output_label; - Gtk::Frame * output_frame; - Gtk::VBox * advanced_vbox; - Gtk::Label * advanced_label; - Gtk::Expander * advanced_expander; - Gtk::Table * new_session_table; - Gtk::HBox * open_session_hbox; - Gtk::ScrolledWindow * recent_scrolledwindow; - - Gtk::Label * recent_sesion_label; - Gtk::Frame * recent_frame; - Gtk::VBox * open_session_vbox; - Gtk::Entry* m_name; - Gtk::FileChooserButton* m_folder; - Gtk::FileChooserButton* m_template; - Gtk::Label * open_session_file_label; - - Gtk::CheckButton* m_create_master_bus; - Gtk::SpinButton* m_master_bus_channel_count; - - Gtk::CheckButton* m_create_control_bus; - Gtk::SpinButton* m_control_bus_channel_count; - - Gtk::CheckButton* m_connect_inputs; - Gtk::CheckButton* m_limit_input_ports; - Gtk::SpinButton* m_input_limit_count; - - Gtk::CheckButton* m_connect_outputs; - Gtk::CheckButton* m_limit_output_ports; - Gtk::SpinButton* m_output_limit_count; - - Gtk::RadioButton* m_connect_outputs_to_master; - Gtk::RadioButton* m_connect_outputs_to_physical; - Gtk::Button* m_okbutton; - - Gtk::FileChooserButton* m_open_filechooser; - Gtk::TreeView* m_treeview; - Gtk::Notebook* m_notebook; - - private: - - Pages page_set; - - struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord { - RecentSessionModelColumns() { - add (visible_name); - add (fullpath); - } - Gtk::TreeModelColumn visible_name; - Gtk::TreeModelColumn fullpath; - }; - - RecentSessionModelColumns recent_columns; - Glib::RefPtr recent_model; - - bool in_destructor; - - void recent_session_selection_changed (); - void nsd_redisplay_recent_sessions(); - void nsd_recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col); - struct RecentSessionsSorter { - bool operator() (std::pair a, std::pair b) const { - return cmp_nocase(a.first, b.first) == -1; - } - }; - void on_new_session_name_entry_changed(); - void notebook_page_changed (GtkNotebookPage*, uint); - void treeview_selection_changed (); - void file_chosen (); - void template_chosen (); - void recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*); - void connect_inputs_clicked (); - void connect_outputs_clicked (); - void limit_inputs_clicked (); - void limit_outputs_clicked (); - void master_bus_button_clicked (); - void monitor_bus_button_clicked (); - - bool on_new_session_page; - bool have_engine; - Glib::ustring engine_page_session_folder; - Glib::ustring engine_page_session_name; - - Gtk::Button* quit_or_cancel_button; -}; - -#endif // NEW_SESSION_DIALOG_H diff --git a/gtk2_ardour/startup.cc b/gtk2_ardour/startup.cc index fe2bbe03c1..d2caf0646b 100644 --- a/gtk2_ardour/startup.cc +++ b/gtk2_ardour/startup.cc @@ -1,3 +1,4 @@ +#include #include #include @@ -14,6 +15,7 @@ #include "ardour/template_utils.h" #include "startup.h" +#include "engine_dialog.h" #include "i18n.h" using namespace std; @@ -34,7 +36,25 @@ ArdourStartup::ArdourStartup () Ardour will play NO role in monitoring")) , monitor_via_ardour_button (_("Ask Ardour to playback material as it is being recorded")) , new_folder_chooser (FILE_CHOOSER_ACTION_SELECT_FOLDER) + , _output_limit_count_adj (1, 0, 100, 1, 10, 0) + , _input_limit_count_adj (1, 0, 100, 1, 10, 0) + , _control_bus_channel_count_adj (2, 0, 100, 1, 10, 0) + , _master_bus_channel_count_adj (2, 0, 100, 1, 10, 0) + { + audio_page_index = -1; + initial_choice_index = -1; + new_user_page_index = -1; + default_folder_page_index = -1; + monitoring_page_index = -1; + session_page_index = -1; + final_page_index = -1; + session_options_page_index = -1; + + engine_dialog = 0; + config_modified = false; + default_dir_chooser = 0; + set_keep_above (true); set_position (WIN_POS_CENTER); @@ -54,19 +74,35 @@ Ardour will play NO role in monitoring")) sys::path been_here_before = user_config_directory(); been_here_before /= ".a3"; // XXXX use more specific version so we can catch upgrades - - if (!exists (been_here_before)) { - // XXX touch been_here_before; + bool new_user = !exists (been_here_before); + bool need_audio_setup = !EngineControl::engine_running(); + + if (new_user) { + /* "touch" the file */ + ofstream fout (been_here_before.to_string().c_str()); setup_new_user_page (); setup_first_time_config_page (); setup_monitoring_choice_page (); + + if (need_audio_setup) { + setup_audio_page (); + } + } else { + + if (need_audio_setup) { + setup_audio_page (); + } + setup_initial_choice_page (); } setup_session_page (); setup_more_options_page (); - setup_final_page (); + + if (new_user) { + setup_final_page (); + } the_startup = this; } @@ -75,18 +111,70 @@ ArdourStartup::~ArdourStartup () { } +Glib::ustring +ArdourStartup::session_name (bool& should_be_new) +{ + if (ic_new_session_button.get_active()) { + should_be_new = true; + return new_name_entry.get_text (); + } else { + should_be_new = false; + + TreeIter iter = recent_session_display.get_selection()->get_selected(); + + if (iter) { + return (*iter)[recent_session_columns.visible_name]; + } + + return ""; + } +} + +Glib::ustring +ArdourStartup::session_folder () +{ + if (ic_new_session_button.get_active()) { + return new_folder_chooser.get_current_folder(); + } else { + TreeIter iter = recent_session_display.get_selection()->get_selected(); + + if (iter) { + return (*iter)[recent_session_columns.fullpath]; + } + return ""; + } +} + +void +ArdourStartup::setup_audio_page () +{ + engine_dialog = manage (new EngineControl); + + engine_dialog->show_all (); + + audio_page_index = append_page (*engine_dialog); + set_page_type (*engine_dialog, ASSISTANT_PAGE_CONTENT); + set_page_title (*engine_dialog, _("Audio Setup")); + + /* the default parameters should work, so the page is potentially complete */ + + set_page_complete (*engine_dialog, true); +} + void ArdourStartup::setup_new_user_page () { - Label* foomatic = manage (new Label (_("\ -Ardour is a digital audio workstation. You can use it to\n\ + Label* foomatic = manage (new Label); + + foomatic->set_markup (_("\ +Ardour is a digital audio workstation. You can use it to\n\ record, edit and mix multi-track audio. You can produce your\n\ own CDs, mix video soundtracks, or just experiment with new\n\ ideas about music and sound.\n\ \n\ There are a few things that need to configured before you start\n\ -using the program.\ -"))); +using the program.\ +")); HBox* hbox = manage (new HBox); HBox* vbox = manage (new HBox); @@ -101,17 +189,25 @@ using the program.\ hbox->show (); vbox->show (); - append_page (*vbox); + new_user_page_index = append_page (*vbox); set_page_type (*vbox, ASSISTANT_PAGE_INTRO); set_page_title (*vbox, _("Welcome to Ardour")); set_page_header_image (*vbox, icon_pixbuf); set_page_complete (*vbox, true); } +void +ArdourStartup::default_dir_changed () +{ + Config->set_default_session_parent_dir (default_dir_chooser->get_current_folder()); + config_modified = true; +} + void ArdourStartup::setup_first_time_config_page () { - Gtk::FileChooserButton* fcb = manage (new FileChooserButton (_("Default session folder"), FILE_CHOOSER_ACTION_SELECT_FOLDER)); + default_dir_chooser = manage (new FileChooserButton (_("Default folder for Ardour sessions"), + FILE_CHOOSER_ACTION_SELECT_FOLDER)); Gtk::Label* txt = manage (new Label); HBox* hbox1 = manage (new HBox); VBox* vbox = manage (new VBox); @@ -126,16 +222,26 @@ Where would you like new Ardour sessions to be stored by default?\n\ hbox1->set_border_width (6); vbox->set_border_width (6); - hbox1->pack_start (*fcb, false, true); + hbox1->pack_start (*default_dir_chooser, false, true); vbox->pack_start (*txt, false, true); vbox->pack_start (*hbox1, false, true); - fcb->show (); + string def = Config->get_default_session_parent_dir(); + + /* XXX really need glob here */ + + if (def == "~") { + def = Glib::get_home_dir(); + } + default_dir_chooser->set_current_folder (def); + default_dir_chooser->signal_current_folder_changed().connect (mem_fun (*this, &ArdourStartup::default_dir_changed)); + default_dir_chooser->show (); + txt->show (); hbox1->show (); vbox->show (); - append_page (*vbox); + default_folder_page_index = append_page (*vbox); set_page_title (*vbox, _("Default folder for new sessions")); set_page_header_image (*vbox, icon_pixbuf); set_page_type (*vbox, ASSISTANT_PAGE_CONTENT); @@ -162,16 +268,16 @@ configuration of that equipment. The two most common are presented here.\n\ Please choose whichever one is right for your setup.\n\n\ You can change this preference at any time, via the Options menu"); - mon_vbox.pack_start (monitor_label); - mon_vbox.pack_start (monitor_via_hardware_button); - mon_vbox.pack_start (monitor_via_ardour_button); + mon_vbox.pack_start (monitor_label, false, false); + mon_vbox.pack_start (monitor_via_hardware_button, false, false); + mon_vbox.pack_start (monitor_via_ardour_button, false, false); mon_vbox.show (); monitor_label.show (); monitor_via_ardour_button.show (); monitor_via_hardware_button.show (); - append_page (mon_vbox); + monitoring_page_index = append_page (mon_vbox); set_page_title (mon_vbox, _("Monitoring Choices")); set_page_header_image (mon_vbox, icon_pixbuf); @@ -191,14 +297,23 @@ ArdourStartup::setup_initial_choice_page () RadioButton::Group g (ic_new_session_button.get_group()); ic_existing_session_button.set_group (g); - ic_vbox.pack_start (ic_new_session_button); - ic_vbox.pack_start (ic_existing_session_button); + HBox* centering_hbox = manage (new HBox); + VBox* centering_vbox = manage (new VBox); + + centering_vbox->pack_start (ic_new_session_button, false, true); + centering_vbox->pack_start (ic_existing_session_button, false, true); + centering_vbox->show (); + + centering_hbox->pack_start (*centering_vbox, true, true); + centering_hbox->show (); + + ic_vbox.pack_start (*centering_hbox, true, true); ic_new_session_button.show (); ic_existing_session_button.show (); ic_vbox.show (); - append_page (ic_vbox); + initial_choice_index = append_page (ic_vbox); set_page_title (ic_vbox, _("What would you like to do?")); set_page_header_image (ic_vbox, icon_pixbuf); @@ -219,7 +334,9 @@ ArdourStartup::setup_session_page () session_vbox.show (); session_hbox.show (); - append_page (session_vbox); + session_page_index = append_page (session_vbox); + /* initial setting */ + set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM); } void @@ -227,7 +344,7 @@ ArdourStartup::setup_final_page () { final_page.set_text ("Ardour is ready for use"); final_page.show (); - append_page (final_page); + final_page_index = append_page (final_page); set_page_complete (final_page, true); set_page_header_image (final_page, icon_pixbuf); set_page_type (final_page, ASSISTANT_PAGE_CONFIRM); @@ -254,6 +371,25 @@ ArdourStartup::on_apply () // XXX do stuff and then .... + if (engine_dialog) { + engine_dialog->setup_engine (); + } + + if (config_modified) { + + if (default_dir_chooser) { + Config->set_default_session_parent_dir (default_dir_chooser->get_current_folder()); + } + + if (monitor_via_hardware_button.get_active()) { + Config->set_monitoring_model (ExternalMonitoring); + } else if (monitor_via_ardour_button.get_active()) { + Config->set_monitoring_model (SoftwareMonitoring); + } + + Config->save_state (); + } + gtk_main_quit (); } @@ -261,6 +397,7 @@ void ArdourStartup::on_prepare (Gtk::Widget* page) { if (page == &session_vbox) { + if (ic_new_session_button.get_active()) { /* new session requested */ setup_new_session_page (); @@ -268,7 +405,7 @@ ArdourStartup::on_prepare (Gtk::Widget* page) /* existing session requested */ setup_existing_session_page (); } - } + } } void @@ -294,6 +431,7 @@ ArdourStartup::setup_new_session_page () new_name_entry.show (); new_name_entry.signal_changed().connect (mem_fun (*this, &ArdourStartup::new_name_changed)); + new_name_entry.signal_activate().connect (mem_fun (*this, &ArdourStartup::move_along_now)); HBox* hbox2 = manage (new HBox); Label* label2 = manage (new Label); @@ -303,7 +441,16 @@ ArdourStartup::setup_new_session_page () hbox2->pack_start (new_folder_chooser, true, true); label2->set_text (_("Create session folder in:")); - new_folder_chooser.set_current_folder(getenv ("HOME")); + + string def = Config->get_default_session_parent_dir(); + + /* XXX really need glob here */ + + if (def == "~") { + def = Glib::get_home_dir(); + } + + new_folder_chooser.set_current_folder (def); new_folder_chooser.set_title (_("Select folder for session")); hbox2->show(); @@ -360,6 +507,9 @@ ArdourStartup::setup_new_session_page () session_new_vbox.show (); session_hbox.pack_start (session_new_vbox, false, false); set_page_title (session_vbox, _("New Session")); + set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM); + + new_name_entry.grab_focus (); } void @@ -396,11 +546,10 @@ ArdourStartup::redisplay_recent_sessions () session_directories.push_back ((*i).second); } - for (vector::const_iterator i = session_directories.begin(); - i != session_directories.end(); ++i) + for (vector::const_iterator i = session_directories.begin(); i != session_directories.end(); ++i) { std::vector state_file_paths; - + // now get available states for this session get_state_files_in_directory (*i, state_file_paths); @@ -418,7 +567,6 @@ ArdourStartup::redisplay_recent_sessions () /* check whether session still exists */ if (!Glib::file_test(fullpath.c_str(), Glib::FILE_TEST_EXISTS)) { /* session doesn't exist */ - cerr << "skipping non-existent session " << fullpath << endl; continue; } @@ -490,6 +638,7 @@ ArdourStartup::setup_existing_session_page () recent_scroller.show(); redisplay_recent_sessions (); + recent_session_display.signal_row_activated().connect (mem_fun (*this, &ArdourStartup::recent_row_activated)); session_hbox.pack_start (recent_scroller, true, true); set_page_title (session_vbox, _("Select a session")); @@ -500,8 +649,11 @@ void ArdourStartup::more_new_session_options_button_clicked () { if (more_new_session_options_button.get_active()) { - more_options_vbox.show (); + more_options_vbox.show_all (); + set_page_type (more_options_vbox, ASSISTANT_PAGE_CONFIRM); + set_page_type (session_vbox, ASSISTANT_PAGE_CONTENT); } else { + set_page_type (session_vbox, ASSISTANT_PAGE_CONFIRM); more_options_vbox.hide (); } } @@ -509,24 +661,354 @@ ArdourStartup::more_new_session_options_button_clicked () void ArdourStartup::setup_more_options_page () { - Label* foomatic = manage (new Label); - foomatic->set_text (_("Here be more options....")); - foomatic->show (); - more_options_vbox.set_border_width (12); - more_options_hbox.set_border_width (12); - - more_options_hbox.pack_start (*foomatic, true, true); - more_options_vbox.pack_start (more_options_hbox, true, true); - more_options_hbox.show (); + _output_limit_count.set_adjustment (_output_limit_count_adj); + _input_limit_count.set_adjustment (_input_limit_count_adj); + _control_bus_channel_count.set_adjustment (_control_bus_channel_count_adj); + _master_bus_channel_count.set_adjustment (_master_bus_channel_count_adj); + + chan_count_label_1.set_text (_("channels")); + chan_count_label_2.set_text (_("channels")); + chan_count_label_3.set_text (_("channels")); + chan_count_label_4.set_text (_("channels")); + + chan_count_label_1.set_alignment(0,0.5); + chan_count_label_1.set_padding(0,0); + chan_count_label_1.set_line_wrap(false); + + chan_count_label_2.set_alignment(0,0.5); + chan_count_label_2.set_padding(0,0); + chan_count_label_2.set_line_wrap(false); + + chan_count_label_3.set_alignment(0,0.5); + chan_count_label_3.set_padding(0,0); + chan_count_label_3.set_line_wrap(false); + + chan_count_label_4.set_alignment(0,0.5); + chan_count_label_4.set_padding(0,0); + chan_count_label_4.set_line_wrap(false); + + bus_label.set_markup (_("Busses")); + input_label.set_markup (_("Inputs")); + output_label.set_markup (_("Outputs")); + + _create_control_bus.set_label (_("Create monitor bus")); + _create_control_bus.set_flags(Gtk::CAN_FOCUS); + _create_control_bus.set_relief(Gtk::RELIEF_NORMAL); + _create_control_bus.set_mode(true); + _create_control_bus.set_active(false); + _create_control_bus.set_border_width(0); + + _control_bus_channel_count.set_flags(Gtk::CAN_FOCUS); + _control_bus_channel_count.set_update_policy(Gtk::UPDATE_ALWAYS); + _control_bus_channel_count.set_numeric(true); + _control_bus_channel_count.set_digits(0); + _control_bus_channel_count.set_wrap(false); + _control_bus_channel_count.set_sensitive(false); + + _master_bus_channel_count.set_flags(Gtk::CAN_FOCUS); + _master_bus_channel_count.set_update_policy(Gtk::UPDATE_ALWAYS); + _master_bus_channel_count.set_numeric(true); + _master_bus_channel_count.set_digits(0); + _master_bus_channel_count.set_wrap(false); + + _create_master_bus.set_label (_("Create master bus")); + _create_master_bus.set_flags(Gtk::CAN_FOCUS); + _create_master_bus.set_relief(Gtk::RELIEF_NORMAL); + _create_master_bus.set_mode(true); + _create_master_bus.set_active(true); + _create_master_bus.set_border_width(0); + + advanced_table.set_row_spacings(0); + advanced_table.set_col_spacings(0); + + _connect_inputs.set_label (_("Automatically connect to physical_inputs")); + _connect_inputs.set_flags(Gtk::CAN_FOCUS); + _connect_inputs.set_relief(Gtk::RELIEF_NORMAL); + _connect_inputs.set_mode(true); + _connect_inputs.set_active(true); + _connect_inputs.set_border_width(0); + + _limit_input_ports.set_label (_("Use only")); + _limit_input_ports.set_flags(Gtk::CAN_FOCUS); + _limit_input_ports.set_relief(Gtk::RELIEF_NORMAL); + _limit_input_ports.set_mode(true); + _limit_input_ports.set_sensitive(true); + _limit_input_ports.set_border_width(0); + + _input_limit_count.set_flags(Gtk::CAN_FOCUS); + _input_limit_count.set_update_policy(Gtk::UPDATE_ALWAYS); + _input_limit_count.set_numeric(true); + _input_limit_count.set_digits(0); + _input_limit_count.set_wrap(false); + _input_limit_count.set_sensitive(false); + + bus_hbox.pack_start (bus_table, Gtk::PACK_SHRINK, 18); + + bus_label.set_alignment(0, 0.5); + bus_label.set_padding(0,0); + bus_label.set_line_wrap(false); + bus_label.set_selectable(false); + bus_label.set_use_markup(true); + bus_frame.set_shadow_type(Gtk::SHADOW_NONE); + bus_frame.set_label_align(0,0.5); + bus_frame.add(bus_hbox); + bus_frame.set_label_widget(bus_label); + + bus_table.set_row_spacings (0); + bus_table.set_col_spacings (0); + bus_table.attach (_create_master_bus, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + bus_table.attach (_master_bus_channel_count, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + bus_table.attach (chan_count_label_1, 2, 3, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0); + bus_table.attach (_create_control_bus, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + bus_table.attach (_control_bus_channel_count, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0); + bus_table.attach (chan_count_label_2, 2, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0); + + input_port_limit_hbox.pack_start(_limit_input_ports, Gtk::PACK_SHRINK, 6); + input_port_limit_hbox.pack_start(_input_limit_count, Gtk::PACK_SHRINK, 0); + input_port_limit_hbox.pack_start(chan_count_label_3, Gtk::PACK_SHRINK, 6); + input_port_vbox.pack_start(_connect_inputs, Gtk::PACK_SHRINK, 0); + input_port_vbox.pack_start(input_port_limit_hbox, Gtk::PACK_EXPAND_PADDING, 0); + input_table.set_row_spacings(0); + input_table.set_col_spacings(0); + input_table.attach(input_port_vbox, 0, 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 6); + + input_hbox.pack_start (input_table, Gtk::PACK_SHRINK, 18); + + input_label.set_alignment(0, 0.5); + input_label.set_padding(0,0); + input_label.set_line_wrap(false); + input_label.set_selectable(false); + input_label.set_use_markup(true); + input_frame.set_shadow_type(Gtk::SHADOW_NONE); + input_frame.set_label_align(0,0.5); + input_frame.add(input_hbox); + input_frame.set_label_widget(input_label); + + _connect_outputs.set_label (_("Automatically connect outputs")); + _connect_outputs.set_flags(Gtk::CAN_FOCUS); + _connect_outputs.set_relief(Gtk::RELIEF_NORMAL); + _connect_outputs.set_mode(true); + _connect_outputs.set_active(true); + _connect_outputs.set_border_width(0); + _limit_output_ports.set_label (_("Use only")); + _limit_output_ports.set_flags(Gtk::CAN_FOCUS); + _limit_output_ports.set_relief(Gtk::RELIEF_NORMAL); + _limit_output_ports.set_mode(true); + _limit_output_ports.set_sensitive(true); + _limit_output_ports.set_border_width(0); + _output_limit_count.set_flags(Gtk::CAN_FOCUS); + _output_limit_count.set_update_policy(Gtk::UPDATE_ALWAYS); + _output_limit_count.set_numeric(false); + _output_limit_count.set_digits(0); + _output_limit_count.set_wrap(false); + _output_limit_count.set_sensitive(false); + output_port_limit_hbox.pack_start(_limit_output_ports, Gtk::PACK_SHRINK, 6); + output_port_limit_hbox.pack_start(_output_limit_count, Gtk::PACK_SHRINK, 0); + output_port_limit_hbox.pack_start(chan_count_label_4, Gtk::PACK_SHRINK, 6); + + _connect_outputs_to_master.set_label (_("... to master bus")); + _connect_outputs_to_master.set_flags(Gtk::CAN_FOCUS); + _connect_outputs_to_master.set_relief(Gtk::RELIEF_NORMAL); + _connect_outputs_to_master.set_mode(true); + _connect_outputs_to_master.set_active(false); + _connect_outputs_to_master.set_border_width(0); + + _connect_outputs_to_master.set_group (connect_outputs_group); + _connect_outputs_to_physical.set_group (connect_outputs_group); + + _connect_outputs_to_physical.set_label (_("... to physical outputs")); + _connect_outputs_to_physical.set_flags(Gtk::CAN_FOCUS); + _connect_outputs_to_physical.set_relief(Gtk::RELIEF_NORMAL); + _connect_outputs_to_physical.set_mode(true); + _connect_outputs_to_physical.set_active(false); + _connect_outputs_to_physical.set_border_width(0); + + output_conn_vbox.pack_start(_connect_outputs, Gtk::PACK_SHRINK, 0); + output_conn_vbox.pack_start(_connect_outputs_to_master, Gtk::PACK_SHRINK, 0); + output_conn_vbox.pack_start(_connect_outputs_to_physical, Gtk::PACK_SHRINK, 0); + output_vbox.set_border_width(6); + + output_port_vbox.pack_start(output_port_limit_hbox, Gtk::PACK_SHRINK, 0); + + output_vbox.pack_start(output_conn_vbox); + output_vbox.pack_start(output_port_vbox); + + output_label.set_alignment(0, 0.5); + output_label.set_padding(0,0); + output_label.set_line_wrap(false); + output_label.set_selectable(false); + output_label.set_use_markup(true); + output_frame.set_shadow_type(Gtk::SHADOW_NONE); + output_frame.set_label_align(0,0.5); + + output_hbox.pack_start (output_vbox, Gtk::PACK_SHRINK, 18); + + output_frame.add(output_hbox); + output_frame.set_label_widget(output_label); + + more_options_vbox.pack_start(advanced_table, Gtk::PACK_SHRINK, 0); + more_options_vbox.pack_start(bus_frame, Gtk::PACK_SHRINK, 6); + more_options_vbox.pack_start(input_frame, Gtk::PACK_SHRINK, 6); + more_options_vbox.pack_start(output_frame, Gtk::PACK_SHRINK, 0); + + /* signals */ + + _connect_inputs.signal_clicked().connect (mem_fun (*this, &ArdourStartup::connect_inputs_clicked)); + _connect_outputs.signal_clicked().connect (mem_fun (*this, &ArdourStartup::connect_outputs_clicked)); + _limit_input_ports.signal_clicked().connect (mem_fun (*this, &ArdourStartup::limit_inputs_clicked)); + _limit_output_ports.signal_clicked().connect (mem_fun (*this, &ArdourStartup::limit_outputs_clicked)); + _create_master_bus.signal_clicked().connect (mem_fun (*this, &ArdourStartup::master_bus_button_clicked)); + _create_control_bus.signal_clicked().connect (mem_fun (*this, &ArdourStartup::monitor_bus_button_clicked)); /* note that more_options_vbox is NOT visible by * default. this is entirely by design - this page * should be skipped unless explicitly requested. */ - append_page (more_options_vbox); + session_options_page_index = append_page (more_options_vbox); set_page_title (more_options_vbox, _("Advanced Session Options")); set_page_complete (more_options_vbox, true); } + +bool +ArdourStartup::create_master_bus() const +{ + return _create_master_bus.get_active(); +} + +int +ArdourStartup::master_channel_count() const +{ + return _master_bus_channel_count.get_value_as_int(); +} + +bool +ArdourStartup::create_control_bus() const +{ + return _create_control_bus.get_active(); +} + +int +ArdourStartup::control_channel_count() const +{ + return _control_bus_channel_count.get_value_as_int(); +} + +bool +ArdourStartup::connect_inputs() const +{ + return _connect_inputs.get_active(); +} + +bool +ArdourStartup::limit_inputs_used_for_connection() const +{ + return _limit_input_ports.get_active(); +} + +int +ArdourStartup::input_limit_count() const +{ + return _input_limit_count.get_value_as_int(); +} + +bool +ArdourStartup::connect_outputs() const +{ + return _connect_outputs.get_active(); +} + +bool +ArdourStartup::limit_outputs_used_for_connection() const +{ + return _limit_output_ports.get_active(); +} + +int +ArdourStartup::output_limit_count() const +{ + return _output_limit_count.get_value_as_int(); +} + +bool +ArdourStartup::connect_outs_to_master() const +{ + return _connect_outputs_to_master.get_active(); +} + +bool +ArdourStartup::connect_outs_to_physical() const +{ + return _connect_outputs_to_physical.get_active(); +} + +void +ArdourStartup::connect_inputs_clicked () +{ + _limit_input_ports.set_sensitive(_connect_inputs.get_active()); + + if (_connect_inputs.get_active() && _limit_input_ports.get_active()) { + _input_limit_count.set_sensitive(true); + } else { + _input_limit_count.set_sensitive(false); + } +} + +void +ArdourStartup::connect_outputs_clicked () +{ + _limit_output_ports.set_sensitive(_connect_outputs.get_active()); + + if (_connect_outputs.get_active() && _limit_output_ports.get_active()) { + _output_limit_count.set_sensitive(true); + } else { + _output_limit_count.set_sensitive(false); + } +} + +void +ArdourStartup::limit_inputs_clicked () +{ + _input_limit_count.set_sensitive(_limit_input_ports.get_active()); +} + +void +ArdourStartup::limit_outputs_clicked () +{ + _output_limit_count.set_sensitive(_limit_output_ports.get_active()); +} + +void +ArdourStartup::master_bus_button_clicked () +{ + _master_bus_channel_count.set_sensitive(_create_master_bus.get_active()); +} + +void +ArdourStartup::monitor_bus_button_clicked () +{ + _control_bus_channel_count.set_sensitive(_create_control_bus.get_active()); +} + +void +ArdourStartup::move_along_now () +{ + gint cur = get_current_page (); + + if (cur == session_page_index) { + if (more_new_session_options_button.get_active()) { + set_current_page (session_options_page_index); + } else { + on_apply (); + } + } +} + +void +ArdourStartup::recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col) +{ + set_page_complete (session_vbox, true); + move_along_now (); +} diff --git a/gtk2_ardour/startup.h b/gtk2_ardour/startup.h index 96adf954ba..f01d972899 100644 --- a/gtk2_ardour/startup.h +++ b/gtk2_ardour/startup.h @@ -14,14 +14,47 @@ #include #include #include +#include +#include +#include + +class EngineControl; class ArdourStartup : public Gtk::Assistant { public: ArdourStartup (); ~ArdourStartup (); + Glib::ustring session_name (bool& should_be_new); + Glib::ustring session_folder (); + + bool use_session_template() { return false; } + Glib::ustring session_template_name() { return ""; } + + EngineControl& engine_control() { return *engine_dialog; } + + // advanced session options + + bool create_master_bus() const; + int master_channel_count() const; + + bool create_control_bus() const; + int control_channel_count() const; + + bool connect_inputs() const; + bool limit_inputs_used_for_connection() const; + int input_limit_count() const; + + bool connect_outputs() const; + bool limit_outputs_used_for_connection() const; + int output_limit_count() const; + + bool connect_outs_to_master() const; + bool connect_outs_to_physical() const ; + private: bool applying; + bool config_modified; void on_apply (); void on_cancel (); @@ -40,6 +73,8 @@ class ArdourStartup : public Gtk::Assistant { void setup_first_time_config_page (); /* first page */ + Gtk::FileChooserButton* default_dir_chooser; + void default_dir_changed(); void setup_first_page (); /* initial choice page */ @@ -88,6 +123,12 @@ class ArdourStartup : public Gtk::Assistant { Gtk::ScrolledWindow recent_scroller; void redisplay_recent_sessions (); void recent_session_row_selected (); + void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col); + + /* audio setup page */ + + void setup_audio_page (); + EngineControl* engine_dialog; /* new sessions */ @@ -104,7 +145,64 @@ class ArdourStartup : public Gtk::Assistant { /* more options for new sessions */ Gtk::VBox more_options_vbox; - Gtk::HBox more_options_hbox; + + Gtk::Label chan_count_label_1; + Gtk::Label chan_count_label_2; + Gtk::Label chan_count_label_3; + Gtk::Label chan_count_label_4; + Gtk::Table advanced_table; + Gtk::HBox input_port_limit_hbox; + Gtk::VBox input_port_vbox; + Gtk::Table input_table; + Gtk::HBox input_hbox; + + Gtk::Label bus_label; + Gtk::Frame bus_frame; + Gtk::Table bus_table; + Gtk::HBox bus_hbox; + + Gtk::Label input_label; + Gtk::Frame input_frame; + Gtk::HBox output_port_limit_hbox; + Gtk::VBox output_port_vbox; + Gtk::VBox output_conn_vbox; + Gtk::VBox output_vbox; + Gtk::HBox output_hbox; + + Gtk::Label output_label; + Gtk::Frame output_frame; + Gtk::VBox advanced_vbox; + Gtk::Label advanced_label; + + Gtk::CheckButton _create_master_bus; + Gtk::SpinButton _master_bus_channel_count; + + Gtk::CheckButton _create_control_bus; + Gtk::SpinButton _control_bus_channel_count; + + Gtk::CheckButton _connect_inputs; + Gtk::CheckButton _limit_input_ports; + Gtk::SpinButton _input_limit_count; + + Gtk::CheckButton _connect_outputs; + Gtk::CheckButton _limit_output_ports; + Gtk::SpinButton _output_limit_count; + + Gtk::RadioButtonGroup connect_outputs_group; + Gtk::RadioButton _connect_outputs_to_master; + Gtk::RadioButton _connect_outputs_to_physical; + + Gtk::Adjustment _output_limit_count_adj; + Gtk::Adjustment _input_limit_count_adj; + Gtk::Adjustment _control_bus_channel_count_adj; + Gtk::Adjustment _master_bus_channel_count_adj; + + void connect_inputs_clicked (); + void connect_outputs_clicked (); + void limit_inputs_clicked (); + void limit_outputs_clicked (); + void master_bus_button_clicked (); + void monitor_bus_button_clicked (); void setup_more_options_page (); /* final page */ @@ -116,8 +214,19 @@ class ArdourStartup : public Gtk::Assistant { Glib::RefPtr layout; + /* page indices */ + gint audio_page_index; + gint new_user_page_index; + gint default_folder_page_index; + gint monitoring_page_index; + gint session_page_index; + gint initial_choice_index; + gint final_page_index; + gint session_options_page_index; + void move_along_now (); + }; #endif /* __gtk2_ardour_startup_h__ */ diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 6949d05d3d..4624440ad6 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -158,7 +158,6 @@ def build(bld): mixer_strip.cc mixer_ui.cc nag.cc - new_session_dialog.cc option_editor.cc opts.cc panner.cc