From 7dd51f6fb38095ae3c349a26c3f3a9d4fe80f5c2 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 21 Mar 2015 19:31:02 +0100 Subject: [PATCH] properly apply default state Actions that also have a private editor variable need to be applied regardless of XML state. --- gtk2_ardour/editor.cc | 57 +++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index c0d96c6890..a6d36ee799 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -2321,37 +2321,16 @@ Editor::set_state (const XMLNode& node, int /*version*/) if ((prop = node.property ("show-measures"))) { bool yn = string_is_affirmative (prop->value()); _show_measures = yn; - RefPtr act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility")); - if (act) { - RefPtr tact = RefPtr::cast_dynamic(act); - /* do it twice to force the change */ - tact->set_active (!yn); - tact->set_active (yn); - } } if ((prop = node.property ("follow-playhead"))) { bool yn = string_is_affirmative (prop->value()); set_follow_playhead (yn); - RefPtr act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead")); - if (act) { - RefPtr tact = RefPtr::cast_dynamic(act); - if (tact->get_active() != yn) { - tact->set_active (yn); - } - } } if ((prop = node.property ("stationary-playhead"))) { bool yn = string_is_affirmative (prop->value()); set_stationary_playhead (yn); - RefPtr act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead")); - if (act) { - RefPtr tact = RefPtr::cast_dynamic(act); - if (tact->get_active() != yn) { - tact->set_active (yn); - } - } } if ((prop = node.property ("region-list-sort-type"))) { @@ -2427,6 +2406,42 @@ Editor::set_state (const XMLNode& node, int /*version*/) nudge_clock->set (_session->frame_rate() * 5, true); } + { + /* apply state + * Not all properties may have been in XML, but + * those that are linked to a private variable may need changing + */ + RefPtr act; + bool yn; + + act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility")); + if (act) { + yn = _show_measures; + RefPtr tact = RefPtr::cast_dynamic(act); + /* do it twice to force the change */ + tact->set_active (!yn); + tact->set_active (yn); + } + + act = ActionManager::get_action (X_("Editor"), X_("toggle-follow-playhead")); + yn = _follow_playhead; + if (act) { + RefPtr tact = RefPtr::cast_dynamic(act); + if (tact->get_active() != yn) { + tact->set_active (yn); + } + } + + act = ActionManager::get_action (X_("Editor"), X_("toggle-stationary-playhead")); + yn = _stationary_playhead; + if (act) { + RefPtr tact = RefPtr::cast_dynamic(act); + if (tact->get_active() != yn) { + tact->set_active (yn); + } + } + } + return 0; }