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>2011-11-01 09:52:46 (GMT)
commit8c208459910f1dddcfdeb00567b990eebfc218b8 (patch)
tree47c442f906124306a52e13641d28fc6cd1ac513e /src/IconbarTool.cc
parent60cd98604ae0ee62d64e3bc852898f69dae221d4 (diff)
downloadfluxbox_paul-8c208459910f1dddcfdeb00567b990eebfc218b8.zip
fluxbox_paul-8c208459910f1dddcfdeb00567b990eebfc218b8.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