aboutsummaryrefslogtreecommitdiff
path: root/src/FocusControl.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-11 11:00:45 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-06-15 23:12:25 (GMT)
commitcd9df3b8144c4c41f7b57f0075fbb98ef7561296 (patch)
tree10ffc1692e4afbcb2c74b9db8c8a44b434ef62ca /src/FocusControl.cc
parent787c7a994d4328a9c90a037dd464f8007351b0c0 (diff)
downloadfluxbox_pavel-cd9df3b8144c4c41f7b57f0075fbb98ef7561296.zip
fluxbox_pavel-cd9df3b8144c4c41f7b57f0075fbb98ef7561296.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/FocusControl.cc')
-rw-r--r--src/FocusControl.cc89
1 files changed, 11 insertions, 78 deletions
diff --git a/src/FocusControl.cc b/src/FocusControl.cc
index abedcf2..4f3b390 100644
--- a/src/FocusControl.cc
+++ b/src/FocusControl.cc
@@ -599,86 +599,19 @@ void FocusControl::setFocusedWindow(WinClient *client) {
599namespace FbTk { 599namespace FbTk {
600 600
601template<> 601template<>
602std::string FbTk::Resource<FocusControl::FocusModel>::getString() const { 602const EnumTraits<FocusControl::FocusModel>::Pair EnumTraits<FocusControl::FocusModel>::s_map[] = {
603 switch (m_value) { 603 { "MouseFocus", FocusControl::MOUSEFOCUS },
604 case FocusControl::MOUSEFOCUS: 604 { "StrictMouseFocus", FocusControl::STRICTMOUSEFOCUS },
605 return string("MouseFocus"); 605 { "ClickFocus", FocusControl::CLICKFOCUS },
606 case FocusControl::STRICTMOUSEFOCUS: 606 { NULL, FocusControl::CLICKFOCUS }
607 return string("StrictMouseFocus"); 607};
608 case FocusControl::CLICKFOCUS:
609 return string("ClickFocus");
610 }
611 // default string
612 return string("ClickFocus");
613}
614
615template<>
616void FbTk::Resource<FocusControl::FocusModel>::
617setFromString(char const *strval) {
618 if (strcasecmp(strval, "MouseFocus") == 0)
619 m_value = FocusControl::MOUSEFOCUS;
620 else if (strcasecmp(strval, "StrictMouseFocus") == 0)
621 m_value = FocusControl::STRICTMOUSEFOCUS;
622 else if (strcasecmp(strval, "ClickToFocus") == 0)
623 m_value = FocusControl::CLICKFOCUS;
624 else
625 setDefaultValue();
626}
627
628template<>
629void FbTk::Resource<FocusControl::FocusModel>::setFromLua(lua::state &l) {
630 lua::stack_sentry s(l, -1);
631 if(l.isstring(-1))
632 setFromString(l.tostring(-1).c_str());
633 else
634 setDefaultValue();
635 l.pop();
636}
637
638template<>
639void FbTk::Resource<FocusControl::FocusModel>::pushToLua(lua::state &l) const {
640 l.pushstring(getString());
641}
642
643 608
644template<> 609template<>
645std::string FbTk::Resource<FocusControl::TabFocusModel>::getString() const { 610const EnumTraits<FocusControl::TabFocusModel>::Pair EnumTraits<FocusControl::TabFocusModel>::s_map[] = {
646 switch (m_value) { 611 { "SloppyTabFocus", FocusControl::MOUSETABFOCUS },
647 case FocusControl::MOUSETABFOCUS: 612 { "ClickToTabFocus", FocusControl::CLICKTABFOCUS },
648 return string("SloppyTabFocus"); 613 { NULL, FocusControl::CLICKTABFOCUS }
649 case FocusControl::CLICKTABFOCUS: 614};
650 return string("ClickToTabFocus");
651 }
652 // default string
653 return string("ClickToTabFocus");
654}
655
656template<>
657void FbTk::Resource<FocusControl::TabFocusModel>::
658setFromString(char const *strval) {
659
660 if (strcasecmp(strval, "SloppyTabFocus") == 0 )
661 m_value = FocusControl::MOUSETABFOCUS;
662 else if (strcasecmp(strval, "ClickToTabFocus") == 0)
663 m_value = FocusControl::CLICKTABFOCUS;
664 else
665 setDefaultValue();
666}
667
668template<>
669void FbTk::Resource<FocusControl::TabFocusModel>::setFromLua(lua::state &l) {
670 lua::stack_sentry s(l, -1);
671 if(l.isstring(-1))
672 setFromString(l.tostring(-1).c_str());
673 else
674 setDefaultValue();
675 l.pop();
676}
677
678template<>
679void FbTk::Resource<FocusControl::TabFocusModel>::pushToLua(lua::state &l) const {
680 l.pushstring(getString());
681}
682 615
683} // end namespace FbTk 616} // end namespace FbTk
684 617