use AutoReloadHelper in apps file, check for changes automatically
This commit is contained in:
parent
93b0c5322a
commit
0b2e002d4f
3 changed files with 21 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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<FbTk::Command<void> >(new FbTk::SimpleCommand<Remember>(*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 ["<<apps_string<<"]"<<endl;
|
||||
|
@ -598,7 +599,6 @@ void Remember::reconfigure() {
|
|||
m_startups.clear();
|
||||
|
||||
if (!apps_file.fail()) {
|
||||
m_last_timestamp = timestamp;
|
||||
if (!apps_file.eof()) {
|
||||
string line;
|
||||
int row = 0;
|
||||
|
@ -687,7 +687,7 @@ void Remember::reconfigure() {
|
|||
#endif
|
||||
}
|
||||
} else {
|
||||
cerr << "apps file failure" << endl;
|
||||
cerr << "failed to open apps file" << endl;
|
||||
}
|
||||
|
||||
// Clean up old state
|
||||
|
@ -895,11 +895,8 @@ void Remember::save() {
|
|||
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) {
|
||||
|
@ -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
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "AtomHandler.hh"
|
||||
#include "ClientPattern.hh"
|
||||
|
||||
#include "FbTk/AutoReloadHelper.hh"
|
||||
#include "FbTk/RefCount.hh"
|
||||
|
||||
#include <fstream>
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue