aboutsummaryrefslogtreecommitdiff
path: root/src/Layer.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2009-10-01 06:57:31 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2009-10-01 06:57:31 (GMT)
commitc4c96ec830f7e22c5f5183886de1f399333f60cd (patch)
tree3ded4864f71f3f092697268ea879e73b8dc978e7 /src/Layer.hh
parent710ad1d4568239bbb1c19e82d764215b492d94db (diff)
downloadfluxbox-c4c96ec830f7e22c5f5183886de1f399333f60cd.zip
fluxbox-c4c96ec830f7e22c5f5183886de1f399333f60cd.tar.bz2
simpler code
Diffstat (limited to 'src/Layer.hh')
-rw-r--r--src/Layer.hh50
1 files changed, 20 insertions, 30 deletions
diff --git a/src/Layer.hh b/src/Layer.hh
index da8f04c..14054b0 100644
--- a/src/Layer.hh
+++ b/src/Layer.hh
@@ -22,16 +22,7 @@
22#ifndef LAYER_HH 22#ifndef LAYER_HH
23#define LAYER_HH 23#define LAYER_HH
24 24
25#include <string> 25#include "FbTk/StringUtil.hh"
26#include <cstdio>
27
28#ifdef HAVE_CSTRING
29 #include <cstring>
30#else
31 #include <string.h>
32#endif
33
34using std::string;
35 26
36/** 27/**
37 * (This is not the layer->raise/lower handling stuff, @see FbTk::Layer) 28 * (This is not the layer->raise/lower handling stuff, @see FbTk::Layer)
@@ -54,52 +45,51 @@ public:
54 45
55 explicit Layer(int i) : m_num(i) {}; 46 explicit Layer(int i) : m_num(i) {};
56 47
57 static int getNumFromString(const string &str) { 48 static int getNumFromString(const std::string &str) {
58 int tempnum = 0; 49 int tempnum = 0;
50 std::string v = FbTk::StringUtil::toLower(str);
59 if (sscanf(str.c_str(), "%d", &tempnum) == 1) 51 if (sscanf(str.c_str(), "%d", &tempnum) == 1)
60 return tempnum; 52 return tempnum;
61 if (strcasecmp(str.c_str(), "Menu") == 0) 53 if (v == "menu")
62 return ::Layer::MENU; 54 return ::Layer::MENU;
63 if (strcasecmp(str.c_str(), "AboveDock") == 0) 55 if (v == "abovedock")
64 return ::Layer::ABOVE_DOCK; 56 return ::Layer::ABOVE_DOCK;
65 if (strcasecmp(str.c_str(), "Dock") == 0) 57 if (v == "dock")
66 return ::Layer::DOCK; 58 return ::Layer::DOCK;
67 if (strcasecmp(str.c_str(), "Top") == 0) 59 if (v == "top")
68 return ::Layer::TOP; 60 return ::Layer::TOP;
69 if (strcasecmp(str.c_str(), "Normal") == 0) 61 if (v == "normal")
70 return ::Layer::NORMAL; 62 return ::Layer::NORMAL;
71 if (strcasecmp(str.c_str(), "Bottom") == 0) 63 if (v == "bottom")
72 return ::Layer::BOTTOM; 64 return ::Layer::BOTTOM;
73 if (strcasecmp(str.c_str(), "Desktop") == 0) 65 if (v == "desktop")
74 return ::Layer::DESKTOP; 66 return ::Layer::DESKTOP;
75 return -1; 67 return -1;
76 } 68 }
77 69
78 static string getString(int num) { 70 static std::string getString(int num) {
79 switch (num) { 71 switch (num) {
80 case ::Layer::MENU: 72 case ::Layer::MENU:
81 return string("Menu"); 73 return std::string("Menu");
82 case ::Layer::ABOVE_DOCK: 74 case ::Layer::ABOVE_DOCK:
83 return string("AboveDock"); 75 return std::string("AboveDock");
84 case ::Layer::DOCK: 76 case ::Layer::DOCK:
85 return string("Dock"); 77 return std::string("Dock");
86 case ::Layer::TOP: 78 case ::Layer::TOP:
87 return string("Top"); 79 return std::string("Top");
88 case ::Layer::NORMAL: 80 case ::Layer::NORMAL:
89 return string("Normal"); 81 return std::string("Normal");
90 case ::Layer::BOTTOM: 82 case ::Layer::BOTTOM:
91 return string("Bottom"); 83 return std::string("Bottom");
92 case ::Layer::DESKTOP: 84 case ::Layer::DESKTOP:
93 return string("Desktop"); 85 return std::string("Desktop");
94 default: 86 default:
95 char tmpstr[128]; 87 return FbTk::StringUtil::number2String(num);
96 sprintf(tmpstr, "%d", num);
97 return string(tmpstr);
98 } 88 }
99 } 89 }
100 90
101 int getNum() const { return m_num; } 91 int getNum() const { return m_num; }
102 string getString() const { return getString(m_num); } 92 std::string getString() const { return getString(m_num); }
103 93
104 Layer &operator=(int num) { m_num = num; return *this; } 94 Layer &operator=(int num) { m_num = num; return *this; }
105 95