From dfb2ab0e213d63d9c704e710afc641584daec27d Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 12 Sep 2004 14:01:41 +0000 Subject: cleaning, moved resource functions to Resources.cc --- src/Makefile.am | 1 + 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 \ FocusModelMenuItem.hh \ ToggleMenu.hh \ HeadArea.hh HeadArea.cc \ + Resources.cc \ ${newwmspec_SOURCE} ${gnome_SOURCE} \ ${REMEMBER_SOURCE} ${REGEXP_SOURCE} ${TOOLBAR_SOURCE} 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.255 2004/09/11 20:29:29 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.256 2004/09/12 14:01:29 fluxgen Exp $ #include "fluxbox.hh" @@ -150,224 +150,6 @@ class Toolbar { }; using namespace std; using namespace FbTk; -//----------------------------------------------------------------- -//---- accessors for int, bool, and some enums with Resource ------ -//----------------------------------------------------------------- - -template<> -void FbTk::Resource:: -setFromString(const char* strval) { - int val; - if (sscanf(strval, "%d", &val)==1) - *this = val; -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - *this = strval; -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - *this = (bool)!strcasecmp(strval, "true"); -} - -template<> -void FbTk::Resource:: -setFromString(char const *strval) { - vector val; - StringUtil::stringtok(val, strval); - int size=val.size(); - //clear old values - m_value.clear(); - - for (int i=0; i -void FbTk::Resource:: -setFromString(char const *strval) { - if (strcasecmp(strval, "Titlebar")==0) - m_value= Fluxbox::ATTACH_AREA_TITLEBAR; - else - m_value= Fluxbox::ATTACH_AREA_WINDOW; -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%ul", &m_value) != 1) - setDefaultValue(); -} - - -//----------------------------------------------------------------- -//---- manipulators for int, bool, and some enums with Resource --- -//----------------------------------------------------------------- -template<> -std::string FbTk::Resource:: -getString() { - return std::string(**this == true ? "true" : "false"); -} - -template<> -std::string FbTk::Resource:: -getString() { - char strval[256]; - sprintf(strval, "%d", **this); - return std::string(strval); -} - -template<> -std::string FbTk::Resource:: -getString() { return **this; } - - -template<> -std::string FbTk::Resource:: -getString() { - string retval; - int size=m_value.size(); - for (int i=0; i -std::string FbTk::Resource:: -getString() { - if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) - return "Titlebar"; - else - return "Window"; -} - -template<> -string FbTk::Resource:: -getString() { - char tmpstr[128]; - sprintf(tmpstr, "%ul", m_value); - return string(tmpstr); -} - -template<> -string FbTk::Resource:: -getString() { - char tmpstr[128]; - sprintf(tmpstr, "%ul", m_value); - return string(tmpstr); -} - -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - int tempnum = 0; - if (sscanf(strval, "%d", &tempnum) == 1) - m_value = tempnum; - else if (strcasecmp(strval, "Menu") == 0) - m_value = Fluxbox::instance()->getMenuLayer(); - else if (strcasecmp(strval, "AboveDock") == 0) - m_value = Fluxbox::instance()->getAboveDockLayer(); - else if (strcasecmp(strval, "Dock") == 0) - m_value = Fluxbox::instance()->getDockLayer(); - else if (strcasecmp(strval, "Top") == 0) - m_value = Fluxbox::instance()->getTopLayer(); - else if (strcasecmp(strval, "Normal") == 0) - m_value = Fluxbox::instance()->getNormalLayer(); - else if (strcasecmp(strval, "Bottom") == 0) - m_value = Fluxbox::instance()->getBottomLayer(); - else if (strcasecmp(strval, "Desktop") == 0) - m_value = Fluxbox::instance()->getDesktopLayer(); - else - setDefaultValue(); -} - - -template<> -string FbTk::Resource:: -getString() { - - if (m_value.getNum() == Fluxbox::instance()->getMenuLayer()) - return string("Menu"); - else if (m_value.getNum() == Fluxbox::instance()->getAboveDockLayer()) - return string("AboveDock"); - else if (m_value.getNum() == Fluxbox::instance()->getDockLayer()) - return string("Dock"); - else if (m_value.getNum() == Fluxbox::instance()->getTopLayer()) - return string("Top"); - else if (m_value.getNum() == Fluxbox::instance()->getNormalLayer()) - return string("Normal"); - else if (m_value.getNum() == Fluxbox::instance()->getBottomLayer()) - return string("Bottom"); - else if (m_value.getNum() == Fluxbox::instance()->getDesktopLayer()) - return string("Desktop"); - else { - char tmpstr[128]; - sprintf(tmpstr, "%d", m_value.getNum()); - return string(tmpstr); - } -} -template<> -void FbTk::Resource:: -setFromString(const char *strval) { - if (sscanf(strval, "%ld", &m_value) != 1) - setDefaultValue(); -} - -template<> -string FbTk::Resource:: -getString() { - char tmpstr[128]; - sprintf(tmpstr, "%ld", m_value); - return string(tmpstr); -} - static Window last_bad_window = None; namespace { void copyFile(const std::string &from, const std::string &to) { @@ -1097,11 +879,11 @@ void Fluxbox::handleButtonEvent(XButtonEvent &be) { if (be.button == 1) { if (! screen->isRootColormapInstalled()) screen->imageControl().installRootColormap(); - - if (screen->getWorkspacemenu().isVisible()) - screen->getWorkspacemenu().hide(); + // hide menus if (screen->getRootmenu().isVisible()) screen->getRootmenu().hide(); + if (screen->getWorkspacemenu().isVisible()) + screen->getWorkspacemenu().hide(); } else if (be.button == 2) { FbCommands::ShowWorkspaceMenuCmd cmd; @@ -1248,7 +1030,7 @@ void Fluxbox::handleKeyEvent(XKeyEvent &ke) { switch (ke.type) { case KeyPress: m_key->doAction(ke); - break; + break; case KeyRelease: { // we ignore most key releases unless we need to use // a release to stop something (e.g. window cycling). -- cgit v0.11.2