do not pass a non-zero offset to plugins AFTER the first call to connect_and_run...
[ardour.git] / gtk2_ardour / ui_config.cc
index b4524f9cc6b8a9d9af555861c690da98d53bc518..ce9fbce172c2a52e67630a59d25a0b6c19ff1346 100644 (file)
@@ -20,6 +20,8 @@
 #include <unistd.h>
 #include <cstdio> /* for snprintf, grrr */
 
+#include <glibmm/miscutils.h>
+
 #include <pbd/failed_constructor.h>
 #include <pbd/xml++.h>
 #include <pbd/error.h>
@@ -54,16 +56,28 @@ UIConfiguration::~UIConfiguration ()
 }
 
 int
-UIConfiguration::load_state ()
+UIConfiguration::load_defaults ()
 {
-       bool found = false;
+       int found = 0;
+       std::string rcfile;
+       const char* ui_conf;
+
+       ui_conf = getenv ("ARDOUR_UI_CONF");
+
+       if (ui_conf && ui_conf[0] != '\0') {
+               rcfile = find_config_file (ui_conf);
+       } else {
+               if (getenv ("ARDOUR_SAE")) {
+                       rcfile = find_config_file ("ardour2_ui_sae.conf");
+               } else {
+                       rcfile = find_config_file ("ardour2_ui_default.conf");
+               }
+       }
+
+       if (rcfile.length()) {
 
-       std::string rcfile = find_config_file ("ardour2_ui_default.conf");
-       
-       if (rcfile.length())
-       {
                XMLTree tree;
-               found = true;
+               found = 1;
 
                cerr << string_compose (_("loading default ui configuration file %1"), rcfile) << endl;
                
@@ -77,8 +91,14 @@ UIConfiguration::load_state ()
                        return -1;
                }
        }
-
-       rcfile = find_config_file ("ardour2_ui.conf");
+       return found;
+}
+       
+int
+UIConfiguration::load_state ()
+{
+       int found = load_defaults ();
+       std::string rcfile = find_config_file ("ardour2_ui.conf");
 
        if (rcfile.length())
        {
@@ -111,8 +131,7 @@ UIConfiguration::save_state()
        XMLTree tree;
        string rcfile;
 
-       rcfile = get_user_ardour_path ();
-       rcfile += "ardour2_ui.conf";
+       rcfile = Glib::build_filename (get_user_ardour_path (), "ardour2_ui.conf");
 
        if (rcfile.length()) {
                tree.set_root (&get_state());