From c8c5072fd1a542cc3783cb5b32e5e4b68e45efe7 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sun, 10 Aug 2003 12:50:04 +0000 Subject: fix ~ to work properly in session.menuFile --- ChangeLog | 3 +++ src/FbTk/StringUtil.cc | 5 ++--- src/Screen.cc | 15 ++++++++------- src/fluxbox.cc | 9 ++------- src/fluxbox.hh | 4 ++-- 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a4a8d2..7201b26 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 0.9.5: +*03/08/10: + * Fix session.menuFile to work with ~ properly (Simon) + fluxbox.hh/cc Screen.cc *03/08/07: * Updated fluxbox-generate_menu (Thanks Han) Test before warning, browser details, minor indent issues diff --git a/src/FbTk/StringUtil.cc b/src/FbTk/StringUtil.cc index 761014f..8532662 100644 --- a/src/FbTk/StringUtil.cc +++ b/src/FbTk/StringUtil.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: StringUtil.cc,v 1.3 2003/07/01 01:49:13 rathnor Exp $ +// $Id: StringUtil.cc,v 1.4 2003/08/10 12:50:04 rathnor Exp $ #include "StringUtil.hh" @@ -73,7 +73,6 @@ const char *strcasestr(const char *str, const char *ptn) { returns expanded filename */ string expandFilename(const std::string &filename) { - string retval; size_t pos = filename.find_first_not_of(" \t"); if (pos != std::string::npos && filename[pos] == '~') { @@ -84,7 +83,7 @@ string expandFilename(const std::string &filename) { } } else return filename; //return unmodified value - + return retval; } diff --git a/src/Screen.cc b/src/Screen.cc index 0ec1655..593dd69 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.212 2003/08/04 12:50:06 fluxgen Exp $ +// $Id: Screen.cc,v 1.213 2003/08/10 12:50:04 rathnor Exp $ #include "Screen.hh" @@ -1612,8 +1612,10 @@ void BScreen::initMenu() { bool defaultMenu = true; Fluxbox * const fb = Fluxbox::instance(); - if (fb->getMenuFilename()) { - ifstream menu_file(fb->getMenuFilename()); + if (fb->getMenuFilename().size() > 0) { + std::string menufilestr = fb->getMenuFilename(); + menufilestr = FbTk::StringUtil::expandFilename(menufilestr); + ifstream menu_file(menufilestr.c_str()); if (!menu_file.fail()) { if (! menu_file.eof()) { @@ -1650,11 +1652,11 @@ void BScreen::initMenu() { i18n->getMessage( FBNLS::ScreenSet, FBNLS::ScreenEmptyMenuFile, "%s: Empty menu file"), - fb->getMenuFilename()); + menufilestr.c_str()); } menu_file.close(); } else - perror(fb->getMenuFilename()); + perror(menufilestr.c_str()); } if (defaultMenu) { @@ -1674,8 +1676,7 @@ void BScreen::initMenu() { FBNLS::ScreenSet, FBNLS::ScreenExit, "Exit"), exit_fb); - } else - fb->saveMenuFilename(fb->getMenuFilename()); + } } /// looks through a menufile and adds correct items to the root-menu. diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 342338c..f910e7b 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.178 2003/08/04 18:16:22 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.179 2003/08/10 12:50:04 rathnor Exp $ #include "fluxbox.hh" @@ -1625,13 +1625,8 @@ void Fluxbox::load_rc() { XrmValue value; char *value_type; - - if (m_rc_menufile->size()) { - *m_rc_menufile = StringUtil::expandFilename(*m_rc_menufile); - if (!m_rc_menufile->size()) + if (m_rc_menufile->size() == 0) m_rc_menufile.setDefaultValue(); - } else - m_rc_menufile.setDefaultValue(); if (m_rc_slitlistfile->size() != 0) { *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile); diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 4f32ea3..1d35f83 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.69 2003/07/28 15:06:36 rathnor Exp $ +// $Id: fluxbox.hh,v 1.70 2003/08/10 12:50:04 rathnor Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -113,7 +113,7 @@ public: inline const std::vector& getTitlebarLeft() const { return *m_rc_titlebar_left; } inline const std::string &getStyleFilename() const { return *m_rc_stylefile; } - inline const char *getMenuFilename() const { return m_rc_menufile->c_str(); } + inline const std::string &getMenuFilename() const { return *m_rc_menufile; } inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } inline int colorsPerChannel() const { return *m_rc_colors_per_channel; } inline int getNumberOfLayers() const { return *m_rc_numlayers; } -- cgit v0.11.2