void
ThemeManager::alias_palette_response (int response, std::string target_name, std::string old_alias)
{
+ cerr << "palette response: " << response << endl;
+
switch (response) {
case GTK_RESPONSE_OK:
case GTK_RESPONSE_ACCEPT:
setup_aliases ();
break;
- default:
+
+ case GTK_RESPONSE_REJECT:
/* revert choice */
ARDOUR_UI::instance()->config()->set_alias (target_name, old_alias);
break;
+
+ default:
+ /* do nothing */
+ break;
}
palette_window->hide ();
delete palette_window;
palette_window = new ArdourDialog (_("Color Palette"));
- palette_window->add_button (Stock::CANCEL, RESPONSE_CANCEL);
+ palette_window->add_button (Stock::CANCEL, RESPONSE_REJECT); /* using CANCEL causes confusion if dialog is closed via CloseAllDialogs */
palette_window->add_button (Stock::OK, RESPONSE_OK);
ArdourCanvas::GtkCanvas* canvas = new ArdourCanvas::GtkCanvas ();
_dirty (false),
base_modified (false),
aliases_modified (false),
- derived_modified (false)
+ derived_modified (false),
+ block_save (0)
{
_instance = this;
int
UIConfiguration::load_defaults ()
{
- int found = 0;
std::string rcfile;
-
+ int ret = -1;
+
if (find_file (ardour_config_search_path(), default_ui_config_file_name, rcfile) ) {
XMLTree tree;
- found = 1;
info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endmsg;
if (!tree.read (rcfile.c_str())) {
error << string_compose(_("cannot read default ui configuration file \"%1\""), rcfile) << endmsg;
- return -1;
- }
-
- if (set_state (*tree.root(), Stateful::loading_state_version)) {
- error << string_compose(_("default ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
- return -1;
+ } else {
+ if (set_state (*tree.root(), Stateful::loading_state_version)) {
+ error << string_compose(_("default ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
+ } else {
+ _dirty = false;
+ ret = 0;
+ }
}
-
- _dirty = false;
} else {
warning << string_compose (_("Could not find default UI configuration file %1"), default_ui_config_file_name) << endmsg;
}
- return found;
+ if (ret == 0) {
+ /* reload color theme */
+ load_color_theme (false);
+ ARDOUR_UI_UTILS::ColorsChanged (); /* EMIT SIGNAL */
+ }
+
+ return 0;
}
int
-UIConfiguration::load_color_theme ()
+UIConfiguration::load_color_theme (bool allow_own)
{
std::string cfile;
- string basename = color_file.get();
+ string basename;
+ bool found = false;
- basename += ".colors";
+ if (allow_own) {
+ basename = "my-";
+ basename += color_file.get();
+ basename += ".colors";
+
+ if (find_file (ardour_config_search_path(), basename, cfile)) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ basename = color_file.get();
+ basename += ".colors";
- if (find_file (ardour_config_search_path(), basename, cfile)) {
- XMLTree tree;
+ if (find_file (ardour_config_search_path(), basename, cfile)) {
+ found = true;
+ }
+ }
+ if (found) {
+
+ XMLTree tree;
+
info << string_compose (_("Loading color file %1"), cfile) << endmsg;
if (!tree.read (cfile.c_str())) {
}
int
-UIConfiguration::store_color_theme (string const& path)
+UIConfiguration::store_color_theme ()
{
XMLNode* root;
LocaleGuard lg (X_("POSIX"));
root->add_child_nocopy (*parent);
XMLTree tree;
-
+ std::string colorfile = Glib::build_filename (user_config_directory(), (string ("my-") + color_file.get() + ".colors"));
+
tree.set_root (root);
- if (!tree.write (path.c_str())){
- error << string_compose (_("Color file %1 not saved"), path) << endmsg;
+
+ if (!tree.write (colorfile.c_str())){
+ error << string_compose (_("Color file %1 not saved"), colorfile) << endmsg;
return -1;
}
}
if (base_modified || aliases_modified || derived_modified) {
- std::string colorfile = Glib::build_filename (user_config_directory(), (color_file.get() + ".colors"));
- cerr << "Save colors to " << colorfile << endl;
- if (store_color_theme (colorfile)) {
+ if (store_color_theme ()) {
error << string_compose (_("Color file %1 not saved"), color_file.get()) << endmsg;
return -1;
}
}
void
-UIConfiguration::load_rc_file (bool themechange)
+UIConfiguration::load_rc_file (bool themechange, bool allow_own)
{
string basename = ui_rc_file.get();
std::string rc_file_path;
{
return o << rhsv.base_color << " + HSV(" << rhsv.modifier << ")";
}
+
static UIConfiguration* instance() { return _instance; }
+ void load_rc_file (bool themechange, bool allow_own = true);
+
int load_state ();
int save_state ();
int load_defaults ();
- void load_rc_file (bool themechange);
-
int set_state (const XMLNode&, int version);
XMLNode& get_state (void);
XMLNode& get_variables (std::string);
static UIConfiguration* _instance;
- int store_color_theme (std::string const &);
+ int store_color_theme ();
void load_base_colors (XMLNode const &);
void load_color_aliases (XMLNode const &);
void load_relative_colors (XMLNode const &);
void reset_gtk_theme ();
void colors_changed ();
- int load_color_theme ();
+ int load_color_theme (bool allow_own=true);
+
+ uint32_t block_save;
};
std::ostream& operator<< (std::ostream& o, const UIConfiguration::RelativeHSV& rhsv);