diff options
author | solido <solido@dummy.example.com> | 2005-11-14 08:38:16 +0000 |
---|---|---|
committer | solido <solido@dummy.example.com> | 2005-11-14 08:38:16 +0000 |
commit | f0416627d63d94cac80e7fc2e0e585b79a8147f0 (patch) | |
tree | f62292c10e578f85f259e22f036e609982fd0fa9 /gtk2_ardour/new_session_dialog.cc | |
parent | 3c6f29ceeacc6bf2f393169792903a730dd84ad7 (diff) |
support for glade and new new session dialog
git-svn-id: svn://localhost/trunk/ardour2@88 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/new_session_dialog.cc')
-rw-r--r-- | gtk2_ardour/new_session_dialog.cc | 379 |
1 files changed, 114 insertions, 265 deletions
diff --git a/gtk2_ardour/new_session_dialog.cc b/gtk2_ardour/new_session_dialog.cc index 854e702232..428facdfba 100644 --- a/gtk2_ardour/new_session_dialog.cc +++ b/gtk2_ardour/new_session_dialog.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 1999-2002 Paul Davis + 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 @@ -18,322 +18,171 @@ $Id$ */ -#include <list> -#include <string> -#include <ardour/session.h> -#include <ardour/audioengine.h> - -#include "prompter.h" +#include "i18n.h" #include "new_session_dialog.h" +#include "glade_path.h" -using namespace Gtkmm2ext; -using namespace Gtk; -using namespace ARDOUR; +const char* NewSessionDialogFactory::s_m_top_level_widget_name = X_("new_session_dialog"); -#include "i18n.h" -extern std::vector<string> channel_combo_strings; - -NewSessionDialog::NewSessionDialog (ARDOUR::AudioEngine& engine, bool startup, string given_path) - : ArdourDialog ("new session dialog"), - file_selector (_("Session name:"), _("Create")), - use_control_button (_("use control outs")), - use_master_button (_("use master outs")), - connect_to_physical_inputs_button (_("automatically connect track inputs to physical ports")), - connect_to_master_button (_("automatically connect track outputs to master outs")), - connect_to_physical_outputs_button (_("automatically connect track outputs to physical ports")), - manual_connect_outputs_button (_("manually connect track outputs")), - in_count_adjustment (2, 1, 1000, 1, 2), - out_count_adjustment (2, 1, 1000, 1, 2), - output_label (_("Output Connections")), - input_label (_("Input Connections")), - expansion_button (_("Advanced...")), - out_table (2, 2), - show_again (_("show again")), - in_count_spinner (in_count_adjustment), - out_count_spinner (out_count_adjustment), - in_count_label (_("Hardware Inputs: use")), - out_count_label (_("Hardware Outputs: use")) - +Glib::RefPtr<Gnome::Glade::Xml> +NewSessionDialogFactory::create() { - using namespace Notebook_Helpers; - - set_name ("NewSessionDialog"); - set_title (_("new session setup")); - set_wmclass (_("ardour_new_session"), "Ardour"); - set_position (Gtk::WIN_POS_MOUSE); - set_keyboard_input (true); - // GTK2FIX - // set_policy (false, true, false); - set_modal (true); - - /* sample rate */ - - sr_label1.set_text (string_compose - (_("This session will playback and record at %1 Hz"), - engine.frame_rate())); - sr_label2.set_text (_("This rate is set by JACK and cannot be changed.\n" - "If you want to use a different sample rate\n" - "please exit and restart JACK")); - sr_box.set_spacing (12); - sr_box.set_border_width (12); - sr_box.pack_start (sr_label1, false, false); - sr_box.pack_start (sr_label2, false, false); - sr_frame.add (sr_box); - - /* input */ - - connect_to_physical_inputs_button.set_active (true); - connect_to_physical_inputs_button.set_name ("NewSessionDialogButton"); - - HBox* input_limit_box = manage (new HBox); - input_limit_box->set_spacing (7); - input_limit_box->pack_start (in_count_label, false, false); - input_limit_box->pack_start (in_count_spinner, false, false); - - input_label.set_alignment (0.1, 0.5); - input_vbox.pack_start (input_label, false, false, 7); - input_vbox.pack_start (connect_to_physical_inputs_button, false, false); + return GladeFactory::create(GladePath::path(X_("new_session_dialog.glade"))); +} - if (engine.n_physical_inputs() > 2) { - input_vbox.pack_start (*input_limit_box, false, false); - } - /* output */ +NewSessionDialog::NewSessionDialog(BaseObjectType* cobject, + const Glib::RefPtr<Gnome::Glade::Xml>& xml) + : Gtk::Dialog(cobject) +{ + // look up the widgets we care about. - use_master_button.set_active (true); - use_master_button.set_name ("NewSessionDialogButton"); - - connect_to_physical_outputs_button.set_group (connect_to_master_button.get_group()); - manual_connect_outputs_button.set_group (connect_to_master_button.get_group()); - connect_to_master_button.set_active (true); + xml->get_widget(X_("SessionName"), m_name); + xml->get_widget(X_("SessionFolder"), m_folder); + xml->get_widget(X_("SessionTemplate"), m_template); - connect_to_physical_outputs_button.set_name ("NewSessionDialogButton"); - manual_connect_outputs_button.set_name ("NewSessionDialogButton"); - connect_to_master_button.set_name ("NewSessionDialogButton"); - use_control_button.set_name ("NewSessionDialogButton"); + xml->get_widget(X_("CreateMasterTrack"), m_create_master_track); + xml->get_widget(X_("MasterChannelCount"), m_master_track_channel_count); - out_count_adjustment.set_value (engine.n_physical_outputs()); - in_count_adjustment.set_value (engine.n_physical_inputs()); + xml->get_widget(X_("CreateControlTrack"), m_create_control_track); + xml->get_widget(X_("ControlChannelCount"), m_control_track_channel_count); - set_popdown_strings (control_out_channel_combo, channel_combo_strings); - control_out_channel_combo.set_name (X_("NewSessionChannelCombo")); - // use stereo as default - control_out_channel_combo.set_active_text (channel_combo_strings.front()); + xml->get_widget(X_("ConnectInputs"), m_connect_inputs); + xml->get_widget(X_("LimitInputPorts"), m_limit_input_ports); + xml->get_widget(X_("InputLimitCount"), m_input_limit_count); - set_popdown_strings (master_out_channel_combo, channel_combo_strings); - master_out_channel_combo.set_name (X_("NewSessionChannelCombo")); - // use stereo as default - master_out_channel_combo.set_active_text (channel_combo_strings.front()); + xml->get_widget(X_("ConnectOutputs"), m_connect_outputs); + xml->get_widget(X_("LimitOutputPorts"), m_limit_output_ports); + xml->get_widget(X_("OutputLimitCount"), m_output_limit_count); + xml->get_widget(X_("ConnectOutsToMaster"), m_connect_outputs_to_master); + xml->get_widget(X_("ConnectOutsToPhysical"), m_connect_outputs_to_physical); - - out_table.set_col_spacings (7); - out_table.set_row_spacings (7); - if (engine.n_physical_outputs() > 2) { - out_table.attach (out_count_label, 0, 1, 0, 1, 0, 0); - out_table.attach (out_count_spinner, 1, 2, 0, 1, 0, 0); - } - out_table.attach (use_control_button, 0, 1, 1, 2, 0, 0); - out_table.attach (control_out_channel_combo, 1, 2, 1, 2, 0, 0); - out_table.attach (use_master_button, 0, 1, 2, 3, 0, 0); - out_table.attach (master_out_channel_combo, 1, 2, 2, 3, 0, 0); - - output_label.set_alignment (0.1, 0.5); - output_vbox.pack_start (output_label, true, true, 7); - output_vbox.pack_start (out_table, false, false, 5); - output_vbox.pack_start (connect_to_master_button, false); - output_vbox.pack_start (connect_to_physical_outputs_button, false); - output_vbox.pack_start (manual_connect_outputs_button, false); - - input_hbox.pack_start (input_vbox, false, false); - output_hbox.pack_start (output_vbox, false, false); + ///@ todo connect some signals - VBox* template_vbox = manage (new VBox); - Label* template_label = manage (new Label (_("Session template"))); - - template_label->set_alignment (0.1, 0.5); - template_vbox->pack_start (*template_label, true, true, 7); - template_vbox->pack_start (template_combo, false, false); +} - io_box.set_border_width (12); - io_box.set_spacing (7); - io_box.pack_start (*template_vbox); +void +NewSessionDialog::set_session_name(const Glib::ustring& name) +{ + m_name->set_text(name); +} - io_box.pack_start (input_hbox); - io_box.pack_start (output_hbox); +std::string +NewSessionDialog::session_name() const +{ + return Glib::filename_from_utf8(m_name->get_text()); +} - reset_templates(); +std::string +NewSessionDialog::session_folder() const +{ + return Glib::filename_from_utf8(m_folder->get_current_folder()); +} - option_hbox.set_spacing (7); - option_hbox.pack_start (io_box); +bool +NewSessionDialog::use_session_template() const +{ + if(m_template->get_filename().empty()) return false; + return true; +} - fsbox.set_border_width (12); - fsbox.set_spacing (7); - fsbox.pack_start (file_selector.table, false, false); +std::string +NewSessionDialog::session_template_name() const +{ + return Glib::filename_from_utf8(m_template->get_filename()); +} - notebook.pages().push_back (TabElem (fsbox, _("Location"))); - notebook.pages().push_back (TabElem (option_hbox, _("Configuration"))); +bool +NewSessionDialog::create_master_track() const +{ + return m_create_master_track->get_active(); +} - if (startup) { - show_again.set_active(true); - show_again.toggled.connect (mem_fun(*this, &NewSessionDialog::show_again_toggled)); - file_selector.button_box.pack_end(show_again, false, false); - } +int +NewSessionDialog::master_channel_count() const +{ + return m_master_track_channel_count->get_value_as_int(); +} - main_vbox.set_border_width (12); - main_vbox.set_border_width (12); - main_vbox.set_spacing (7); - main_vbox.pack_start (sr_frame, false, false); - main_vbox.pack_start (notebook, false, false); - main_vbox.pack_start (file_selector.button_box, false, false); - - add (main_vbox); - -// template_selector.shift_made.connect ( -// mem_fun(*this, &NewSessionDialog::mix_template_shift)); -// template_selector.control_made.connect ( -// mem_fun(*this, &NewSessionDialog::mix_template_control)); - - file_selector.cancel_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), -1)); - file_selector.op_button.signal_clicked().connect (bind (mem_fun(*this, &ArdourDialog::stop), 0)); - file_selector.Expanded.connect (mem_fun(*this, &NewSessionDialog::file_selector_expansion)); - - delete_event.connect (mem_fun(*this, &ArdourDialog::wm_close_event)); - show.connect (mem_fun(*this, &NewSessionDialog::fixup_at_show)); - - file_selector.entry_label.set_name ("NewSessionMainLabel"); - file_selector.where_label.set_name ("NewSessionMainLabel"); - template_label->set_name ("NewSessionIOLabel"); - input_label.set_name ("NewSessionIOLabel"); - output_label.set_name ("NewSessionIOLabel"); - sr_label1.set_name ("NewSessionSR1Label"); - sr_label2.set_name ("NewSessionSR2Label"); - - if (given_path.empty()) { - Session::FavoriteDirs favs; - Session::read_favorite_dirs (favs); - file_selector.set_favorites (favs); - } else { - file_selector.set_path (given_path, true); - notebook.set_page (-1); - notebook.show.connect (bind (mem_fun (notebook, &Notebook::set_page), -1)); - } - - set_default_size(531, 358); +bool +NewSessionDialog::create_control_track() const +{ + return m_create_control_track->get_active(); } -void -NewSessionDialog::file_selector_expansion (bool expanded) +int +NewSessionDialog::control_channel_count() const { - if (expanded) { - fsbox.pack_start (file_selector.expansion_vbox); - fsbox.reorder_child (file_selector.expansion_vbox, 2); - } else { - fsbox.remove (file_selector.expansion_vbox); - } + return m_control_track_channel_count->get_value_as_int(); } -void -NewSessionDialog::fixup_at_show () +bool +NewSessionDialog::connect_inputs() const { -// if (template_selector.clist().rows().size() == 0) { -// use_template_button.set_sensitive (false); -// } + return m_connect_inputs->get_active(); +} - Session::FavoriteDirs favs; - Session::read_favorite_dirs (favs); - file_selector.set_favorites (favs); +bool +NewSessionDialog::limit_inputs_used_for_connection() const +{ + return m_limit_input_ports->get_active(); +} - file_selector.entry.grab_focus (); +int +NewSessionDialog::input_limit_count() const +{ + return m_input_limit_count->get_value_as_int(); } -void -NewSessionDialog::_mix_template_refiller (CList &clist, void *arg) +bool +NewSessionDialog::connect_outputs() const +{ + return m_connect_outputs->get_active(); +} +bool +NewSessionDialog::limit_outputs_used_for_connection() const { - ((NewSessionDialog*) arg)->mix_template_refiller (clist); + return m_limit_output_ports->get_active(); } -void -NewSessionDialog::mix_template_refiller (CList &clist) +int +NewSessionDialog::output_limit_count() const { - const gchar *rowdata[2]; - list<string> templates; - list<string>::iterator i; - - Session::get_template_list(templates); - - rowdata[0] = _("blank"); - clist.insert_row (0, rowdata); - - guint row; - for (row=1, i=templates.begin(); i != templates.end(); ++row, ++i) { - rowdata[0] = (*i).c_str(); - clist.insert_row (row, rowdata); - } + return m_output_limit_count->get_value_as_int(); } -void -NewSessionDialog::mix_template_shift (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res) +bool +NewSessionDialog::connect_outs_to_master() const { - if (res && res->text){ - Session::delete_template(*res->text); - // template_selector.rescan(); - } + return m_connect_outputs_to_master->get_active(); } -void -NewSessionDialog::mix_template_control (Gtkmm2ext::Selector* selector, Gtkmm2ext::SelectionResult* res) +bool +NewSessionDialog::connect_outs_to_physical() const { -#if 0 - if (res && res->text) { - ArdourPrompter prompter (true); - prompter.set_prompt(_("Name for mix template:")); - - string old_name = *(res->text); - prompter.set_initial_text (old_name); - prompter.done.connect (Gtk::Main::quit.slot()); - prompter.show_all(); - - Gtk::Main::run(); - - if (prompter.status == Gtkmm2ext::Prompter::entered) { - string name; - - prompter.get_result (name); - - if (name.length() && name != old_name) { - Session::rename_template(old_name, name); - template_selector.rescan(); - } - } - } -#endif + return m_connect_outputs_to_physical->get_active(); } + void -NewSessionDialog::show_again_toggled () +NewSessionDialog::reset_name() { - Config->set_no_new_session_dialog(!show_again.get_active()); - Config->save_state(); + m_name->set_text(Glib::ustring()); + } +/// @todo void -NewSessionDialog::reset_templates () +NewSessionDialog::reset_template() { - templates.clear (); - templates.push_back (_("No template - create tracks/busses manually")); - Session::get_template_list (templates); - set_popdown_strings (template_combo, templates); + } -string -NewSessionDialog::get_template_name() +void +NewSessionDialog::reset() { - string str = template_combo.get_entry()->get_text(); - if (str.substr (0, 11) == _("No template")) { - return ""; - } else { - return str; - } + reset_name(); + reset_template(); } |