summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/theme_manager.cc47
-rw-r--r--gtk2_ardour/theme_manager.h13
-rw-r--r--gtk2_ardour/ui_config.cc86
-rw-r--r--gtk2_ardour/ui_config.h2
-rw-r--r--gtk2_ardour/utils.cc15
-rw-r--r--gtk2_ardour/utils.h3
6 files changed, 128 insertions, 38 deletions
diff --git a/gtk2_ardour/theme_manager.cc b/gtk2_ardour/theme_manager.cc
index e402bf1a3e..c99e8e886b 100644
--- a/gtk2_ardour/theme_manager.cc
+++ b/gtk2_ardour/theme_manager.cc
@@ -79,7 +79,7 @@ ThemeManager::ThemeManager()
, palette_window (0)
{
Gtk::HBox* hbox;
-
+
/* Now the alias list */
alias_list = TreeStore::create (alias_columns);
@@ -112,11 +112,33 @@ ThemeManager::ThemeManager()
set_homogeneous (false);
- vector<string> color_themes = ::get_color_themes ();
+ std::map<string,string> color_themes;
+
+ get_color_themes (color_themes);
if (color_themes.size() > 1) {
- Gtkmm2ext::set_popdown_strings (color_theme_dropdown, color_themes);
- color_theme_dropdown.set_active_text (UIConfiguration::instance().get_color_file());
+ theme_list = TreeStore::create (color_theme_columns);
+
+ TreeModel::iterator selected_iter = theme_list->children().end();
+
+ for (std::map<string,string>::iterator c = color_themes.begin(); c != color_themes.end(); ++c) {
+ TreeModel::Row row;
+
+ row = *(theme_list->append());
+ row[color_theme_columns.name] = c->first;
+ row[color_theme_columns.path] = c->second;
+
+ if (UIConfiguration::instance().get_color_file() == c->first) {
+ selected_iter = row;
+ }
+ }
+
+ color_theme_dropdown.set_model (theme_list);
+ color_theme_dropdown.pack_start (color_theme_columns.name);
+
+ if (selected_iter != theme_list->children().end()) {
+ color_theme_dropdown.set_active (selected_iter);
+ }
hbox = Gtk::manage (new Gtk::HBox());
Gtk::Alignment* align = Gtk::manage (new Gtk::Alignment);
@@ -126,6 +148,7 @@ ThemeManager::ThemeManager()
hbox->pack_start (color_theme_label, false, false);
hbox->pack_start (*align, true, true);
pack_start (*hbox, PACK_SHRINK);
+ hbox->show_all ();
}
pack_start (reset_button, PACK_SHRINK);
@@ -365,8 +388,16 @@ ThemeManager::on_icon_set_changed ()
void
ThemeManager::on_color_theme_changed ()
{
- string new_theme = color_theme_dropdown.get_active_text();
- UIConfiguration::instance().set_color_file (new_theme);
+ Gtk::TreeModel::iterator iter = color_theme_dropdown.get_active();
+
+ if (iter) {
+ Gtk::TreeModel::Row row = *iter;
+
+ if (row) {
+ string new_theme = row[color_theme_columns.path];
+ UIConfiguration::instance().set_color_file (new_theme);
+ }
+ }
}
void
@@ -423,9 +454,7 @@ ThemeManager::reset_canvas_colors()
string cfile;
string basename;
- basename = "my-";
- basename += UIConfiguration::instance().get_color_file();
- basename += UIConfiguration::color_file_suffix;
+ basename = UIConfiguration::instance().color_file_name (true, true, true);
if (find_file (ardour_config_search_path(), basename, cfile)) {
string backup = cfile + string (X_(".old"));
diff --git a/gtk2_ardour/theme_manager.h b/gtk2_ardour/theme_manager.h
index 366fc8aad8..acfa2f9219 100644
--- a/gtk2_ardour/theme_manager.h
+++ b/gtk2_ardour/theme_manager.h
@@ -67,16 +67,19 @@ class ThemeManager : public Gtk::VBox
private:
Gtk::Notebook notebook;
- struct BasicColorDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
- BasicColorDisplayModelColumns() {
+ struct ColorThemeModelColumns : public Gtk::TreeModel::ColumnRecord {
+ ColorThemeModelColumns() {
add (name);
- add (gdkcolor);
+ add (path);
}
Gtk::TreeModelColumn<std::string> name;
- Gtk::TreeModelColumn<Gdk::Color> gdkcolor;
+ Gtk::TreeModelColumn<std::string> path;
};
+ ColorThemeModelColumns color_theme_columns;
+ Glib::RefPtr<Gtk::TreeStore> theme_list;
+
Gtk::ColorSelectionDialog color_dialog;
sigc::connection color_dialog_connection;
@@ -99,7 +102,7 @@ class ThemeManager : public Gtk::VBox
Gtk::Label icon_set_label;
Gtk::ComboBoxText icon_set_dropdown;
Gtk::Label color_theme_label;
- Gtk::ComboBoxText color_theme_dropdown;
+ Gtk::ComboBox color_theme_dropdown;
/* handls response from color dialog when it is used to
edit a derived color.
diff --git a/gtk2_ardour/ui_config.cc b/gtk2_ardour/ui_config.cc
index f43b4eac33..f16c326eab 100644
--- a/gtk2_ardour/ui_config.cc
+++ b/gtk2_ardour/ui_config.cc
@@ -32,27 +32,28 @@
#include <pango/pangoft2.h> // for fontmap resolution control for GnomeCanvas
#include <pango/pangocairo.h> // for fontmap resolution control for GnomeCanvas
-#include "pbd/gstdio_compat.h"
-#include "pbd/unwind.h"
#include <glibmm/miscutils.h>
#include <gtkmm/settings.h>
#include "pbd/convert.h"
+#include "pbd/error.h"
#include "pbd/failed_constructor.h"
-#include "pbd/xml++.h"
#include "pbd/file_utils.h"
+#include "pbd/gstdio_compat.h"
#include "pbd/locale_guard.h"
-#include "pbd/error.h"
#include "pbd/stacktrace.h"
-
-#include "gtkmm2ext/rgb_macros.h"
-#include "gtkmm2ext/gtk_ui.h"
+#include "pbd/unwind.h"
+#include "pbd/xml++.h"
#include "ardour/filesystem_paths.h"
#include "ardour/search_paths.h"
+#include "ardour/revision.h"
#include "ardour/utils.h"
+#include "gtkmm2ext/rgb_macros.h"
+#include "gtkmm2ext/gtk_ui.h"
+
#include "ui_config.h"
#include "i18n.h"
@@ -256,11 +257,39 @@ UIConfiguration::load_defaults ()
return ret;
}
+std::string
+UIConfiguration::color_file_name (bool use_my, bool with_program, bool with_version) const
+{
+ string basename;
+
+ if (use_my) {
+ basename += "my-";
+ }
+
+ basename = color_file.get(); //this is the overall theme file, e.g. "dark"
+
+ if (with_program) {
+ basename += '-';
+ basename += downcase (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_theme (bool allow_own)
{
std::string cfile;
- string basename;
bool found = false;
/* ColorsChanged() will trigger a parameter_changed () which
* in turn calls save_state()
@@ -268,22 +297,45 @@ UIConfiguration::load_color_theme (bool allow_own)
PBD::Unwinder<uint32_t> uw (block_save, block_save + 1);
if (allow_own) {
- basename = "my-";
- basename += color_file.get();
- basename += color_file_suffix;
- if (find_file (theme_search_path(), basename, cfile)) {
+ PBD::Searchpath sp (user_config_directory());
+
+ if (find_file (sp, color_file_name (true, true, true), cfile)) {
found = true;
}
+
+
+ if (!found) {
+ if (find_file (sp, color_file_name (true, true, false), cfile)) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ if (find_file (sp, color_file_name (true, false, false), cfile)) {
+ found = true;
+ }
+ }
+
}
if (!found) {
- basename = color_file.get();
- basename += color_file_suffix;
- if (find_file (theme_search_path(), basename, cfile)) {
+ if (find_file (theme_search_path(), color_file_name (false, true, true), cfile)) {
found = true;
}
+
+ if (!found) {
+ if (find_file (theme_search_path(), color_file_name (false, true, false), cfile)) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ if (find_file (theme_search_path(), color_file_name (false, false, false), cfile)) {
+ found = true;
+ }
+ }
}
if (found) {
@@ -304,7 +356,7 @@ UIConfiguration::load_color_theme (bool allow_own)
ColorsChanged ();
} else {
- warning << string_compose (_("Color file %1 not found"), basename) << endmsg;
+ warning << string_compose (_("Color file for %1 not found"), color_file.get()) << endmsg;
}
return 0;
@@ -348,7 +400,7 @@ UIConfiguration::store_color_theme ()
root->add_child_nocopy (*parent);
XMLTree tree;
- std::string colorfile = Glib::build_filename (user_config_directory(), (string ("my-") + color_file.get() + color_file_suffix));
+ std::string colorfile = Glib::build_filename (user_config_directory(), color_file_name (true, true, true));;
tree.set_root (root);
diff --git a/gtk2_ardour/ui_config.h b/gtk2_ardour/ui_config.h
index 76a628b9be..3db30c0180 100644
--- a/gtk2_ardour/ui_config.h
+++ b/gtk2_ardour/ui_config.h
@@ -60,6 +60,8 @@ private:
XMLNode& get_variables (std::string);
void set_variables (const XMLNode&);
+ std::string color_file_name (bool use_my, bool with_program, bool with_version) const;
+
typedef std::map<std::string,ArdourCanvas::Color> Colors;
typedef std::map<std::string,std::string> ColorAliases;
typedef std::map<std::string,ArdourCanvas::SVAModifier> Modifiers;
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index 12c01fb7d0..e8dc568828 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -418,11 +418,10 @@ ARDOUR_UI_UTILS::get_xpm (std::string name)
return xpm_map[name];
}
-vector<string>
-ARDOUR_UI_UTILS::get_color_themes ()
+void
+ARDOUR_UI_UTILS::get_color_themes (map<std::string,std::string>& themes)
{
Searchpath spath(ARDOUR::theme_search_path());
- vector<string> r;
for (vector<string>::iterator s = spath.begin(); s != spath.end(); ++s) {
@@ -441,11 +440,15 @@ ARDOUR_UI_UTILS::get_color_themes ()
continue;
}
- r.push_back (Glib::filename_to_utf8 (basename_nosuffix(*e)));
+ XMLProperty const* prop = root->property (X_("theme-name"));
+
+ if (!prop) {
+ continue;
+ }
+
+ themes.insert (make_pair (prop->value(), Glib::filename_to_utf8 (basename_nosuffix(*e))));
}
}
-
- return r;
}
vector<string>
diff --git a/gtk2_ardour/utils.h b/gtk2_ardour/utils.h
index 03a68558b5..bdc05643a5 100644
--- a/gtk2_ardour/utils.h
+++ b/gtk2_ardour/utils.h
@@ -23,6 +23,7 @@
#include <string>
#include <cmath>
#include <vector>
+#include <map>
#include "ardour/types.h"
@@ -72,7 +73,7 @@ bool emulate_key_event (unsigned int);
Glib::RefPtr<Gdk::Pixbuf> get_xpm (std::string);
std::vector<std::string> get_icon_sets ();
-std::vector<std::string> get_color_themes ();
+void get_color_themes (std::map<std::string,std::string>&);
std::string get_icon_path (const char*, std::string icon_set = std::string(), bool is_image = true);
Glib::RefPtr<Gdk::Pixbuf> get_icon (const char*, std::string icon_set = std::string());
static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map;