fixed menu timestamps stuff
fluxgen fluxgen
2 files changed,
30 insertions(+),
23 deletions(-)
M
src/fluxbox.cc
→
src/fluxbox.cc
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ while (!m_atomhandler.empty()) {
delete m_atomhandler.back(); m_atomhandler.pop_back(); } - - std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = m_menu_timestamps.end(); - for (; it != it_end; ++it) - delete *it; - + + clearMenuFilenames(); } void Fluxbox::eventLoop() {@@ -2227,18 +2223,12 @@
if (old_blackboxrc) XrmDestroyDatabase(old_blackboxrc); - std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); - std::list<MenuTimestamp *>::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::checkMenu() { - bool reread = false; - std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); - std::list<MenuTimestamp *>::iterator it_end = m_menu_timestamps.end(); - for (; it != it_end && (! reread); ++it) { +bool Fluxbox::menuTimestampsChanged() const { + std::list<MenuTimestamp *>::const_iterator it = m_menu_timestamps.begin(); + std::list<MenuTimestamp *>::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::clearMenuFilenames() { + std::list<MenuTimestamp *>::iterator it = m_menu_timestamps.begin(); + std::list<MenuTimestamp *>::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)
M
src/fluxbox.hh
→
src/fluxbox.hh
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ void loadRootCommand(BScreen &scr);
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 @@ void removeGroupSearch(Window win);
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 @@ bool isStartup() const { return m_starting; }
enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; typedef std::vector<Fluxbox::Titlebar> TitlebarList; + /// @return whether the timestamps on the menu changed + bool menuTimestampsChanged() const; private: struct cursor {