fix ~ to work properly in session.menuFile

This commit is contained in:
rathnor 2003-08-10 12:50:04 +00:00
parent babf480280
commit c8c5072fd1
5 changed files with 17 additions and 19 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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.

View file

@ -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);

View file

@ -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<Fluxbox::Titlebar>& 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; }