diff options
author | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2002-12-01 13:42:15 (GMT) |
commit | 28b5c604490094e187494dcc566bd3d7a05a2c25 (patch) | |
tree | 8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/Resource.cc | |
parent | b9134162f9633784d9097df18769a699a62650fe (diff) | |
download | fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.zip fluxbox-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2 |
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/Resource.cc')
-rw-r--r-- | src/Resource.cc | 106 |
1 files changed, 53 insertions, 53 deletions
diff --git a/src/Resource.cc b/src/Resource.cc index cb871f1..fb96b71 100644 --- a/src/Resource.cc +++ b/src/Resource.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Resource.cc,v 1.3 2002/07/20 09:51:26 fluxgen Exp $ | 22 | // $Id: Resource.cc,v 1.4 2002/12/01 13:41:58 rathnor Exp $ |
23 | 23 | ||
24 | #include "Resource.hh" | 24 | #include "Resource.hh" |
25 | #include "XrmDatabaseHelper.hh" | 25 | #include "XrmDatabaseHelper.hh" |
@@ -37,35 +37,35 @@ bool ResourceManager::m_init = false; | |||
37 | // else false | 37 | // else false |
38 | //------------------------- | 38 | //------------------------- |
39 | bool ResourceManager::load(const char *filename) { | 39 | bool ResourceManager::load(const char *filename) { |
40 | assert(filename); | 40 | assert(filename); |
41 | 41 | ||
42 | ensureXrmIsInitialize(); | 42 | ensureXrmIsInitialize(); |
43 | 43 | ||
44 | XrmDatabaseHelper database; | 44 | XrmDatabaseHelper database; |
45 | database = XrmGetFileDatabase(filename); | 45 | database = XrmGetFileDatabase(filename); |
46 | if (database==0) | 46 | if (database==0) |
47 | return false; | 47 | return false; |
48 | 48 | ||
49 | XrmValue value; | 49 | XrmValue value; |
50 | char *value_type; | 50 | char *value_type; |
51 | 51 | ||
52 | //get list and go throu all the resources and load them | 52 | //get list and go throu all the resources and load them |
53 | ResourceList::iterator i = m_resourcelist.begin(); | 53 | ResourceList::iterator i = m_resourcelist.begin(); |
54 | ResourceList::iterator i_end = m_resourcelist.end(); | 54 | ResourceList::iterator i_end = m_resourcelist.end(); |
55 | for (; i != i_end; ++i) { | 55 | for (; i != i_end; ++i) { |
56 | 56 | ||
57 | Resource_base *resource = *i; | 57 | Resource_base *resource = *i; |
58 | if (XrmGetResource(*database, resource->name().c_str(), | 58 | if (XrmGetResource(*database, resource->name().c_str(), |
59 | resource->altName().c_str(), &value_type, &value)) | 59 | resource->altName().c_str(), &value_type, &value)) |
60 | resource->setFromString(value.addr); | 60 | resource->setFromString(value.addr); |
61 | else { | 61 | else { |
62 | cerr<<"Failed to read: "<<resource->name()<<endl; | 62 | cerr<<"Failed to read: "<<resource->name()<<endl; |
63 | cerr<<"Setting default value"<<endl; | 63 | cerr<<"Setting default value"<<endl; |
64 | resource->setDefaultValue(); | 64 | resource->setDefaultValue(); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | 70 | ||
71 | //-------------- save ----------------- | 71 | //-------------- save ----------------- |
@@ -75,45 +75,45 @@ bool ResourceManager::load(const char *filename) { | |||
75 | // the error | 75 | // the error |
76 | //------------------------------------- | 76 | //------------------------------------- |
77 | bool ResourceManager::save(const char *filename, const char *mergefilename) { | 77 | bool ResourceManager::save(const char *filename, const char *mergefilename) { |
78 | assert(filename); | 78 | assert(filename); |
79 | 79 | ||
80 | ensureXrmIsInitialize(); | 80 | ensureXrmIsInitialize(); |
81 | 81 | ||
82 | XrmDatabaseHelper database; | 82 | XrmDatabaseHelper database; |
83 | 83 | ||
84 | string rc_string; | 84 | string rc_string; |
85 | ResourceList::iterator i = m_resourcelist.begin(); | 85 | ResourceList::iterator i = m_resourcelist.begin(); |
86 | ResourceList::iterator i_end = m_resourcelist.end(); | 86 | ResourceList::iterator i_end = m_resourcelist.end(); |
87 | //write all resources to database | 87 | //write all resources to database |
88 | for (; i != i_end; ++i) { | 88 | for (; i != i_end; ++i) { |
89 | Resource_base *resource = *i; | 89 | Resource_base *resource = *i; |
90 | rc_string = resource->name() + string(": ") + resource->getString(); | 90 | rc_string = resource->name() + string(": ") + resource->getString(); |
91 | XrmPutLineResource(&*database, rc_string.c_str()); | 91 | XrmPutLineResource(&*database, rc_string.c_str()); |
92 | } | 92 | } |
93 | 93 | ||
94 | if (database==0) | 94 | if (database==0) |
95 | return false; | 95 | return false; |
96 | 96 | ||
97 | //check if we want to merge a database | 97 | //check if we want to merge a database |
98 | if (mergefilename) { | 98 | if (mergefilename) { |
99 | XrmDatabaseHelper olddatabase(mergefilename); | 99 | XrmDatabaseHelper olddatabase(mergefilename); |
100 | if (olddatabase == 0) // did we load the file? | 100 | if (olddatabase == 0) // did we load the file? |
101 | return false; | 101 | return false; |
102 | 102 | ||
103 | XrmMergeDatabases(*database, &*olddatabase); // merge databases | 103 | XrmMergeDatabases(*database, &*olddatabase); // merge databases |
104 | XrmPutFileDatabase(*olddatabase, filename); // save database to file | 104 | XrmPutFileDatabase(*olddatabase, filename); // save database to file |
105 | 105 | ||
106 | *database = 0; // don't try to destroy the database | 106 | *database = 0; // don't try to destroy the database |
107 | } else // save database to file | 107 | } else // save database to file |
108 | XrmPutFileDatabase(*database, filename); | 108 | XrmPutFileDatabase(*database, filename); |
109 | 109 | ||
110 | return true; | 110 | return true; |
111 | } | 111 | } |
112 | 112 | ||
113 | void ResourceManager::ensureXrmIsInitialize() { | 113 | void ResourceManager::ensureXrmIsInitialize() { |
114 | if (!m_init) { | 114 | if (!m_init) { |
115 | XrmInitialize(); | 115 | XrmInitialize(); |
116 | m_init = true; | 116 | m_init = true; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||