aboutsummaryrefslogtreecommitdiff
path: root/src/IconbarTool.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-11 11:00:45 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-16 23:49:23 (GMT)
commiteb0eef14134ee667c60f75f53de4e24950f3c117 (patch)
tree58b35842e1f84666373478bca3386be037a7a019 /src/IconbarTool.cc
parent3b7c1a3c220b7ccec0dee7804d36dabfe81449c4 (diff)
downloadfluxbox_pavel-eb0eef14134ee667c60f75f53de4e24950f3c117.zip
fluxbox_pavel-eb0eef14134ee667c60f75f53de4e24950f3c117.tar.bz2
Simplify FbTk::Resource template class
by outsourcing the conversion from string/lua to the specific type (and back) to a separate class. This change touches a lot of files because the interface of FbTk::Resource changed slightly. However, the changes are minor.
Diffstat (limited to 'src/IconbarTool.cc')
-rw-r--r--src/IconbarTool.cc45
1 files changed, 6 insertions, 39 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 0f3aeb7..1452080 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -68,45 +68,12 @@ using std::endl;
68namespace FbTk { 68namespace FbTk {
69 69
70template<> 70template<>
71void FbTk::Resource<FbTk::Container::Alignment>::setDefaultValue() { 71const EnumTraits<Container::Alignment>::Pair EnumTraits<Container::Alignment>::s_map[] = {
72 m_value = FbTk::Container::RELATIVE; 72 { "Left", Container::LEFT },
73} 73 { "Right", Container::RIGHT },
74 74 { "Relative", Container::RELATIVE },
75template<> 75 { NULL, Container::RELATIVE }
76string FbTk::Resource<FbTk::Container::Alignment>::getString() const { 76};
77 if (m_value == FbTk::Container::LEFT)
78 return string("Left");
79 if (m_value == FbTk::Container::RIGHT)
80 return string("Right");
81 return string("Relative");
82}
83
84template<>
85void FbTk::Resource<FbTk::Container::Alignment>::setFromString(const char *str) {
86 if (strcasecmp(str, "Left") == 0)
87 m_value = FbTk::Container::LEFT;
88 else if (strcasecmp(str, "Right") == 0)
89 m_value = FbTk::Container::RIGHT;
90 else if (strcasecmp(str, "Relative") == 0)
91 m_value = FbTk::Container::RELATIVE;
92 else
93 setDefaultValue();
94}
95
96template<>
97void FbTk::Resource<FbTk::Container::Alignment>::setFromLua(lua::state &l) {
98 lua::stack_sentry s(l, -1);
99 if(l.isstring(-1))
100 setFromString(l.tostring(-1).c_str());
101 else
102 setDefaultValue();
103 l.pop();
104}
105
106template<>
107void FbTk::Resource<FbTk::Container::Alignment>::pushToLua(lua::state &l) const {
108 l.pushstring(getString());
109}
110 77
111} // end namespace FbTk 78} // end namespace FbTk
112 79