From 0b2e002d4f281edfef0e6c036cf58d9fdb7ae978 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 12 May 2008 09:00:02 -0700 Subject: use AutoReloadHelper in apps file, check for changes automatically --- ChangeLog | 3 +++ src/Remember.cc | 28 ++++++++++++++-------------- src/Remember.hh | 6 ++++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 690212b..e441093 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ (Format: Year/Month/Day) Changes for 1.1 +*08/05/12: + * Modifying the apps file no longer requires a reconfigure (Mark) + Remember.cc/hh *08/05/09: * Made tooltip in toolbar update when the title changes (Henrik) Tooltip.cc/hh, Screen.cc/cc, OSDWindow.hh diff --git a/src/Remember.cc b/src/Remember.cc index 8e133b8..825a070 100644 --- a/src/Remember.cc +++ b/src/Remember.cc @@ -281,14 +281,14 @@ void Application::reset() { Remember *Remember::s_instance = 0; Remember::Remember(): - m_pats(new Patterns()), - m_last_timestamp(0) -{ + m_pats(new Patterns()) { if (s_instance != 0) throw string("Can not create more than one instance of Remember"); s_instance = this; enableUpdate(); + + m_reloader.setReloadCmd(FbTk::RefCount >(new FbTk::SimpleCommand(*this, &Remember::reload))); reconfigure(); } @@ -579,11 +579,12 @@ Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlis void Remember::reconfigure() { - string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); + m_reloader.setMainFile(Fluxbox::instance()->getAppsFilename()); + m_reloader.checkReload(); +} - time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); - if (m_last_timestamp > 0 && m_last_timestamp == timestamp) - return; +void Remember::reload() { + string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); #ifdef DEBUG cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["< 0) - m_last_timestamp = timestamp; - + // update timestamp to avoid unnecessary reload + m_reloader.addFile(Fluxbox::instance()->getAppsFilename()); } bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { @@ -1216,6 +1213,9 @@ void Remember::setupClient(WinClient &winclient) { if (winclient.screen().isRestart()) return; + // check if apps file has changed + reconfigure(); + Application *app = find(winclient); if (app == 0) return; // nothing to do diff --git a/src/Remember.hh b/src/Remember.hh index 4ab8f2a..107f1d2 100644 --- a/src/Remember.hh +++ b/src/Remember.hh @@ -29,6 +29,7 @@ #include "AtomHandler.hh" #include "ClientPattern.hh" +#include "FbTk/AutoReloadHelper.hh" #include "FbTk/RefCount.hh" #include @@ -223,7 +224,8 @@ public: Application* add(WinClient &winclient); FluxboxWindow* findGroup(Application *, BScreen &screen); - void reconfigure(); // was load + void reconfigure(); + void reload(); void save(); bool isRemembered(WinClient &win, Attribute attrib); @@ -277,7 +279,7 @@ private: Startups m_startups; static Remember *s_instance; - time_t m_last_timestamp; + FbTk::AutoReloadHelper m_reloader; }; #endif // REMEMBER_HH -- cgit v0.11.2