From f428cb4bf163f0463dc0a4c321126c257da68dfa Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Sun, 9 Aug 2015 09:39:01 +1000 Subject: Refactor part of EngineControl::set_state into new set_current_state method --- gtk2_ardour/engine_dialog.cc | 52 ++++++++++++++++++++++++-------------------- gtk2_ardour/engine_dialog.h | 2 ++ 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/gtk2_ardour/engine_dialog.cc b/gtk2_ardour/engine_dialog.cc index 27f46456fc..9a9d4e9203 100644 --- a/gtk2_ardour/engine_dialog.cc +++ b/gtk2_ardour/engine_dialog.cc @@ -1704,34 +1704,40 @@ EngineControl::set_state (const XMLNode& root) for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) { if ((*i)->active) { - PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); - backend_combo.set_active_text ((*i)->backend); - - /* The driver popdown strings need to be populated now so that - * set_active_text will actually set a valid entry. Then - * backend_changed() will populate all the other combo's so they - * can also be set to valid entries and the state will be restored - * correctly. - */ - if (!(*i)->driver.empty()) { - set_driver_popdown_strings (); - } - driver_combo.set_active_text ((*i)->driver); - backend_changed (); - - device_combo.set_active_text ((*i)->device); - input_device_combo.set_active_text ((*i)->input_device); - output_device_combo.set_active_text ((*i)->output_device); - sample_rate_combo.set_active_text (rate_as_string ((*i)->sample_rate)); - set_active_text_if_present (buffer_size_combo, bufsize_as_string ((*i)->buffer_size)); - input_latency.set_value ((*i)->input_latency); - output_latency.set_value ((*i)->output_latency); - midi_option_combo.set_active_text ((*i)->midi_option); + set_current_state (*i); break; } } } +void +EngineControl::set_current_state (const State& state) +{ + PBD::Unwinder protect_ignore_changes (ignore_changes, ignore_changes + 1); + backend_combo.set_active_text (state->backend); + + /* The driver popdown strings need to be populated now so that + * set_active_text will actually set a valid entry. Then + * backend_changed() will populate all the other combo's so they + * can also be set to valid entries and the state will be restored + * correctly. + */ + if (!state->driver.empty()) { + set_driver_popdown_strings (); + } + driver_combo.set_active_text (state->driver); + backend_changed (); + + device_combo.set_active_text (state->device); + input_device_combo.set_active_text (state->input_device); + output_device_combo.set_active_text (state->output_device); + sample_rate_combo.set_active_text (rate_as_string (state->sample_rate)); + set_active_text_if_present (buffer_size_combo, bufsize_as_string (state->buffer_size)); + input_latency.set_value (state->input_latency); + output_latency.set_value (state->output_latency); + midi_option_combo.set_active_text (state->midi_option); +} + int EngineControl::push_state_to_backend (bool start) { diff --git a/gtk2_ardour/engine_dialog.h b/gtk2_ardour/engine_dialog.h index 7973ab9633..1921f8bbde 100644 --- a/gtk2_ardour/engine_dialog.h +++ b/gtk2_ardour/engine_dialog.h @@ -235,6 +235,8 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList { void store_state (State); bool equivalent_states (const State&, const State&); + void set_current_state (const State& state); + bool _have_control; static bool print_channel_count (Gtk::SpinButton*); -- cgit v1.2.3