+ } else {
+ warning << string_compose (_("Could not find default UI configuration file %1"), default_ui_config_file_name) << endmsg;
+ }
+
+ if (ret == 0) {
+ /* reload color theme */
+ load_color_theme (false);
+ }
+
+ return ret;
+}
+
+std::string
+UIConfiguration::color_file_name (bool use_my, bool with_version) const
+{
+ string basename;
+
+ if (use_my) {
+ basename += "my-";
+ }
+
+ std::string color_name = color_file.get();
+ size_t sep = color_name.find_first_of("-");
+ if (sep != string::npos) {
+ color_name = color_name.substr (0, sep);
+ }
+
+ basename += color_name;
+ basename += "-";
+ basename += downcase(std::string(PROGRAM_NAME));
+
+ std::string rev (revision);
+ std::size_t pos = rev.find_first_of("-");
+
+ if (with_version && pos != string::npos && pos > 0) {
+ basename += "-";
+ basename += rev.substr (0, pos); // COLORFILE_VERSION - program major.minor
+ }
+
+ basename += color_file_suffix;
+ return basename;
+}
+
+int
+UIConfiguration::load_color_file (string const & path)
+{
+ XMLTree tree;
+
+ info << string_compose (_("Loading color file %1"), path) << endmsg;
+
+ if (!tree.read (path.c_str())) {
+ error << string_compose(_("cannot read color file \"%1\""), path) << endmsg;
+ return -1;
+ }
+
+ if (set_state (*tree.root(), Stateful::loading_state_version)) {
+ error << string_compose(_("color file \"%1\" not loaded successfully."), path) << endmsg;
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+UIConfiguration::load_color_theme (bool allow_own)
+{
+ std::string cfile;
+ bool found = false;
+ /* ColorsChanged() will trigger a parameter_changed () which
+ * in turn calls save_state()
+ */
+ PBD::Unwinder<uint32_t> uw (block_save, block_save + 1);
+
+ if (find_file (theme_search_path(), color_file_name (false, true), cfile)) {
+ found = true;
+ }
+
+ if (!found) {
+ if (find_file (theme_search_path(), color_file_name (false, false), cfile)) {
+ found = true;