set Theme buttons on state reset
authorRobin Gareus <robin@gareus.org>
Wed, 21 Jan 2015 19:24:39 +0000 (20:24 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 21 Jan 2015 19:24:39 +0000 (20:24 +0100)
cleaner version of last commit, set GUI elements
on state-reset.

gtk2_ardour/theme_manager.cc
gtk2_ardour/theme_manager.h

index dfff1c1f15d6170a7d8a985d83fac34a593ab243..44389da71197405d5039daaa068e3ffe06cf818b 100644 (file)
@@ -170,12 +170,7 @@ ThemeManager::ThemeManager()
        color_dialog.get_colorsel()->set_has_opacity_control (true);
        color_dialog.get_colorsel()->set_has_palette (true);
        
-       flat_buttons.set_active (ARDOUR_UI::config()->get_flat_buttons());
-       blink_rec_button.set_active (ARDOUR_UI::config()->get_blink_rec_arm());
-       region_color_button.set_active (ARDOUR_UI::config()->get_color_regions_using_track_color());
-       show_clipping_button.set_active (ARDOUR_UI::config()->get_show_waveform_clipping());
-       waveform_gradient_depth.set_value(ARDOUR_UI::config()->get_waveform_gradient_depth());
-       timeline_item_gradient_depth.set_value(ARDOUR_UI::config()->get_timeline_item_gradient_depth());
+       set_ui_to_state();
 
        color_dialog.get_ok_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (color_dialog, &Gtk::Dialog::response), RESPONSE_ACCEPT));
        color_dialog.get_cancel_button()->signal_clicked().connect (sigc::bind (sigc::mem_fun (color_dialog, &Gtk::Dialog::response), RESPONSE_CANCEL));
@@ -346,11 +341,37 @@ ThemeManager::on_light_theme_button_toggled()
         uic->set_color_file("light");
 }
 
+void
+ThemeManager::set_ui_to_state()
+{
+       /* there is no way these values can change individually
+        * by themselves (w/o user-interaction)
+        * hence a common combined update function suffices
+        */
+
+       if (ARDOUR_UI::config()->get_color_file() == "light") {
+               light_button.set_active(true);
+       } else {
+               dark_button.set_active(true);
+       }
+
+       /* there is no need to block signal handlers, here,
+        * all elements check if the value has changed and ignore NOOPs 
+        */
+       flat_buttons.set_active (ARDOUR_UI::config()->get_flat_buttons());
+       blink_rec_button.set_active (ARDOUR_UI::config()->get_blink_rec_arm());
+       region_color_button.set_active (ARDOUR_UI::config()->get_color_regions_using_track_color());
+       show_clipping_button.set_active (ARDOUR_UI::config()->get_show_waveform_clipping());
+       waveform_gradient_depth.set_value(ARDOUR_UI::config()->get_waveform_gradient_depth());
+       timeline_item_gradient_depth.set_value(ARDOUR_UI::config()->get_timeline_item_gradient_depth());
+}
+
 void
 ThemeManager::reset_canvas_colors()
 {
        ARDOUR_UI::config()->load_defaults();
        ARDOUR_UI::config()->save_state ();
+       set_ui_to_state();
 }
 
 ArdourCanvas::Container*
index 3180240c222633dc3a33bf049ca10360dd8b2e03..6a5f5db79b229998b4fdc22f48cff2fb404f2025 100644 (file)
@@ -168,6 +168,7 @@ class ThemeManager : public Gtk::VBox
        void modifier_edited (Gtk::Range*, std::string);
        
        void colors_changed ();
+       void set_ui_to_state ();
 };
 
 #endif /* __ardour_gtk_color_manager_h__ */