fix pango font style (prev commit)
[ardour.git] / gtk2_ardour / ui_config.cc
index 119e8df696ac78433fe6d2620ac87804955e9696..342adb294fd2687ed1bc23c998aa450b3f406235 100644 (file)
@@ -25,7 +25,6 @@
 
 #include "pbd/failed_constructor.h"
 #include "pbd/xml++.h"
-#include "pbd/filesystem.h"
 #include "pbd/file_utils.h"
 #include "pbd/error.h"
 
@@ -47,10 +46,12 @@ UIConfiguration::UIConfiguration ()
 #undef  CANVAS_VARIABLE
 #define UI_CONFIG_VARIABLE(Type,var,name,val) var (name,val),
 #define CANVAS_VARIABLE(var,name) var (name),
+#define CANVAS_STRING_VARIABLE(var,name) var (name),
 #include "ui_config_vars.h"
 #include "canvas_vars.h"
 #undef  UI_CONFIG_VARIABLE
 #undef  CANVAS_VARIABLE
+#undef  CANVAS_STRING_VARIABLE
        _dirty (false)
 {
        load_state();
@@ -60,6 +61,15 @@ UIConfiguration::~UIConfiguration ()
 {
 }
 
+void
+UIConfiguration::map_parameters (boost::function<void (std::string)>& functor)
+{
+#undef  UI_CONFIG_VARIABLE
+#define UI_CONFIG_VARIABLE(Type,var,Name,value) functor (Name);
+#include "ui_config_vars.h"
+#undef  UI_CONFIG_VARIABLE
+}
+
 int
 UIConfiguration::load_defaults ()
 {
@@ -160,10 +170,8 @@ UIConfiguration::save_state()
 {
        XMLTree tree;
 
-       sys::path rcfile_path(user_config_directory());
-
-       rcfile_path /= "ardour3_ui.conf";
-       const string rcfile = rcfile_path.to_string();
+       std::string rcfile(user_config_directory());
+       rcfile = Glib::build_filename (rcfile, "ardour3_ui.conf");
 
        // this test seems bogus?
        if (rcfile.length()) {
@@ -209,10 +217,12 @@ UIConfiguration::get_variables (std::string which_node)
 #undef  CANVAS_VARIABLE
 #define UI_CONFIG_VARIABLE(Type,var,Name,value) if (node->name() == "UI") { var.add_to_node (*node); }
 #define CANVAS_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
+#define CANVAS_STRING_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
 #include "ui_config_vars.h"
 #include "canvas_vars.h"
 #undef  UI_CONFIG_VARIABLE
 #undef  CANVAS_VARIABLE
+#undef  CANVAS_STRING_VARIABLE
 
        return *node;
 }
@@ -256,32 +266,39 @@ UIConfiguration::set_variables (const XMLNode& node)
          if (var.set_from_node (node)) { \
                 ParameterChanged (name); \
                 }
+#define CANVAS_STRING_VARIABLE(var,name)       \
+         if (var.set_from_node (node)) { \
+                ParameterChanged (name); \
+                }
 #include "ui_config_vars.h"
 #include "canvas_vars.h"
 #undef  UI_CONFIG_VARIABLE
 #undef  CANVAS_VARIABLE
+#undef  CANVAS_STRING_VARIABLE
 }
 
 void
 UIConfiguration::pack_canvasvars ()
 {
 #undef  CANVAS_VARIABLE
-#define CANVAS_VARIABLE(var,name) canvas_colors.insert (std::pair<std::string,UIConfigVariable<uint32_t>* >(name,&var));
+#define CANVAS_VARIABLE(var,name) canvas_colors.insert (std::pair<std::string,ColorVariable<uint32_t>* >(name,&var));
+#define CANVAS_STRING_VARIABLE(var,name) 
 #include "canvas_vars.h"
 #undef  CANVAS_VARIABLE
+#undef  CANVAS_STRING_VARIABLE
 }
 
 uint32_t
 UIConfiguration::color_by_name (const std::string& name)
 {
-       map<std::string,UIConfigVariable<uint32_t>* >::iterator i = canvas_colors.find (name);
+       map<std::string,ColorVariable<uint32_t>* >::iterator i = canvas_colors.find (name);
 
        if (i != canvas_colors.end()) {
                return i->second->get();
        }
 
        // cerr << string_compose (_("Color %1 not found"), name) << endl;
-       return RGBA_TO_UINT (random()%256,random()%256,random()%256,0xff);
+       return RGBA_TO_UINT (g_random_int()%256,g_random_int()%256,g_random_int()%256,0xff);
 }
 
 void