fixed menu timestamps stuff

This commit is contained in:
fluxgen 2003-05-13 00:20:49 +00:00
parent cffa01d79b
commit 2014d60ef3
2 changed files with 30 additions and 23 deletions

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.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"
@ -560,11 +560,7 @@ Fluxbox::~Fluxbox() {
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,12 +2223,6 @@ void Fluxbox::real_reconfigure() {
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();
@ -2246,21 +2236,26 @@ void Fluxbox::real_reconfigure() {
}
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::saveMenuFilename(const char *filename) {
}
}
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)

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.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<Fluxbox::Titlebar> TitlebarList;
/// @return whether the timestamps on the menu changed
bool menuTimestampsChanged() const;
private:
struct cursor {