- smod = "duplex";
- }
-
-
- XMLNode node (X_("MIDI-port"));
-
- node.add_property ("tag", dialog.port_name.get_text());
- node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
- node.add_property ("type", MIDI::PortFactory::default_port_type());
- node.add_property ("mode", smod);
-
- if (MIDI::Manager::instance()->add_port (node) != 0) {
- redisplay_midi_ports ();
- }
-}
-
-bool
-OptionEditor::port_removable (MIDI::Port *port)
-{
- if (!session) {
- return true;
- }
-
- if (port == session->mtc_port() ||
- port == session->mmc_port() ||
- port == session->midi_port()) {
- return false;
- }
- return true;
-}
-
-void
-OptionEditor::mtc_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
-{
- if (session) {
- if (rb->get_active()) {
- session->set_mtc_port (port->name());
- Config->set_mtc_port_name (port->name());
- } else {
- session->set_mtc_port ("");
- }
- bb->set_sensitive (port_removable (port));
- }
-}
-
-void
-OptionEditor::mmc_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
-{
- if (session) {
- if (rb->get_active()) {
- session->set_mmc_port (port->name());
- Config->set_mtc_port_name (port->name());
- } else {
- session->set_mmc_port ("");
- }
- bb->set_sensitive (port_removable (port));
- }
-}
-
-void
-OptionEditor::midi_port_chosen (MIDI::Port* port, Gtk::RadioButton* rb, Gtk::Button* bb)
-{
- if (session) {
- if (rb->get_active()) {
- session->set_midi_port (port->name());
- Config->set_midi_port_name (port->name());
- } else {
- session->set_midi_port ("");
- }
- bb->set_sensitive (port_removable (port));
- }
-}
-
-void
-OptionEditor::midi_clock_port_chosen (MIDI::Port *port, Gtk::RadioButton* rb, Gtk::Button* bb)
-{
- if (session) {
- if (rb->get_active()) {
- session->set_midi_clock_port (port->name());
- Config->set_midi_clock_port_name (port->name());
- } else {
- session->set_midi_clock_port ("");
- }
- bb->set_sensitive (port_removable (port));
- }
-}
-
-void
-OptionEditor::port_online_toggled (MIDI::Port* port, ToggleButton* tb)
-{
- bool wanted = tb->get_active();
-
- if (port->input()) {
- if (wanted != port->input()->offline()) {
- port->input()->set_offline (wanted);
- }
- }
-}
-
-void
-OptionEditor::map_port_online (MIDI::Port* port, ToggleButton* tb)
-{
- bool bstate = tb->get_active ();
-
- if (port->input()) {
- if (bstate != port->input()->offline()) {
- if (port->input()->offline()) {
- tb->set_label (_("offline"));
- tb->set_active (false);
- } else {
- tb->set_label (_("online"));
- tb->set_active (true);
- }
- }
- }
-}
-
-void
-OptionEditor::mmc_receive_device_id_adjusted ()
-{
- uint8_t id = (uint8_t) mmc_receive_device_id_spinner.get_value();
- Config->set_mmc_receive_device_id (id);
-}
-
-void
-OptionEditor::mmc_send_device_id_adjusted ()
-{
- uint8_t id = (uint8_t) mmc_send_device_id_spinner.get_value();
- Config->set_mmc_send_device_id (id);
-}
-
-void
-OptionEditor::port_trace_in_toggled (MIDI::Port* port, ToggleButton* tb)
-{
- bool trace = tb->get_active();
-
- if (port->input()) {
- if (port->input()->tracing() != trace) {
- port->input()->trace (trace, &cerr, string (port->name()) + string (" input: "));
- }
- }
-}
-
-void
-OptionEditor::port_trace_out_toggled (MIDI::Port* port, ToggleButton* tb)
-{
- bool trace = tb->get_active();
-
- if (port->output()) {
- if (port->output()->tracing() != trace) {
- port->output()->trace (trace, &cerr, string (port->name()) + string (" output: "));
- }
- }
-}
-
-void
-OptionEditor::save ()
-{
- /* XXX a bit odd that we save the entire session state here */
-
- ui.save_state ("");
-}
-
-gint
-OptionEditor::wm_close (GdkEventAny *ev)
-{
- save ();
- hide ();
- return TRUE;
-}
-
-void
-OptionEditor::raid_path_changed ()
-{
- if (session) {
- Config->set_raid_path (session_raid_entry.get_text());
- }
-}
-
-void
-OptionEditor::click_browse_clicked ()
-{
- SoundFileChooser sfdb (*this, _("Choose Click"), session);
-
- sfdb.show_all ();
- sfdb.present ();
-
- int result = sfdb.run ();
-
- if (result == Gtk::RESPONSE_OK) {
- click_chosen(sfdb.get_filename());
- }
-}
-
-void
-OptionEditor::click_chosen (const string & path)
-{
- click_path_entry.set_text (path);
- click_sound_changed ();
-}
-
-void
-OptionEditor::click_emphasis_browse_clicked ()
-{
- SoundFileChooser sfdb (*this, _("Choose Click Emphasis"), session);
-
- sfdb.show_all ();
- sfdb.present ();
-
- int result = sfdb.run ();
-
- if (result == Gtk::RESPONSE_OK) {
- click_emphasis_chosen (sfdb.get_filename());
- }
-}
-
-void
-OptionEditor::click_emphasis_chosen (const string & path)
-{
- click_emphasis_path_entry.set_text (path);
- click_emphasis_sound_changed ();
-}
-
-void
-OptionEditor::click_sound_changed ()
-{
- if (session) {
- string path = click_path_entry.get_text();
-
- if (path == Config->get_click_sound()) {
- return;
- }
-
- strip_whitespace_edges (path);
-
- if (path == _("internal")) {
- Config->set_click_sound ("");
- } else {
- Config->set_click_sound (path);
- }
- }
-}
-
-void
-OptionEditor::click_emphasis_sound_changed ()
-{
- if (session) {
- string path = click_emphasis_path_entry.get_text();
-
- if (path == Config->get_click_emphasis_sound()) {
- return;
- }
-
- strip_whitespace_edges (path);
-
- if (path == _("internal")) {
- Config->set_click_emphasis_sound ("");
- } else {
- Config->set_click_emphasis_sound (path);
- }
- }
-}
-
-void
-OptionEditor::clear_click_editor ()
-{
- if (click_io_selector) {
- click_hpacker.remove (*click_io_selector);
- click_hpacker.remove (*click_gpm);
- delete click_io_selector;
- delete click_gpm;
- click_io_selector = 0;
- click_gpm = 0;
- }
-}
-
-void
-OptionEditor::setup_click_editor ()
-{
- Label* label;
-
- if (first_click_setup) {
-
- click_path_entry.set_name ("OptionsEntry");
- click_emphasis_path_entry.set_name ("OptionsEntry");
-
- click_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_sound_changed));
- click_emphasis_path_entry.signal_activate().connect (mem_fun(*this, &OptionEditor::click_emphasis_sound_changed));
-
- click_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_sound_changed));
- click_emphasis_path_entry.signal_focus_out_event().connect (bind (mem_fun(*this, &OptionEditor::focus_out_event_handler), &OptionEditor::click_emphasis_sound_changed));
-
- click_browse_button.set_name ("EditorGTKButton");
- click_emphasis_browse_button.set_name ("EditorGTKButton");
-
- click_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_browse_clicked));
- click_emphasis_browse_button.signal_clicked().connect (mem_fun(*this, &OptionEditor::click_emphasis_browse_clicked));
-
- click_packer.set_border_width (12);
- click_packer.set_spacing (5);
-
- click_table.set_col_spacings (10);
-
- label = manage(new Label(_("Click audio file")));
- label->set_name ("OptionsLabel");
- click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
- click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
- click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
-
- label = manage(new Label(_("Click emphasis audiofile")));
- label->set_name ("OptionsLabel");
- click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
- click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
- click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
-
- click_packer.pack_start (click_table, false, false);
- click_packer.pack_start (click_hpacker, false, false);
-
-
- click_hpacker.set_spacing (10);
-
- first_click_setup = false;
- }
-
- click_path_entry.set_sensitive (true);
- click_emphasis_path_entry.set_sensitive (true);
-
- click_io_selector = new IOSelector (*session, session->click_io(), false);
- click_gpm = new GainMeter (*session);
- click_gpm->set_io (session->click_io());
-
- click_hpacker.pack_start (*click_io_selector, false, false);
- click_hpacker.pack_start (*click_gpm, false, false);
-
- click_table.set_col_spacings (10);
-
- label = manage(new Label(_("Click audio file")));
- label->set_name ("OptionsLabel");
- click_table.attach (*label, 0, 1, 0, 1, FILL|EXPAND, FILL);
- click_table.attach (click_path_entry, 1, 2, 0, 1, Gtk::FILL|Gtk::EXPAND, FILL);
- click_table.attach (click_browse_button, 2, 3, 0, 1, FILL|EXPAND, FILL);
-
- label = manage(new Label(_("Click emphasis audiofile")));
- label->set_name ("OptionsLabel");
- click_table.attach (*label, 0, 1, 1, 2, FILL|EXPAND, FILL);
- click_table.attach (click_emphasis_path_entry, 1, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, FILL);
- click_table.attach (click_emphasis_browse_button, 2, 3, 1, 2, FILL|EXPAND, FILL);
-
- click_packer.show_all ();
-}
-
-void
-OptionEditor::clear_auditioner_editor ()
-{
- if (auditioner_io_selector) {
- audition_hpacker.remove (*auditioner_io_selector);
- audition_hpacker.remove (*auditioner_gpm);
- delete auditioner_io_selector;
- delete auditioner_gpm;
- auditioner_io_selector = 0;
- auditioner_gpm = 0;