diff --git a/gtk2_ardour/marker_io_dialog.cc b/gtk2_ardour/marker_io_dialog.cc new file mode 100644 index 0000000000..e632d37e92 --- /dev/null +++ b/gtk2_ardour/marker_io_dialog.cc @@ -0,0 +1,119 @@ +/* + Copyright (C) 2014 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 "ardour/session.h" +#include "ardour/midi_port.h" + +#include "ardour_ui.h" +#include "marker_io_dialog.h" +#include "midi_port_dropdown.h" + +#include "i18n.h" + +MarkerIODialog::MarkerIODialog () + : WavesDialog ("marker_io_dialog.xml", true, false) + , input_dropdown (get_waves_dropdown ("input_dropdown")) + , output_dropdown (get_waves_dropdown ("output_dropdown")) +{ + populate_dropdown (input_dropdown, false); + populate_dropdown (output_dropdown, true); + + input_dropdown.signal_menu_item_clicked.connect (sigc::mem_fun (*this, &MarkerIODialog::output_chosen)); + output_dropdown.signal_menu_item_clicked.connect (sigc::mem_fun (*this, &MarkerIODialog::output_chosen)); +} + +void +MarkerIODialog::on_realize () +{ + WavesDialog::on_realize (); + /* remove all borders, buttons, titles, etc */ + get_window()->set_decorations (Gdk::WMDecoration (0)); +} + +void +MarkerIODialog::output_chosen (WavesDropdown*, void* full_name_of_chosen_port) +{ + if (!_session) { + return; + } + _session->scene_out()->disconnect_all (); + + if (full_name_of_chosen_port != 0) { + _session->scene_out()->connect ((char *) full_name_of_chosen_port); + } + + hide (); +} + +void +MarkerIODialog::input_chosen (WavesDropdown*, void* full_name_of_chosen_port) +{ + if (!_session) { + return; + } + _session->scene_in()->disconnect_all (); + + if (full_name_of_chosen_port != 0) { + _session->scene_in()->connect ((char*) full_name_of_chosen_port); + } + + hide (); +} + +void +MarkerIODialog::populate_dropdown (WavesDropdown& dropdown, bool for_playback) +{ + using namespace ARDOUR; + + std::vector midi_states; + static const char* midi_port_name_prefix = "system_midi:"; + const char* midi_type_suffix; + bool have_first = false; + + if (for_playback) { + EngineStateController::instance()->get_physical_midi_output_states(midi_states); + midi_type_suffix = X_(" playback"); + } else { + EngineStateController::instance()->get_physical_midi_input_states(midi_states); + midi_type_suffix = X_(" capture"); + } + + dropdown.clear_items (); + + std::vector::const_iterator state_iter; + + for (state_iter = midi_states.begin(); state_iter != midi_states.end(); ++state_iter) { + + // strip the device name from input port name + + std::string device_name; + + ARDOUR::remove_pattern_from_string(state_iter->name, midi_port_name_prefix, device_name); + ARDOUR::remove_pattern_from_string(device_name, midi_type_suffix, device_name); + + if (state_iter->active) { + dropdown.add_menu_item (device_name, strdup (state_iter->name.c_str())); + if (!have_first) { + std::cerr << "set text using full name: " << state_iter->name << " device " << device_name << " active " << state_iter->active << "\n"; + dropdown.set_text (device_name); + have_first = true; + } + } + } +} + diff --git a/gtk2_ardour/marker_io_dialog.h b/gtk2_ardour/marker_io_dialog.h new file mode 100644 index 0000000000..478929c25d --- /dev/null +++ b/gtk2_ardour/marker_io_dialog.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2014 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 +#include + +#include "ardour/engine_state_controller.h" +#include "ardour/utils.h" + +#include "waves_dialog.h" + +class MidiPortDropdown; +class WavesDropdown; + +class MarkerIODialog : public WavesDialog +{ + public: + MarkerIODialog (); + + private: + WavesDropdown& input_dropdown; + WavesDropdown& output_dropdown; + + void populate_dropdown (WavesDropdown& dropdown, bool for_playback); + + void input_chosen (WavesDropdown*,void*); + void output_chosen (WavesDropdown*,void*); + void on_realize (); +}; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 2237a2723f..b101ef17b8 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -136,6 +136,7 @@ gtk2_ardour_sources = [ 'main.cc', 'main_clock.cc', 'marker.cc', + 'marker_io_dialog.cc', 'midi_automation_line.cc', 'midi_channel_dialog.cc', 'midi_channel_selector.cc', @@ -143,6 +144,7 @@ gtk2_ardour_sources = [ 'midi_export_dialog.cc', 'midi_list_editor.cc', 'midi_port_dialog.cc', + 'midi_port_dropdown.cc', 'midi_region_view.cc', 'midi_scroomer.cc', 'midi_selection.cc',