From 2014d60ef394006ea916907226643200bbc86dc6 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 13 May 2003 00:20:49 +0000 Subject: fixed menu timestamps stuff --- src/fluxbox.cc | 47 +++++++++++++++++++++++++---------------------- src/fluxbox.hh | 6 +++++- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/fluxbox.cc b/src/fluxbox.cc index ab35aff..c26f766 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.142 2003/05/12 11:14:47 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.143 2003/05/13 00:20:49 fluxgen Exp $ #include "fluxbox.hh" @@ -559,12 +559,8 @@ Fluxbox::~Fluxbox() { delete m_atomhandler.back(); m_atomhandler.pop_back(); } - - std::list::iterator it = m_menu_timestamps.begin(); - std::list::iterator it_end = m_menu_timestamps.end(); - for (; it != it_end; ++it) - delete *it; - + + clearMenuFilenames(); } void Fluxbox::eventLoop() { @@ -2227,18 +2223,12 @@ void Fluxbox::real_reconfigure() { if (old_blackboxrc) XrmDestroyDatabase(old_blackboxrc); - std::list::iterator it = m_menu_timestamps.begin(); - std::list::iterator it_end = m_menu_timestamps.end(); - for (; it != it_end; ++it) - delete *it; - - m_menu_timestamps.erase(m_menu_timestamps.begin(), m_menu_timestamps.end()); ScreenList::iterator sit = m_screen_list.begin(); ScreenList::iterator sit_end = m_screen_list.end(); for (; sit != sit_end; ++sit) (*sit)->reconfigure(); - + //reconfigure keys m_key->reconfigure(StringUtil::expandFilename(*m_rc_keyfile).c_str()); @@ -2246,21 +2236,26 @@ void Fluxbox::real_reconfigure() { } -void Fluxbox::checkMenu() { - bool reread = false; - std::list::iterator it = m_menu_timestamps.begin(); - std::list::iterator it_end = m_menu_timestamps.end(); - for (; it != it_end && (! reread); ++it) { +bool Fluxbox::menuTimestampsChanged() const { + std::list::const_iterator it = m_menu_timestamps.begin(); + std::list::const_iterator it_end = m_menu_timestamps.end(); + for (; it != it_end; ++it) { struct stat buf; if (! stat((*it)->filename.c_str(), &buf)) { if ((*it)->timestamp != buf.st_ctime) - reread = true; + return true; } else - reread = true; + return true; } - if (reread) rereadMenu(); + // no timestamp changed + return false; +} + +void Fluxbox::checkMenu() { + if (menuTimestampsChanged()) + rereadMenu(); } @@ -2316,6 +2311,14 @@ void Fluxbox::saveMenuFilename(const char *filename) { } } +void Fluxbox::clearMenuFilenames() { + std::list::iterator it = m_menu_timestamps.begin(); + std::list::iterator it_end = m_menu_timestamps.end(); + for (; it != it_end; ++it) + delete *it; + + m_menu_timestamps.erase(m_menu_timestamps.begin(), m_menu_timestamps.end()); +} void Fluxbox::timeout() { if (m_reconfigure_wait) diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 503e55c..a3c4f81 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.57 2003/05/12 04:23:31 fluxgen Exp $ +// $Id: fluxbox.hh,v 1.58 2003/05/13 00:18:28 fluxgen Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH @@ -156,6 +156,7 @@ public: void loadTitlebar(); void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } void saveMenuFilename(const char *); + void clearMenuFilenames(); void saveTitlebarFilename(const char *); void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); } void saveWindowSearch(Window win, FluxboxWindow *fbwin); @@ -166,6 +167,7 @@ public: void restart(const char *command = 0); void reconfigure(); void rereadMenu(); + /// reloads the menus if the timestamps changed void checkMenu(); /// handle any system signal sent to the application @@ -185,6 +187,8 @@ public: enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; typedef std::vector TitlebarList; + /// @return whether the timestamps on the menu changed + bool menuTimestampsChanged() const; private: struct cursor { -- cgit v0.11.2