removed the following environment variables:
authorTim Mayberry <mojofunk@gmail.com>
Sun, 12 Mar 2006 16:19:03 +0000 (16:19 +0000)
committerTim Mayberry <mojofunk@gmail.com>
Sun, 12 Mar 2006 16:19:03 +0000 (16:19 +0000)
ARDOUR_GLADE_PATH
ARDOUR_RC
ARDOUR_UI
ARDOUR_UI_RC
ARDOUR_BINDINGS
ARDOUR_COLORS

They have been replaced with just one environment
variable called ARDOUR_PATH which can contain a number
of colon separated paths that are used to find various
configuration and data files. Files located in
ARDOUR_PATH have priority over files in ~/.ardour/ and
in the system path.

Moved two member functions of the Configuration class
into globals.cc as they should of been static and I'm
trying to keep the non-portable code together when it
makes sense.

git-svn-id: svn://localhost/trunk/ardour2@380 d708f5d6-7413-0410-9779-e7cbd77b26cf

16 files changed:
gtk2_ardour/actions.cc
gtk2_ardour/ardev_common.sh
gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui_dependents.cc
gtk2_ardour/editor.cc
gtk2_ardour/editor_mouse.cc
gtk2_ardour/glade_path.cc
gtk2_ardour/main.cc
libs/ardour/ardour/ardour.h
libs/ardour/ardour/configuration.h
libs/ardour/audio_library.cc
libs/ardour/configuration.cc
libs/ardour/globals.cc
libs/ardour/recent_sessions.cc
libs/ardour/session.cc
libs/ardour/session_state.cc

index 1ca9278bafa9ea0382dc7682efb290369d8fce94..137b8b55e589a8679eb346718aabf67c1aaa2ca2 100644 (file)
@@ -64,12 +64,8 @@ ActionManager::init ()
 {
        ui_manager = UIManager::create ();
        
-       std::string ui_file = Glib::getenv(X_("ARDOUR_UI"));
-    
-        if(!Glib::file_test(ui_file, Glib::FILE_TEST_EXISTS)) ui_file = ARDOUR::find_config_file("ardour.menus");
+       std::string ui_file = ARDOUR::find_config_file("ardour.menus");
 
-       std::cout << "Loading UI definition file " << ui_file << std::endl;
-       
        bool loaded = false;
        
        try {
index 2dad81d3eeb5e00a606dfba12a61c48729af8938..9f932e9bbffea1a27f5123e3405344a5003fcacb 100755 (executable)
@@ -1,8 +1,5 @@
 #export G_DEBUG=fatal_criticals
-export ARDOUR_RC=../ardour.rc
-export ARDOUR_GLADE_PATH=./glade
-export ARDOUR_UI=./ardour.menus
-export ARDOUR_UI_RC=./ardour2_ui.rc
-export ARDOUR_BINDINGS=./ardour.bindings
-export ARDOUR_COLORS=./ardour.colors
+
+export ARDOUR_PATH=./glade:./pixmaps:.:..
+
 export LD_LIBRARY_PATH=../libs/ardour:../libs/midi++2:../libs/pbd3:../libs/soundtouch:../libs/gtkmm2ext:$LD_LIBRARY_PATH
index 72bc9948eefdbe0b159eb9017a228cbb621594ea..f99d199681a1813c49b118c4ccfde4900439d795 100644 (file)
@@ -131,11 +131,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
        using namespace Gtk::Menu_Helpers;
 
        Gtkmm2ext::init();
-
-       /* actually, its already loaded, but ... */
-
-       cerr << "Loading UI configuration file " << rcfile << endl;
-
+       
        about = 0;
 
        if (theArdourUI == 0) {
@@ -148,12 +144,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], string rcfile)
 
        color_manager = new ColorManager();
 
-       std::string color_file = Glib::getenv(X_("ARDOUR_COLORS"));
-       if(!Glib::file_test(color_file, Glib::FILE_TEST_EXISTS)) {
-               color_file = ARDOUR::find_config_file("ardour.colors");
-       }
-
-       cerr << "Loading UI color configuration file " << color_file << endl;
+       std::string color_file = ARDOUR::find_config_file("ardour.colors");
        
        color_manager->load (color_file);
 
@@ -374,8 +365,8 @@ ARDOUR_UI::save_ardour_state ()
                session->add_instant_xml(enode, session->path());
                session->add_instant_xml(mnode, session->path());
        } else {
-               Config->add_instant_xml(enode, Config->get_user_ardour_path());
-               Config->add_instant_xml(mnode, Config->get_user_ardour_path());
+               Config->add_instant_xml(enode, get_user_ardour_path());
+               Config->add_instant_xml(mnode, get_user_ardour_path());
        }
 }
 
@@ -2130,7 +2121,7 @@ ARDOUR_UI::mixer_settings () const
        if (session) {
                node = session->instant_xml(X_("Mixer"), session->path());
        } else {
-               node = Config->instant_xml(X_("Mixer"), Config->get_user_ardour_path());
+               node = Config->instant_xml(X_("Mixer"), get_user_ardour_path());
        }
 
        if (!node) {
@@ -2148,7 +2139,7 @@ ARDOUR_UI::editor_settings () const
        if (session) {
                node = session->instant_xml(X_("Editor"), session->path());
        } else {
-               node = Config->instant_xml(X_("Editor"), Config->get_user_ardour_path());
+               node = Config->instant_xml(X_("Editor"), get_user_ardour_path());
        }
 
        if (!node) {
index dc69ce84835bce14a2d1f8e65e9fddd7bb2cb8a7..1f8b0ef702bdf40c34be573e94ed250e221f5a91 100644 (file)
@@ -64,12 +64,8 @@ ARDOUR_UI::setup_keybindings ()
        install_actions ();
        RedirectBox::register_actions ();
        
-       std::string key_binding_file = Glib::getenv(X_("ARDOUR_BINDINGS"));
+       std::string key_binding_file = ARDOUR::find_config_file("ardour.bindings");
 
-       if(!Glib::file_test(key_binding_file, Glib::FILE_TEST_EXISTS)) key_binding_file = ARDOUR::find_config_file("ardour.bindings");
-
-       std::cout << "Loading key binding file " << key_binding_file << std::endl;
-       
        try {
                AccelMap::load (key_binding_file);
        } catch (...) {
index 8789632c3b5a9d14b7eef0918b6c41269ecbc0f2..1012b67211ba05162e511a6c7e3f903b77eabb3f 100644 (file)
@@ -877,7 +877,7 @@ Editor::instant_save ()
        if (session) {
                session->add_instant_xml(get_state(), session->path());
        } else {
-               Config->add_instant_xml(get_state(), Config->get_user_ardour_path());
+               Config->add_instant_xml(get_state(), get_user_ardour_path());
        }
 }
 
index 7ec47fe532873414f891980f22df5ee6059458aa..8ad1ff6ae098cf19070f0864863a9254949f391d 100644 (file)
@@ -727,8 +727,9 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
                        break;
                default:
                        
-                       if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) {
+                       if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask(Keyboard::Shift))) {
                                scroll_backward (0.6f);
+                               return true;
                        }
                        else if (Keyboard::no_modifier_keys_pressed (&event->button)) {
                                scroll_tracks_up_line ();
@@ -763,8 +764,9 @@ Editor::button_press_handler (ArdourCanvas::Item* item, GdkEvent* event, ItemTyp
                        break;
                default:
 
-                       if (Keyboard::modifier_state_contains (event->button.state, Keyboard::ModifierMask(Keyboard::Alt))) {
+                       if (Keyboard::modifier_state_equals (event->button.state, Keyboard::ModifierMask(Keyboard::Shift))) {
                                scroll_forward (0.6f);
+                               return true;
                        }
                        else if (Keyboard::no_modifier_keys_pressed (&event->button)) {
                                scroll_tracks_down_line ();
index 3d6476d821bb0a18e53e2e7053e2ae1855d9ac72..29bca7151f787867b0b6dfaf66f482d1acb538f8 100644 (file)
 std::string
 GladePath::path(const std::string& glade_file)
 {
-    std::string user_glade_dir = Glib::getenv(X_("ARDOUR_GLADE_PATH"));
     std::string full_path;
-    
-    if(!user_glade_dir.empty()) {
-        full_path = Glib::build_filename(user_glade_dir, glade_file);
-        if(Glib::file_test(full_path, Glib::FILE_TEST_EXISTS)) return full_path;
-    }
-
-    full_path = ARDOUR::find_data_file(Glib::build_filename("glade",
-                                                            glade_file));
+   
+    full_path = ARDOUR::find_data_file(glade_file, "glade");
     return full_path;
 }
index 3dd0da92508bf25c59f123839d285bf6a9cb9ee0..14330e20092ae7440349f47032208418663466e7 100644 (file)
@@ -239,18 +239,13 @@ string
 which_ui_rcfile ()
 {
        string rcfile;
-       char* envvar;
-
-       if ((envvar = getenv("ARDOUR_UI_RC")) == 0) {
-               rcfile = find_config_file ("ardour2_ui.rc");
        
-               if (rcfile.length() == 0) {
-                       warning << _("Without a UI style file, ardour will look strange.\n Please set ARDOUR_UI_RC to point to a valid UI style file") << endmsg;
-               }
-       } else {
-               rcfile = envvar;
-       }
+       rcfile = find_config_file ("ardour2_ui.rc");
        
+       if (rcfile.length() == 0) {
+               warning << _("Without a UI style file, ardour will look strange.\n Please set ARDOUR_UI_RC to point to a valid UI style file") << endmsg;
+       }
+
        return rcfile;
 }
 
index 293d34682395735d5ecdb280a12c3ff8d81df8c7..45b45ecd06f717d1b5264a7adfb19d555384bf20 100644 (file)
@@ -47,6 +47,11 @@ namespace ARDOUR {
 
        int init (AudioEngine&, bool with_vst, bool try_optimization, void (*sighandler)(int,siginfo_t*,void*) = 0);
        int cleanup ();
+
+       
+       std::string get_user_ardour_path ();
+       std::string get_system_ardour_path ();
+
        std::string find_config_file (std::string name);
        std::string find_data_file (std::string name, std::string subdir = "" );
 
index 8ae0c0f73a6c38e8fa644f5415a6f30e823036a6..7fe3b312323f1d85b5341828fd4aeae31a5b98d8 100644 (file)
@@ -161,9 +161,6 @@ class Configuration : public Stateful
        bool get_timecode_source_is_synced ();
        void set_timecode_source_is_synced (bool);
 
-       std::string get_user_ardour_path ();
-       std::string get_system_ardour_path ();
-
        gain_t get_quieten_at_speed ();
        void  set_quieten_at_speed (gain_t);
 
index 33a1ad230e6de130410608c107c1d140bd569231..bf462f7128a2cbe496317f2e4bb9e367ea8756f5 100644 (file)
@@ -49,11 +49,11 @@ AudioLibrary::AudioLibrary ()
 {
 //     sfdb_paths.push_back("/Users/taybin/sounds");
 
-       src = "file:" + Config->get_user_ardour_path() + "sfdb";
+       src = "file:" + get_user_ardour_path() + "sfdb";
 
        // workaround for possible bug in raptor that crashes when saving to a
        // non-existant file.
-       touch_file(Config->get_user_ardour_path() + "sfdb");
+       touch_file(get_user_ardour_path() + "sfdb");
 
        lrdf_read_file(src.c_str());
 
index 3b4ad4b45f54bdea5506a4bec9718e587d03276b..f73ba1052a1fbe6e8d7c12d773a8113efdf8c4ca 100644 (file)
@@ -59,24 +59,12 @@ Configuration::~Configuration ()
 string
 Configuration::get_user_path()
 {
-       char *envvar;
-
-       if ((envvar = getenv ("ARDOUR_RC")) != 0) {
-               return envvar;
-       }
-
        return find_config_file ("ardour.rc");
 }
 
 string
 Configuration::get_system_path()
 {
-       char* envvar;
-
-       if ((envvar = getenv ("ARDOUR_SYSTEM_RC")) != 0) {
-               return envvar;
-       }
-
        return find_config_file ("ardour_system.rc");
 }
 
@@ -92,9 +80,7 @@ Configuration::load_state ()
        if (rcfile.length()) {
 
                XMLTree tree;
-
-               cerr << "Loading system configuration file " << rcfile << endl;
-
+               
                if (!tree.read (rcfile.c_str())) {
                        error << string_compose(_("Ardour: cannot read system configuration file \"%1\""), rcfile) << endmsg;
                        return -1;
@@ -117,9 +103,7 @@ Configuration::load_state ()
        if (rcfile.length()) {
 
                XMLTree tree;
-
-               cerr << "Loading user configuration file " << rcfile << endl;
-
+               
                if (!tree.read (rcfile)) {
                        error << string_compose(_("Ardour: cannot read configuration file \"%1\""), rcfile) << endmsg;
                        return -1;
@@ -140,28 +124,12 @@ Configuration::save_state()
 {
        XMLTree tree;
        string rcfile;
-       char *envvar;
 
        /* Note: this only writes the per-user file, and therefore
           only saves variables marked as user-set or modified
        */
 
-       if ((envvar = getenv ("ARDOUR_RC")) != 0) {
-               if (strlen (envvar) == 0) {
-                       return -1;
-               }
-               rcfile = envvar;
-       } else {
-
-               if ((envvar = getenv ("HOME")) == 0) {
-                       return -1;
-               }
-               if (strlen (envvar) == 0) {
-                       return -1;
-               }
-               rcfile = envvar;
-               rcfile += "/.ardour/ardour.rc";
-       }
+       rcfile = find_config_file("ardour.rc");
 
        if (rcfile.length()) {
                tree.set_root (&state (true));
@@ -1054,41 +1022,6 @@ Configuration::set_auto_xfade (bool yn)
        }
 }
 
-string
-Configuration::get_user_ardour_path ()
-{
-       string path;
-       char* envvar;
-       
-       if ((envvar = getenv ("HOME")) == 0 || strlen (envvar) == 0) {
-               return "/";
-       }
-               
-       path = envvar;
-       path += "/.ardour/";
-       
-       return path;
-}
-
-string
-Configuration::get_system_ardour_path ()
-{
-       string path;
-       char* envvar;
-
-       if ((envvar = getenv ("ARDOUR_DATA_PATH")) != 0) {
-               path += envvar;
-               if (path[path.length()-1] != ':') {
-                       path += ':';
-               }
-       }
-
-       path += DATA_DIR;
-       path += "/ardour/";
-       
-       return path;
-}
-
 bool 
 Configuration::get_no_new_session_dialog()
 {
index ad7f5c0cc835124f364ae32654018f43f193e3c3..9c3cadafe2b3103447b0c82e96dd7e04c718767a 100644 (file)
@@ -32,6 +32,7 @@
 #include <lrdf.h>
 
 #include <pbd/error.h>
+#include <pbd/strsplit.h>
 
 #include <midi++/port.h>
 #include <midi++/port_request.h>
@@ -298,37 +299,72 @@ ARDOUR::new_change ()
        return c;
 }
 
-static string
-find_file (string name, string dir, string subdir = "")
+string
+ARDOUR::get_user_ardour_path ()
 {
        string path;
+       char* envvar;
+       
+       if ((envvar = getenv ("HOME")) == 0 || strlen (envvar) == 0) {
+               return "/";
+       }
+               
+       path = envvar;
+       path += "/.ardour/";
+       
+       return path;
+}
 
-       /* stop A: ~/.ardour/... */
-
-       path = getenv ("HOME");
+string
+ARDOUR::get_system_ardour_path ()
+{
+       string path;
 
-       if (path.length()) {
-               
-               path += "/.ardour/";
+       path += DATA_DIR;
+       path += "/ardour/";
+       
+       return path;
+}
 
-               /* try to ensure that the directory exists.
-                  failure doesn't mean much here.
-               */
+static string
+find_file (string name, string dir, string subdir = "")
+{
+       string path;
+       char* envvar = getenv("ARDOUR_PATH");
 
-               mkdir (path.c_str(), 0755);
+       /* stop A: any directory in ARDOUR_PATH */
+       
+       if (envvar != 0) {
 
-               if (subdir.length()) {
-                       path += subdir + "/";
-               }
+               vector<string> split_path;
+       
+               split (envvar, split_path, ':');
                
-               path += name;
-               if (access (path.c_str(), R_OK) == 0) {
-                       return path;
+               for (vector<string>::iterator i = split_path.begin(); i != split_path.end(); ++i) {
+                       path = *i;
+                       path += "/" + name;
+                       if (access (path.c_str(), R_OK) == 0) {
+                               cerr << "Using file " << path << " found in ARDOUR_PATH." << endl;
+                               return path;
+                       }
                }
        }
 
-       /* stop B: dir/... */
+       /* stop B: ~/.ardour/ */
 
+       path = get_user_ardour_path();
+               
+       if (subdir.length()) {
+               path += subdir + "/";
+       }
+               
+       path += name;
+       if (access (path.c_str(), R_OK) == 0) {
+               return path;
+       }
+
+       /* C: dir/... */
+       
        path = dir;
        path += "/ardour/";
        
index a5c6b210ee4b021d18ee23aa9e9f59a0dc314fab..efbdb807f734b341a1f53ba9b9bc54dc6ef3a6e6 100644 (file)
@@ -34,7 +34,7 @@ using namespace ARDOUR;
 int
 ARDOUR::read_recent_sessions (RecentSessions& rs)
 {
-       string path = Config->get_user_ardour_path();
+       string path = get_user_ardour_path();
        path += "/recent";
 
        ifstream recent (path.c_str());
@@ -82,7 +82,7 @@ ARDOUR::read_recent_sessions (RecentSessions& rs)
 int
 ARDOUR::write_recent_sessions (RecentSessions& rs)
 {
-       string path = Config->get_user_ardour_path();
+       string path = get_user_ardour_path();
        path += "/recent";
 
        ofstream recent (path.c_str());
index 4361bd244e711ec2b3a1c66cf2f2c0c29c5341b2..9b61b5d816f726a5503a45a3234daa3670afd08e 100644 (file)
@@ -3409,7 +3409,7 @@ void
 Session::add_instant_xml (XMLNode& node, const std::string& dir)
 {
        Stateful::add_instant_xml (node, dir);
-       Config->add_instant_xml (node, Config->get_user_ardour_path());
+       Config->add_instant_xml (node, get_user_ardour_path());
 }
 
 int
index 241d54c8b66c03daf45ec9a8df6f9c97f0881a82..5bb7ad01e4331a00da8498aaaf13c6e091fca055 100644 (file)
@@ -2241,7 +2241,7 @@ Session::automation_dir () const
 string
 Session::template_dir ()
 {
-       string path = Config->get_user_ardour_path();
+       string path = get_user_ardour_path();
        path += "templates/";
 
        return path;
@@ -2252,11 +2252,11 @@ Session::template_path ()
 {
        string path;
 
-       path += Config->get_user_ardour_path();
+       path += get_user_ardour_path();
        if (path[path.length()-1] != ':') {
                path += ':';
        }
-       path += Config->get_system_ardour_path();
+       path += get_system_ardour_path();
 
        vector<string> split_path;
        
@@ -2654,7 +2654,7 @@ Session::get_template_list (list<string> &template_names)
 int
 Session::read_favorite_dirs (FavoriteDirs & favs)
 {
-       string path = Config->get_user_ardour_path();
+       string path = get_user_ardour_path();
        path += "/favorite_dirs";
 
        ifstream fav (path.c_str());
@@ -2689,7 +2689,7 @@ Session::read_favorite_dirs (FavoriteDirs & favs)
 int
 Session::write_favorite_dirs (FavoriteDirs & favs)
 {
-       string path = Config->get_user_ardour_path();
+       string path = get_user_ardour_path();
        path += "/favorite_dirs";
 
        ofstream fav (path.c_str());