Show cursor in Cut mode on button press at cutting position
[ardour.git] / gtk2_ardour / color_theme_manager.cc
index df0ca9075535e4a88da7e13baa97aebe7ac933ef..fc2a823c68032e0f12a1fd496048b89503c238e1 100644 (file)
@@ -27,8 +27,9 @@
 #include "gtkmm2ext/cell_renderer_color_selector.h"
 #include "gtkmm2ext/utils.h"
 
-#include "pbd/file_utils.h"
 #include "pbd/compose.h"
+#include "pbd/file_utils.h"
+#include "pbd/replace_all.h"
 
 #include "ardour/filesystem_paths.h"
 #include "ardour/profile.h"
@@ -45,7 +46,7 @@
 #include "ui_config.h"
 #include "utils.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace Gtk;
@@ -76,13 +77,16 @@ ColorThemeManager::ColorThemeManager ()
 
                        row = *(theme_list->append());
                        row[color_theme_columns.name] = c->first;
-                       row[color_theme_columns.path] = c->second;
+
+                       string color_file_name = c->second;
+
+                       row[color_theme_columns.path] = color_file_name;
 
                        /* match second (path; really basename) since that is
                           what we store/restore.
                        */
 
-                       if (UIConfiguration::instance().get_color_file() == c->second) {
+                       if (UIConfiguration::instance().get_color_file() == color_file_name) {
                                selected_iter = row;
                        }
                }
@@ -131,7 +135,7 @@ ColorThemeManager::ColorThemeManager ()
 
        palette_group = initialize_palette_canvas (*palette_viewport.canvas());
        palette_viewport.signal_size_allocate().connect (sigc::bind (sigc::mem_fun (*this, &ColorThemeManager::palette_canvas_allocated), palette_group, palette_viewport.canvas(),
-                                                                    sigc::mem_fun (*this, &ColorThemeManager::palette_event)));
+                                                                    sigc::mem_fun (*this, &ColorThemeManager::palette_event)));
        palette_scroller.add (palette_viewport);
 
        modifier_scroller.add (modifier_vbox);
@@ -161,6 +165,16 @@ ColorThemeManager::ColorThemeManager ()
        show_all ();
 }
 
+
+ColorThemeManager::~ColorThemeManager ()
+{
+       if (palette_group) { 
+               palette_group->clear (true);  
+               delete palette_group;
+       }
+}
+
+
 void
 ColorThemeManager::setup_modifiers ()
 {
@@ -219,7 +233,9 @@ ColorThemeManager::reset_canvas_colors()
        string cfile;
        string basename;
 
-       basename = UIConfiguration::instance().color_file_name (true, true, true);
+       /* look for a versioned user-owned color file, and try to rename it */
+
+       basename = UIConfiguration::instance().color_file_name (true, true);
 
        if (find_file (ardour_config_search_path(), basename, cfile)) {
                string backup = cfile + string (X_(".old"));
@@ -227,7 +243,7 @@ ColorThemeManager::reset_canvas_colors()
                /* don't really care if it fails */
        }
 
-       UIConfiguration::instance().load_defaults();
+       UIConfiguration::instance().load_color_theme (false);
        UIConfiguration::instance().save_state ();
 }
 
@@ -305,7 +321,6 @@ ColorThemeManager::build_palette_canvas (ArdourCanvas::Canvas& canvas, ArdourCan
        for (uint32_t y = 0; y < height - box_size && color_num < color_limit; y += box_size) {
                for (uint32_t x = 0; x < width - box_size && color_num < color_limit; x += box_size) {
                        ArdourCanvas::Rectangle* r = new ArdourCanvas::Rectangle (&group, ArdourCanvas::Rect (x, y, x + box_size, y + box_size));
-
                        string name = nc[color_num++].name;
 
                        UIConfiguration::Colors::iterator c = colors.find (name);
@@ -614,4 +629,3 @@ ColorThemeManager::on_color_theme_changed ()
                }
        }
 }
-