all repos — fluxbox @ 0b2e002d4f281edfef0e6c036cf58d9fdb7ae978

custom fork of the fluxbox windowmanager

use AutoReloadHelper in apps file, check for changes automatically
Mark Tiefenbruck mark@fluxbox.org
commit

0b2e002d4f281edfef0e6c036cf58d9fdb7ae978

parent

93b0c5322a7482d83e38657b36e9814f8415e47b

3 files changed, 21 insertions(+), 16 deletions(-)

jump to
M ChangeLogChangeLog

@@ -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
M src/Remember.ccsrc/Remember.cc

@@ -281,14 +281,14 @@

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<FbTk::Command<void> >(new FbTk::SimpleCommand<Remember>(*this, &Remember::reload))); reconfigure(); }

@@ -579,11 +579,12 @@ }

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 ["<<apps_string<<"]"<<endl;

@@ -598,7 +599,6 @@ m_pats.reset(new Patterns());

m_startups.clear(); if (!apps_file.fail()) { - m_last_timestamp = timestamp; if (!apps_file.eof()) { string line; int row = 0;

@@ -687,7 +687,7 @@ cerr<<__FILE__<<"("<<__FUNCTION__<< ") Empty apps file" << endl;

#endif } } else { - cerr << "apps file failure" << endl; + cerr << "failed to open apps file" << endl; } // Clean up old state

@@ -895,11 +895,8 @@ }

apps_file << "[end]" << endl; } apps_file.close(); - - time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); - if (timestamp > 0) - m_last_timestamp = timestamp; - + // update timestamp to avoid unnecessary reload + m_reloader.addFile(Fluxbox::instance()->getAppsFilename()); } bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {

@@ -1215,6 +1212,9 @@

// leave windows alone on restart if (winclient.screen().isRestart()) return; + + // check if apps file has changed + reconfigure(); Application *app = find(winclient); if (app == 0)
M src/Remember.hhsrc/Remember.hh

@@ -29,6 +29,7 @@

#include "AtomHandler.hh" #include "ClientPattern.hh" +#include "FbTk/AutoReloadHelper.hh" #include "FbTk/RefCount.hh" #include <fstream>

@@ -223,7 +224,8 @@ Application* find(WinClient &winclient);

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

Startups m_startups; static Remember *s_instance; - time_t m_last_timestamp; + FbTk::AutoReloadHelper m_reloader; }; #endif // REMEMBER_HH