if a (file) source really cannot be found, differentiate between audio & MIDI.
[ardour.git] / gtk2_ardour / ui_config.cc
index 3666a280c9be7f215908c488861b92506df90ed9..86e08d7fa6001651224cd08433284ae0b7207fe9 100644 (file)
@@ -40,6 +40,9 @@ using namespace std;
 using namespace PBD;
 using namespace ARDOUR;
 
+static const char* ui_config_file_name = "ui_config";
+static const char* default_ui_config_file_name = "default_ui_config";
+
 UIConfiguration::UIConfiguration ()
        :
 #undef  UI_CONFIG_VARIABLE
@@ -76,22 +79,12 @@ int
 UIConfiguration::load_defaults ()
 {
        int found = 0;
+        std::string rcfile;
 
-       std::string default_ui_rc_file;
-       std::string rcfile;
-
-       if (getenv ("ARDOUR_SAE")) {
-               rcfile = "ardour3_ui_sae.conf";
-       } else {
-               rcfile = "ardour3_ui_default.conf";
-       }
-
-       if (find_file_in_search_path (ardour_config_search_path(), rcfile, default_ui_rc_file) ) {
+       if (find_file (ardour_config_search_path(), default_ui_config_file_name, rcfile) ) {
                XMLTree tree;
                found = 1;
 
-               string rcfile = default_ui_rc_file;
-
                info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;
 
                if (!tree.read (rcfile.c_str())) {
@@ -115,14 +108,12 @@ UIConfiguration::load_state ()
 {
        bool found = false;
 
-       std::string default_ui_rc_file;
+       std::string rcfile;
 
-       if ( find_file_in_search_path (ardour_config_search_path(), "ardour3_ui_default.conf", default_ui_rc_file)) {
+       if ( find_file (ardour_config_search_path(), default_ui_config_file_name, rcfile)) {
                XMLTree tree;
                found = true;
 
-               string rcfile = default_ui_rc_file;
-
                info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;
 
                if (!tree.read (rcfile.c_str())) {
@@ -136,14 +127,10 @@ UIConfiguration::load_state ()
                }
        }
 
-       std::string user_ui_rc_file;
-
-       if (find_file_in_search_path (ardour_config_search_path(), "ardour3_ui.conf", user_ui_rc_file)) {
+       if (find_file (ardour_config_search_path(), ui_config_file_name, rcfile)) {
                XMLTree tree;
                found = true;
 
-               string rcfile = user_ui_rc_file;
-
                info << string_compose (_("Loading user ui configuration file %1"), rcfile) << endmsg;
 
                if (!tree.read (rcfile)) {
@@ -173,7 +160,7 @@ UIConfiguration::save_state()
        XMLTree tree;
 
        std::string rcfile(user_config_directory());
-       rcfile = Glib::build_filename (rcfile, "ardour3_ui.conf");
+       rcfile = Glib::build_filename (rcfile, ui_config_file_name);
 
        // this test seems bogus?
        if (rcfile.length()) {
@@ -307,6 +294,35 @@ UIConfiguration::color_by_name (const std::string& name)
        if (i != canvas_colors.end()) {
                return i->second->get();
        }
+#if 0 // yet unsed experimental style postfix
+       /* Idea: use identical colors but different font/sizes
+        * for variants of the same 'widget'.
+        *
+        * example:
+        *  set_name("mute button");  // in route_ui.cc
+        *  set_name("mute button small"); // in mixer_strip.cc
+        *
+        * ardour3_widget_list.rc:
+        *  widget "*mute button" style:highest "small_button"
+        *  widget "*mute button small" style:highest "very_small_text"
+        *
+        * both use color-schema of defined in
+        *   BUTTON_VARS(MuteButton, "mute button")
+        *
+        * (in this particular example the widgets should be packed
+        * vertically shinking the mixer strip ones are currently not)
+        */
+       const size_t name_len = name.size();
+       const size_t name_sep = name.find(':');
+       for (i = canvas_colors.begin(); i != canvas_colors.end(), name_sep != string::npos; ++i) {
+               const size_t cmp_len = i->first.size();
+               const size_t cmp_sep = i->first.find(':');
+               if (cmp_len >= name_len || cmp_sep == string::npos) continue;
+               if (name.substr(name_sep) != i->first.substr(cmp_sep)) continue;
+               if (name.substr(0, cmp_sep) != i->first.substr(0, cmp_sep)) continue;
+               return i->second->get();
+       }
+#endif
 
        // cerr << string_compose (_("Color %1 not found"), name) << endl;
        return RGBA_TO_UINT (g_random_int()%256,g_random_int()%256,g_random_int()%256,0xff);