fix clicking when processors become active/inactive; reduce crazy 2.5sec delay for...
[ardour.git] / libs / ardour / configuration.cc
1 /*
2     Copyright (C) 1999-2009 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "ardour/configuration.h"
21
22 using namespace ARDOUR;
23 using namespace std;
24 using namespace PBD;
25
26 Configuration::Configuration ()
27 {
28 }
29
30 Configuration::~Configuration ()
31 {
32 }
33
34 bool ConfigVariableBase::show_stores = false;
35
36 void
37 ConfigVariableBase::add_to_node (XMLNode& node)
38 {
39         std::string const v = get_as_string ();
40         show_stored_value (v);
41         XMLNode* child = new XMLNode ("Option");
42         child->add_property ("name", _name);
43         child->add_property ("value", v);
44         node.add_child_nocopy (*child);
45 }
46
47 bool
48 ConfigVariableBase::set_from_node (XMLNode const & node)
49 {
50         if (node.name() == "Config" || node.name() == "Canvas" || node.name() == "UI") {
51                 
52                 /* ardour.rc */
53                 
54                 const XMLProperty* prop;
55                 XMLNodeList nlist;
56                 XMLNodeConstIterator niter;
57                 XMLNode* child;
58                 
59                 nlist = node.children();
60                 
61                 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
62                         
63                         child = *niter;
64                         
65                         if (child->name() == "Option") {
66                                 if ((prop = child->property ("name")) != 0) {
67                                         if (prop->value() == _name) {
68                                                 if ((prop = child->property ("value")) != 0) {
69                                                         set_from_string (prop->value());
70                                                         return true;
71                                                 }
72                                         }
73                                 }
74                         }
75                 }
76                         
77         } else if (node.name() == "Options") {
78
79                 /* session file */
80
81                 XMLNodeList olist;
82                 XMLNodeConstIterator oiter;
83                 XMLNode* option;
84                 const XMLProperty* opt_prop;
85                 
86                 olist = node.children();
87                 
88                 for (oiter = olist.begin(); oiter != olist.end(); ++oiter) {
89                         
90                         option = *oiter;
91                         
92                         if (option->name() == _name) {
93                                 if ((opt_prop = option->property ("val")) != 0) {
94                                         set_from_string (opt_prop->value());
95                                         return true;
96                                 }
97                         }
98                 }
99         }
100         
101         return false;
102 }
103
104
105 void
106 ConfigVariableBase::set_show_stored_values (bool yn)
107 {
108         show_stores = yn;
109 }
110
111 void
112 ConfigVariableBase::show_stored_value (const string& str)
113 {
114         if (show_stores) {
115                 cerr << "Config variable " << _name << " stored as " << str << endl;
116         }
117 }
118
119 void
120 ConfigVariableBase::notify ()
121 {
122         // placeholder for any debugging desired when a config variable is modified
123 }
124
125 void
126 ConfigVariableBase::miss ()
127 {
128         // placeholder for any debugging desired when a config variable 
129         // is set but to the same value as it already has
130 }
131