diff options
author | fluxgen <fluxgen> | 2004-09-12 14:01:41 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-09-12 14:01:41 (GMT) |
commit | dfb2ab0e213d63d9c704e710afc641584daec27d (patch) | |
tree | 798a729de7d012e03b701972ba83b36c21762835 | |
parent | 2fef25747f1010ad965ddb2a483da9a94732b530 (diff) | |
download | fluxbox-dfb2ab0e213d63d9c704e710afc641584daec27d.zip fluxbox-dfb2ab0e213d63d9c704e710afc641584daec27d.tar.bz2 |
cleaning, moved resource functions to Resources.cc
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/fluxbox.cc | 228 |
2 files changed, 6 insertions, 223 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 8f8b950..476f6ae 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -114,6 +114,7 @@ fluxbox_SOURCES = AtomHandler.hh ArrowButton.hh ArrowButton.cc \ | |||
114 | FocusModelMenuItem.hh \ | 114 | FocusModelMenuItem.hh \ |
115 | ToggleMenu.hh \ | 115 | ToggleMenu.hh \ |
116 | HeadArea.hh HeadArea.cc \ | 116 | HeadArea.hh HeadArea.cc \ |
117 | Resources.cc \ | ||
117 | ${newwmspec_SOURCE} ${gnome_SOURCE} \ | 118 | ${newwmspec_SOURCE} ${gnome_SOURCE} \ |
118 | ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} | 119 | ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} |
119 | 120 | ||
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index b973227..c7828ac 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: fluxbox.cc,v 1.255 2004/09/11 20:29:29 fluxgen Exp $ | 25 | // $Id: fluxbox.cc,v 1.256 2004/09/12 14:01:29 fluxgen Exp $ |
26 | 26 | ||
27 | #include "fluxbox.hh" | 27 | #include "fluxbox.hh" |
28 | 28 | ||
@@ -150,224 +150,6 @@ class Toolbar { }; | |||
150 | using namespace std; | 150 | using namespace std; |
151 | using namespace FbTk; | 151 | using namespace FbTk; |
152 | 152 | ||
153 | //----------------------------------------------------------------- | ||
154 | //---- accessors for int, bool, and some enums with Resource ------ | ||
155 | //----------------------------------------------------------------- | ||
156 | |||
157 | template<> | ||
158 | void FbTk::Resource<int>:: | ||
159 | setFromString(const char* strval) { | ||
160 | int val; | ||
161 | if (sscanf(strval, "%d", &val)==1) | ||
162 | *this = val; | ||
163 | } | ||
164 | |||
165 | template<> | ||
166 | void FbTk::Resource<std::string>:: | ||
167 | setFromString(const char *strval) { | ||
168 | *this = strval; | ||
169 | } | ||
170 | |||
171 | template<> | ||
172 | void FbTk::Resource<bool>:: | ||
173 | setFromString(char const *strval) { | ||
174 | *this = (bool)!strcasecmp(strval, "true"); | ||
175 | } | ||
176 | |||
177 | template<> | ||
178 | void FbTk::Resource<Fluxbox::TitlebarList>:: | ||
179 | setFromString(char const *strval) { | ||
180 | vector<std::string> val; | ||
181 | StringUtil::stringtok(val, strval); | ||
182 | int size=val.size(); | ||
183 | //clear old values | ||
184 | m_value.clear(); | ||
185 | |||
186 | for (int i=0; i<size; i++) { | ||
187 | if (strcasecmp(val[i].c_str(), "Maximize")==0) | ||
188 | m_value.push_back(Fluxbox::MAXIMIZE); | ||
189 | else if (strcasecmp(val[i].c_str(), "Minimize")==0) | ||
190 | m_value.push_back(Fluxbox::MINIMIZE); | ||
191 | else if (strcasecmp(val[i].c_str(), "Shade")==0) | ||
192 | m_value.push_back(Fluxbox::SHADE); | ||
193 | else if (strcasecmp(val[i].c_str(), "Stick")==0) | ||
194 | m_value.push_back(Fluxbox::STICK); | ||
195 | else if (strcasecmp(val[i].c_str(), "Menu")==0) | ||
196 | m_value.push_back(Fluxbox::MENU); | ||
197 | else if (strcasecmp(val[i].c_str(), "Close")==0) | ||
198 | m_value.push_back(Fluxbox::CLOSE); | ||
199 | } | ||
200 | } | ||
201 | |||
202 | template<> | ||
203 | void FbTk::Resource<Fluxbox::TabsAttachArea>:: | ||
204 | setFromString(char const *strval) { | ||
205 | if (strcasecmp(strval, "Titlebar")==0) | ||
206 | m_value= Fluxbox::ATTACH_AREA_TITLEBAR; | ||
207 | else | ||
208 | m_value= Fluxbox::ATTACH_AREA_WINDOW; | ||
209 | } | ||
210 | |||
211 | template<> | ||
212 | void FbTk::Resource<unsigned int>:: | ||
213 | setFromString(const char *strval) { | ||
214 | if (sscanf(strval, "%ul", &m_value) != 1) | ||
215 | setDefaultValue(); | ||
216 | } | ||
217 | |||
218 | template<> | ||
219 | void FbTk::Resource<long long>:: | ||
220 | setFromString(const char *strval) { | ||
221 | if (sscanf(strval, "%ul", &m_value) != 1) | ||
222 | setDefaultValue(); | ||
223 | } | ||
224 | |||
225 | |||
226 | //----------------------------------------------------------------- | ||
227 | //---- manipulators for int, bool, and some enums with Resource --- | ||
228 | //----------------------------------------------------------------- | ||
229 | template<> | ||
230 | std::string FbTk::Resource<bool>:: | ||
231 | getString() { | ||
232 | return std::string(**this == true ? "true" : "false"); | ||
233 | } | ||
234 | |||
235 | template<> | ||
236 | std::string FbTk::Resource<int>:: | ||
237 | getString() { | ||
238 | char strval[256]; | ||
239 | sprintf(strval, "%d", **this); | ||
240 | return std::string(strval); | ||
241 | } | ||
242 | |||
243 | template<> | ||
244 | std::string FbTk::Resource<std::string>:: | ||
245 | getString() { return **this; } | ||
246 | |||
247 | |||
248 | template<> | ||
249 | std::string FbTk::Resource<Fluxbox::TitlebarList>:: | ||
250 | getString() { | ||
251 | string retval; | ||
252 | int size=m_value.size(); | ||
253 | for (int i=0; i<size; i++) { | ||
254 | switch (m_value[i]) { | ||
255 | case Fluxbox::SHADE: | ||
256 | retval.append("Shade"); | ||
257 | break; | ||
258 | case Fluxbox::MINIMIZE: | ||
259 | retval.append("Minimize"); | ||
260 | break; | ||
261 | case Fluxbox::MAXIMIZE: | ||
262 | retval.append("Maximize"); | ||
263 | break; | ||
264 | case Fluxbox::CLOSE: | ||
265 | retval.append("Close"); | ||
266 | break; | ||
267 | case Fluxbox::STICK: | ||
268 | retval.append("Stick"); | ||
269 | break; | ||
270 | case Fluxbox::MENU: | ||
271 | retval.append("Menu"); | ||
272 | break; | ||
273 | default: | ||
274 | break; | ||
275 | } | ||
276 | retval.append(" "); | ||
277 | } | ||
278 | |||
279 | return retval; | ||
280 | } | ||
281 | |||
282 | template<> | ||
283 | std::string FbTk::Resource<Fluxbox::TabsAttachArea>:: | ||
284 | getString() { | ||
285 | if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) | ||
286 | return "Titlebar"; | ||
287 | else | ||
288 | return "Window"; | ||
289 | } | ||
290 | |||
291 | template<> | ||
292 | string FbTk::Resource<unsigned int>:: | ||
293 | getString() { | ||
294 | char tmpstr[128]; | ||
295 | sprintf(tmpstr, "%ul", m_value); | ||
296 | return string(tmpstr); | ||
297 | } | ||
298 | |||
299 | template<> | ||
300 | string FbTk::Resource<long long>:: | ||
301 | getString() { | ||
302 | char tmpstr[128]; | ||
303 | sprintf(tmpstr, "%ul", m_value); | ||
304 | return string(tmpstr); | ||
305 | } | ||
306 | |||
307 | template<> | ||
308 | void FbTk::Resource<Fluxbox::Layer>:: | ||
309 | setFromString(const char *strval) { | ||
310 | int tempnum = 0; | ||
311 | if (sscanf(strval, "%d", &tempnum) == 1) | ||
312 | m_value = tempnum; | ||
313 | else if (strcasecmp(strval, "Menu") == 0) | ||
314 | m_value = Fluxbox::instance()->getMenuLayer(); | ||
315 | else if (strcasecmp(strval, "AboveDock") == 0) | ||
316 | m_value = Fluxbox::instance()->getAboveDockLayer(); | ||
317 | else if (strcasecmp(strval, "Dock") == 0) | ||
318 | m_value = Fluxbox::instance()->getDockLayer(); | ||
319 | else if (strcasecmp(strval, "Top") == 0) | ||
320 | m_value = Fluxbox::instance()->getTopLayer(); | ||
321 | else if (strcasecmp(strval, "Normal") == 0) | ||
322 | m_value = Fluxbox::instance()->getNormalLayer(); | ||
323 | else if (strcasecmp(strval, "Bottom") == 0) | ||
324 | m_value = Fluxbox::instance()->getBottomLayer(); | ||
325 | else if (strcasecmp(strval, "Desktop") == 0) | ||
326 | m_value = Fluxbox::instance()->getDesktopLayer(); | ||
327 | else | ||
328 | setDefaultValue(); | ||
329 | } | ||
330 | |||
331 | |||
332 | template<> | ||
333 | string FbTk::Resource<Fluxbox::Layer>:: | ||
334 | getString() { | ||
335 | |||
336 | if (m_value.getNum() == Fluxbox::instance()->getMenuLayer()) | ||
337 | return string("Menu"); | ||
338 | else if (m_value.getNum() == Fluxbox::instance()->getAboveDockLayer()) | ||
339 | return string("AboveDock"); | ||
340 | else if (m_value.getNum() == Fluxbox::instance()->getDockLayer()) | ||
341 | return string("Dock"); | ||
342 | else if (m_value.getNum() == Fluxbox::instance()->getTopLayer()) | ||
343 | return string("Top"); | ||
344 | else if (m_value.getNum() == Fluxbox::instance()->getNormalLayer()) | ||
345 | return string("Normal"); | ||
346 | else if (m_value.getNum() == Fluxbox::instance()->getBottomLayer()) | ||
347 | return string("Bottom"); | ||
348 | else if (m_value.getNum() == Fluxbox::instance()->getDesktopLayer()) | ||
349 | return string("Desktop"); | ||
350 | else { | ||
351 | char tmpstr[128]; | ||
352 | sprintf(tmpstr, "%d", m_value.getNum()); | ||
353 | return string(tmpstr); | ||
354 | } | ||
355 | } | ||
356 | template<> | ||
357 | void FbTk::Resource<long>:: | ||
358 | setFromString(const char *strval) { | ||
359 | if (sscanf(strval, "%ld", &m_value) != 1) | ||
360 | setDefaultValue(); | ||
361 | } | ||
362 | |||
363 | template<> | ||
364 | string FbTk::Resource<long>:: | ||
365 | getString() { | ||
366 | char tmpstr[128]; | ||
367 | sprintf(tmpstr, "%ld", m_value); | ||
368 | return string(tmpstr); | ||
369 | } | ||
370 | |||
371 | static Window last_bad_window = None; | 153 | static Window last_bad_window = None; |
372 | namespace { | 154 | namespace { |
373 | void copyFile(const std::string &from, const std::string &to) { | 155 | void copyFile(const std::string &from, const std::string &to) { |
@@ -1097,11 +879,11 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { | |||
1097 | if (be.button == 1) { | 879 | if (be.button == 1) { |
1098 | if (! screen->isRootColormapInstalled()) | 880 | if (! screen->isRootColormapInstalled()) |
1099 | screen->imageControl().installRootColormap(); | 881 | screen->imageControl().installRootColormap(); |
1100 | 882 | // hide menus | |
1101 | if (screen->getWorkspacemenu().isVisible()) | ||
1102 | screen->getWorkspacemenu().hide(); | ||
1103 | if (screen->getRootmenu().isVisible()) | 883 | if (screen->getRootmenu().isVisible()) |
1104 | screen->getRootmenu().hide(); | 884 | screen->getRootmenu().hide(); |
885 | if (screen->getWorkspacemenu().isVisible()) | ||
886 | screen->getWorkspacemenu().hide(); | ||
1105 | 887 | ||
1106 | } else if (be.button == 2) { | 888 | } else if (be.button == 2) { |
1107 | FbCommands::ShowWorkspaceMenuCmd cmd; | 889 | FbCommands::ShowWorkspaceMenuCmd cmd; |
@@ -1248,7 +1030,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { | |||
1248 | switch (ke.type) { | 1030 | switch (ke.type) { |
1249 | case KeyPress: | 1031 | case KeyPress: |
1250 | m_key->doAction(ke); | 1032 | m_key->doAction(ke); |
1251 | break; | 1033 | break; |
1252 | case KeyRelease: { | 1034 | case KeyRelease: { |
1253 | // we ignore most key releases unless we need to use | 1035 | // we ignore most key releases unless we need to use |
1254 | // a release to stop something (e.g. window cycling). | 1036 | // a release to stop something (e.g. window cycling). |