always save/keep audio/MIDI setup states so that they are available for use *after...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 5 Sep 2013 18:21:25 +0000 (14:21 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 5 Sep 2013 18:21:25 +0000 (14:21 -0400)
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/engine_dialog.cc
gtk2_ardour/engine_dialog.h
gtk2_ardour/startup.cc
gtk2_ardour/startup.h

index 9eae8b42684f02cb7ac4e8358d7cfc02d2709679..b7d6459ae2b1092d240504af03d80dc7abcd1ca9 100644 (file)
@@ -214,6 +214,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
        }
 
        ui_config = new UIConfiguration();
+       _audio_midi_setup = new EngineControl;
 
        editor = 0;
        mixer = 0;
@@ -4145,3 +4146,19 @@ ARDOUR_UI::reset_route_peak_display (Route* route)
                reset_peak_display ();
        }
 }
+
+EngineControl*
+ARDOUR_UI::audio_midi_setup_widget ()
+{
+       /* remove widget from any existing parent, since it is about
+          to be packed somewhere else.
+       */
+       
+       Gtk::Container* parent = _audio_midi_setup->get_parent ();
+
+       if (parent) {
+               parent->remove (*_audio_midi_setup);
+       }
+
+       return _audio_midi_setup;
+}
index f8b47bd3e8fb1fed9c79ef2a8fe7ae7b6b3537b0..6be0d39848656f30515d3e2041e1fb13a4954484 100644 (file)
@@ -90,6 +90,7 @@ class BigClockWindow;
 class BundleManager;
 class ButtonJoiner;
 class ConnectionEditor;
+class EngineControl;
 class KeyEditor;
 class LocationUIWindow;
 class MainClock;
@@ -288,6 +289,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
 
         const std::string& announce_string() const { return _announce_string; }
 
+        EngineControl* audio_midi_setup_widget();
+
   protected:
        friend class PublicEditor;
 
@@ -748,6 +751,8 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
 
         std::string _announce_string;
         void check_announcements ();
+
+        EngineControl* _audio_midi_setup;
 };
 
 #endif /* __ardour_gui_h__ */
index c30627fdecd1790a39562e8f5e71d29b3dc8d97c..002b7dd3ed2a3d783739a47f42dfdf50d3cdf3d9 100644 (file)
@@ -647,11 +647,10 @@ ARDOUR_UI::save_ardour_state ()
        window_node->add_child_nocopy (*tearoff_node);
 
        Config->add_extra_xml (*window_node);
+       Config->add_extra_xml (_audio_midi_setup->get_state());
 
-       if (_startup && _startup->engine_control() && _startup->engine_control()->was_used()) {
-               Config->add_extra_xml (_startup->engine_control()->get_state());
-       }
        Config->save_state();
+
        if (ui_config->dirty()) {
                ui_config->save_state ();
        }
index c50198a9601f760cd0148b8adc6858a2717c24d0..7a543306e68bdf2ed0770df8a34c3579b0032803 100644 (file)
@@ -68,7 +68,6 @@ EngineControl::EngineControl ()
 #else
        , basic_packer (9, 2)
 #endif
-       , _used (false)
 {
        using namespace Notebook_Helpers;
        Label* label;
@@ -471,31 +470,28 @@ EngineControl::get_state ()
        XMLNode* root = new XMLNode ("AudioMIDISetup");
        std::string path;
 
-       if (_used) {
-
-               if (!states.empty()) {
-                       XMLNode* state_nodes = new XMLNode ("EngineStates");
+       if (!states.empty()) {
+               XMLNode* state_nodes = new XMLNode ("EngineStates");
+               
+               for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
                        
-                       for (StateList::const_iterator i = states.begin(); i != states.end(); ++i) {
-
-                               XMLNode* node = new XMLNode ("State");
-
-                               node->add_property ("backend", (*i).backend);
-                               node->add_property ("driver", (*i).driver);
-                               node->add_property ("device", (*i).device);
-                               node->add_property ("sample-rate", (*i).sample_rate);
-                               node->add_property ("buffer-size", (*i).buffer_size);
-                               node->add_property ("input-latency", (*i).input_latency);
-                               node->add_property ("output-latency", (*i).output_latency);
-                               node->add_property ("input-channels", (*i).input_channels);
-                               node->add_property ("output-channels", (*i).output_channels);
-                               node->add_property ("active", (*i).active ? "yes" : "no");
-       
-                               state_nodes->add_child_nocopy (*node);
-                       }
-
-                       root->add_child_nocopy (*state_nodes);
+                       XMLNode* node = new XMLNode ("State");
+                       
+                       node->add_property ("backend", (*i).backend);
+                       node->add_property ("driver", (*i).driver);
+                       node->add_property ("device", (*i).device);
+                       node->add_property ("sample-rate", (*i).sample_rate);
+                       node->add_property ("buffer-size", (*i).buffer_size);
+                       node->add_property ("input-latency", (*i).input_latency);
+                       node->add_property ("output-latency", (*i).output_latency);
+                       node->add_property ("input-channels", (*i).input_channels);
+                       node->add_property ("output-channels", (*i).output_channels);
+                       node->add_property ("active", (*i).active ? "yes" : "no");
+                       
+                       state_nodes->add_child_nocopy (*node);
                }
+               
+               root->add_child_nocopy (*state_nodes);
        }
 
        return *root;
@@ -518,6 +514,7 @@ EngineControl::set_state (const XMLNode& root)
 
        states.clear ();
 
+
        for (citer = clist.begin(); citer != clist.end(); ++citer) {
 
                child = *citer;
@@ -653,13 +650,6 @@ EngineControl::setup_engine (bool start)
                        return -1;
                }
 
-               /* we've used this dialog to configure the engine, which means
-                * that our state becomes relevant for saving (and thus
-                * implicitly, restoring.
-                */
-
-               _used = true;
-
                /* get a pointer to the current state object, creating one if
                 * necessary
                 */
index 3ee7a388bcc3d0be0830bb09828b5d91fe5de606..7c9c652f57d5caeb09c69537f8b5866ac06f5dbb 100644 (file)
@@ -41,7 +41,6 @@ class EngineControl : public Gtk::VBox {
        static bool need_setup ();
        int setup_engine (bool start);
 
-       bool was_used() const { return _used; }
        XMLNode& get_state ();
        void set_state (const XMLNode&);
 
@@ -96,8 +95,6 @@ class EngineControl : public Gtk::VBox {
     sigc::connection sr_connection;
     sigc::connection bs_connection;
     
-    bool _used;
-    
     static bool engine_running ();
     
     void driver_changed ();
index 2e6fe49e98e6163f4c050dd9376ef6046ac4f0b5..d776e3c36f25a026e8d5448d1ddc10810d53c193 100644 (file)
@@ -314,7 +314,7 @@ ArdourStartup::session_folder ()
 void
 ArdourStartup::setup_audio_page ()
 {
-       engine_dialog = manage (new EngineControl);
+       engine_dialog = ARDOUR_UI::instance()->audio_midi_setup_widget ();
 
        engine_dialog->set_border_width (12);
 
index 4af6ffbc2ac28d5a91594f0cb645439289f3c0ea..5a95994c4e6b5d543f120e025d23e222d27da6a6 100644 (file)
@@ -56,8 +56,6 @@ class ArdourStartup : public Gtk::Assistant {
        bool use_session_template();
        std::string session_template_name();
 
-       EngineControl* engine_control() { return engine_dialog; }
-
        // advanced session options
 
        bool create_master_bus() const;