aboutsummaryrefslogtreecommitdiff
path: root/src/Resources.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-30 19:31:15 (GMT)
committermathias <mathias>2006-10-30 19:31:15 (GMT)
commite5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5 (patch)
treec84838a84802805e9b1463045e86200b7cef917f /src/Resources.cc
parent426c12c25c2ef095a882619ad7424684b88465b8 (diff)
downloadfluxbox-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.zip
fluxbox-e5e76e7761f52ba7c0deca75bcecae4fbd3e2ff5.tar.bz2
Cosmetic patch from Slava Semushin
Diffstat (limited to 'src/Resources.cc')
-rw-r--r--src/Resources.cc55
1 files changed, 29 insertions, 26 deletions
diff --git a/src/Resources.cc b/src/Resources.cc
index feab9ea..9603523 100644
--- a/src/Resources.cc
+++ b/src/Resources.cc
@@ -35,7 +35,10 @@
35#include <stdio.h> 35#include <stdio.h>
36#include <string> 36#include <string>
37#include <vector> 37#include <vector>
38using namespace std; 38
39using std::string;
40using std::vector;
41
39using namespace FbTk; 42using namespace FbTk;
40 43
41//----------------------------------------------------------------- 44//-----------------------------------------------------------------
@@ -52,7 +55,7 @@ setFromString(const char* strval) {
52} 55}
53 56
54template<> 57template<>
55void FbTk::Resource<std::string>:: 58void FbTk::Resource<string>::
56setFromString(const char *strval) { 59setFromString(const char *strval) {
57 *this = strval; 60 *this = strval;
58} 61}
@@ -64,13 +67,13 @@ setFromString(char const *strval) {
64} 67}
65 68
66template<> 69template<>
67void FbTk::Resource<std::vector<WinButton::Type> >:: 70void FbTk::Resource<vector<WinButton::Type> >::
68setFromString(char const *strval) { 71setFromString(char const *strval) {
69 vector<std::string> val; 72 vector<string> val;
70 StringUtil::stringtok(val, strval); 73 StringUtil::stringtok(val, strval);
71 //clear old values 74 //clear old values
72 m_value.clear(); 75 m_value.clear();
73 76
74 for (size_t i = 0; i < val.size(); i++) { 77 for (size_t i = 0; i < val.size(); i++) {
75 if (strcasecmp(val[i].c_str(), "Maximize")==0) 78 if (strcasecmp(val[i].c_str(), "Maximize")==0)
76 m_value.push_back(WinButton::MAXIMIZE); 79 m_value.push_back(WinButton::MAXIMIZE);
@@ -98,14 +101,14 @@ setFromString(char const *strval) {
98 101
99template<> 102template<>
100void FbTk::Resource<unsigned int>:: 103void FbTk::Resource<unsigned int>::
101setFromString(const char *strval) { 104setFromString(const char *strval) {
102 if (sscanf(strval, "%ul", &m_value) != 1) 105 if (sscanf(strval, "%ul", &m_value) != 1)
103 setDefaultValue(); 106 setDefaultValue();
104} 107}
105 108
106template<> 109template<>
107void FbTk::Resource<long long>:: 110void FbTk::Resource<long long>::
108setFromString(const char *strval) { 111setFromString(const char *strval) {
109 if (sscanf(strval, "%llu", &m_value) != 1) 112 if (sscanf(strval, "%llu", &m_value) != 1)
110 setDefaultValue(); 113 setDefaultValue();
111} 114}
@@ -115,26 +118,26 @@ setFromString(const char *strval) {
115//---- manipulators for int, bool, and some enums with Resource --- 118//---- manipulators for int, bool, and some enums with Resource ---
116//----------------------------------------------------------------- 119//-----------------------------------------------------------------
117template<> 120template<>
118std::string FbTk::Resource<bool>:: 121string FbTk::Resource<bool>::
119getString() const { 122getString() const {
120 return std::string(**this == true ? "true" : "false"); 123 return string(**this == true ? "true" : "false");
121} 124}
122 125
123template<> 126template<>
124std::string FbTk::Resource<int>:: 127string FbTk::Resource<int>::
125getString() const { 128getString() const {
126 char strval[256]; 129 char strval[256];
127 sprintf(strval, "%d", **this); 130 sprintf(strval, "%d", **this);
128 return std::string(strval); 131 return string(strval);
129} 132}
130 133
131template<> 134template<>
132std::string FbTk::Resource<std::string>:: 135string FbTk::Resource<string>::
133getString() const { return **this; } 136getString() const { return **this; }
134 137
135 138
136template<> 139template<>
137std::string FbTk::Resource<std::vector<WinButton::Type> >:: 140string FbTk::Resource<vector<WinButton::Type> >::
138getString() const { 141getString() const {
139 string retval; 142 string retval;
140 for (size_t i = 0; i < m_value.size(); i++) { 143 for (size_t i = 0; i < m_value.size(); i++) {
@@ -167,7 +170,7 @@ getString() const {
167} 170}
168 171
169template<> 172template<>
170std::string FbTk::Resource<Fluxbox::TabsAttachArea>:: 173string FbTk::Resource<Fluxbox::TabsAttachArea>::
171getString() const { 174getString() const {
172 if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) 175 if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR)
173 return "Titlebar"; 176 return "Titlebar";
@@ -211,43 +214,43 @@ setFromString(const char *strval) {
211 m_value = ::Layer::BOTTOM; 214 m_value = ::Layer::BOTTOM;
212 else if (strcasecmp(strval, "Desktop") == 0) 215 else if (strcasecmp(strval, "Desktop") == 0)
213 m_value = ::Layer::DESKTOP; 216 m_value = ::Layer::DESKTOP;
214 else 217 else
215 setDefaultValue(); 218 setDefaultValue();
216} 219}
217 220
218 221
219template<> 222template<>
220std::string FbTk::Resource<Layer>:: 223string FbTk::Resource<Layer>::
221getString() const { 224getString() const {
222 switch (m_value.getNum()) { 225 switch (m_value.getNum()) {
223 case Layer::MENU: 226 case Layer::MENU:
224 return std::string("Menu"); 227 return string("Menu");
225 case Layer::ABOVE_DOCK: 228 case Layer::ABOVE_DOCK:
226 return std::string("AboveDock"); 229 return string("AboveDock");
227 case Layer::DOCK: 230 case Layer::DOCK:
228 return std::string("Dock"); 231 return string("Dock");
229 case Layer::TOP: 232 case Layer::TOP:
230 return std::string("Top"); 233 return string("Top");
231 case Layer::NORMAL: 234 case Layer::NORMAL:
232 return std::string("Normal"); 235 return string("Normal");
233 case Layer::BOTTOM: 236 case Layer::BOTTOM:
234 return std::string("Bottom"); 237 return string("Bottom");
235 case Layer::DESKTOP: 238 case Layer::DESKTOP:
236 return std::string("Desktop"); 239 return string("Desktop");
237 default: 240 default:
238 char tmpstr[128]; 241 char tmpstr[128];
239 sprintf(tmpstr, "%d", m_value.getNum()); 242 sprintf(tmpstr, "%d", m_value.getNum());
240 return std::string(tmpstr); 243 return string(tmpstr);
241 } 244 }
242} 245}
243 246
244template<> 247template<>
245void FbTk::Resource<long>:: 248void FbTk::Resource<long>::
246setFromString(const char *strval) { 249setFromString(const char *strval) {
247 if (sscanf(strval, "%ld", &m_value) != 1) 250 if (sscanf(strval, "%ld", &m_value) != 1)
248 setDefaultValue(); 251 setDefaultValue();
249} 252}
250 253
251template<> 254template<>
252string FbTk::Resource<long>:: 255string FbTk::Resource<long>::
253getString() const { 256getString() const {