diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-08 22:02:32 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-12-08 22:02:38 -0500 |
commit | 0bb8e80f87f1cfd84ebfd02e48b9addffacb78c4 (patch) | |
tree | 19e711a870e8c0ffca480635f26376cfeee8f808 /gtk2_ardour | |
parent | 9ac551abab0fd80d3e61cb084d2e70c4ecc78310 (diff) |
more tweaking of color management.
User's own modification to NAME.colors are stored in $CONFIG/my-NAME.colors now.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/theme_manager.cc | 11 | ||||
-rw-r--r-- | gtk2_ardour/ui_config.cc | 77 | ||||
-rw-r--r-- | gtk2_ardour/ui_config.h | 10 |
3 files changed, 66 insertions, 32 deletions
diff --git a/gtk2_ardour/theme_manager.cc b/gtk2_ardour/theme_manager.cc index 1f333058ed..c48b8a494f 100644 --- a/gtk2_ardour/theme_manager.cc +++ b/gtk2_ardour/theme_manager.cc @@ -639,6 +639,8 @@ ThemeManager::alias_palette_event (GdkEvent* ev, string new_alias, string target 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: @@ -646,10 +648,15 @@ ThemeManager::alias_palette_response (int response, std::string target_name, std 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 (); @@ -668,7 +675,7 @@ ThemeManager::choose_color_from_palette (string const & name) 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 (); diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc index e39336491f..127654990f 100644 --- a/gtk2_ardour/ui_config.cc +++ b/gtk2_ardour/ui_config.cc @@ -67,7 +67,8 @@ UIConfiguration::UIConfiguration () _dirty (false), base_modified (false), aliases_modified (false), - derived_modified (false) + derived_modified (false), + block_save (0) { _instance = this; @@ -257,45 +258,68 @@ UIConfiguration::map_parameters (boost::function<void (std::string)>& functor) 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())) { @@ -317,7 +341,7 @@ UIConfiguration::load_color_theme () } int -UIConfiguration::store_color_theme (string const& path) +UIConfiguration::store_color_theme () { XMLNode* root; LocaleGuard lg (X_("POSIX")); @@ -345,10 +369,12 @@ UIConfiguration::store_color_theme (string const& path) 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; } @@ -425,10 +451,8 @@ UIConfiguration::save_state() } 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; } @@ -705,7 +729,7 @@ UIConfiguration::set_alias (string const & name, string const & alias) } 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; @@ -726,3 +750,4 @@ std::ostream& operator<< (std::ostream& o, const UIConfiguration::RelativeHSV& r { return o << rhsv.base_color << " + HSV(" << rhsv.modifier << ")"; } + diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h index dc7d93e5e1..f72dc46289 100644 --- a/gtk2_ardour/ui_config.h +++ b/gtk2_ardour/ui_config.h @@ -55,12 +55,12 @@ class UIConfiguration : public PBD::Stateful 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); @@ -134,13 +134,15 @@ class UIConfiguration : public PBD::Stateful 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); |