diff options
author | David Robillard <d@drobilla.net> | 2013-01-19 20:15:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-01-19 20:15:15 +0000 |
commit | 444d89b669145beed314b8a7cf5755b5cda0b820 (patch) | |
tree | 8e525924f07aefc16732a90a740f06acf83b1b24 /gtk2_ardour/midi_time_axis.cc | |
parent | 2d9a15087bad6dfaeedd259b2fe948627d3b5ffb (diff) |
Set MIDI device mode to the first by default if unset.
Give up trying to hide mode selector when it's useless.
Fix display of program names for default mode.
Abstract out (non-crashy) MidiTimeAxisView::get_device_names().
git-svn-id: svn://localhost/ardour2/branches/3.0@13903 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_time_axis.cc')
-rw-r--r-- | gtk2_ardour/midi_time_axis.cc | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/gtk2_ardour/midi_time_axis.cc b/gtk2_ardour/midi_time_axis.cc index 973bbb77e5..b9162cfe2b 100644 --- a/gtk2_ardour/midi_time_axis.cc +++ b/gtk2_ardour/midi_time_axis.cc @@ -231,6 +231,15 @@ MidiTimeAxisView::set_route (boost::shared_ptr<Route> rt) set_gui_property (X_("midnam-model-name"), "Generic"); } + if (gui_property (X_("midnam-custom-device-mode")).empty()) { + boost::shared_ptr<MIDI::Name::MasterDeviceNames> device_names = get_device_names( + gui_property (X_("midnam-model-name"))); + if (device_names) { + set_gui_property (X_("midnam-custom-device-mode"), + *device_names->custom_device_mode_names().begin()); + } + } + _midnam_model_selector.set_active_text (gui_property (X_("midnam-model-name"))); _midnam_custom_device_mode_selector.set_active_text (gui_property (X_("midnam-custom-device-mode"))); @@ -373,14 +382,9 @@ MidiTimeAxisView::model_changed() _midnam_custom_device_mode_selector.clear_items(); - if (device_modes.size() < 2) { - _midnam_custom_device_mode_selector.hide(); - } else { - _midnam_custom_device_mode_selector.show(); - for (std::list<std::string>::const_iterator i = device_modes.begin(); - i != device_modes.end(); ++i) { - _midnam_custom_device_mode_selector.append_text(*i); - } + for (std::list<std::string>::const_iterator i = device_modes.begin(); + i != device_modes.end(); ++i) { + _midnam_custom_device_mode_selector.append_text(*i); } _midnam_custom_device_mode_selector.set_active(0); @@ -756,6 +760,19 @@ MidiTimeAxisView::add_multi_channel_controller_item(Menu_Helpers::MenuList& ctl_ dynamic_cast<Label*> (ctl_items.back().get_child())->set_use_markup (true); } +boost::shared_ptr<MIDI::Name::MasterDeviceNames> +MidiTimeAxisView::get_device_names(const std::string& model) +{ + using namespace MIDI::Name; + boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance() + .document_by_model(model); + if (midnam) { + return midnam->master_device_names(model); + } else { + return boost::shared_ptr<MasterDeviceNames>(); + } +} + void MidiTimeAxisView::build_controller_menu () { @@ -790,15 +807,9 @@ MidiTimeAxisView::build_controller_menu () } using namespace MIDI::Name; - const Glib::ustring model = _midnam_model_selector.get_active_text(); - boost::shared_ptr<MIDINameDocument> midnam = MidiPatchManager::instance() - .document_by_model(model); - boost::shared_ptr<MasterDeviceNames> device_names; + boost::shared_ptr<MasterDeviceNames> device_names = get_device_names( + _midnam_model_selector.get_active_text()); - if (midnam) { - device_names = midnam->master_device_names(model); - } - if (device_names && !device_names->controls().empty()) { /* Controllers names available in midnam file, generate fancy menu */ unsigned n_items = 0; |