update drobilla's fascistic dir-locals.el to force emacs users into whitespace submis...
[ardour.git] / gtk2_ardour / ui_config.h
index 5d4b72056d21550086802b5034cbda30ce844cc7..09e844883161653f5ecd7c942d86256b41a49e51 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2007 Paul Davis 
+    Copyright (C) 2000-2007 Paul Davis
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 #include <ostream>
 #include <iostream>
 
-#include <pbd/stateful.h> 
-#include <pbd/xml++.h>
+#include "pbd/stateful.h"
+#include "pbd/xml++.h"
+#include "ardour/configuration_variable.h"
 
 template<class T>
-class UIConfigVariable 
+class UIConfigVariable : public ARDOUR::ConfigVariableBase
 {
   public:
-       UIConfigVariable (std::string str) : _name (str) {}
-       UIConfigVariable (std::string str, T val) : _name (str), value(val) {}
-
-       std::string name() const { return _name; }
+       UIConfigVariable (std::string str) : ARDOUR::ConfigVariableBase (str) {}
+       UIConfigVariable (std::string str, T val) : ARDOUR::ConfigVariableBase (str), value (val) {}
 
        bool set (T val) {
                if (val == value) {
@@ -48,54 +47,25 @@ class UIConfigVariable
                return value;
        }
 
-       void add_to_node (XMLNode& node) {
+       std::string get_as_string () const {
                std::stringstream ss;
                ss << std::hex;
                ss.fill('0');
                ss.width(8);
                ss << value;
-               XMLNode* child = new XMLNode ("Option");
-               child->add_property ("name", _name);
-               child->add_property ("value", ss.str());
-               node.add_child_nocopy (*child);
+               return ss.str ();
        }
-       
-       bool set_from_node (const XMLNode& node) {
-
-               const XMLProperty* prop;
-               XMLNodeList nlist;
-               XMLNodeConstIterator niter;
-               XMLNode* child;
-                       
-               nlist = node.children();
-                       
-               for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
-                               
-                       child = *niter;
-                               
-                       if (child->name() == "Option") {
-                               if ((prop = child->property ("name")) != 0) {
-                                       if (prop->value() == _name) {
-                                               if ((prop = child->property ("value")) != 0) {
-                                                       std::stringstream ss;
-                                                       ss << std::hex;
-                                                       ss << prop->value();
-                                                       ss >> value;
-
-                                                       return true;
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return false;
+
+       void set_from_string (std::string const & s) {
+               std::stringstream ss;
+               ss << std::hex;
+               ss << s;
+               ss >> value;
        }
 
   protected:
        T get_for_save() { return value; }
-       std::string _name;
        T value;
-       
 };
 
 class UIConfiguration : public PBD::Stateful
@@ -110,7 +80,7 @@ class UIConfiguration : public PBD::Stateful
        int save_state ();
        int load_defaults ();
 
-       int set_state (const XMLNode&);
+       int set_state (const XMLNode&, int version);
        XMLNode& get_state (void);
        XMLNode& get_variables (std::string);
        void set_variables (const XMLNode&);