aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-05-12 16:00:02 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-05-12 16:00:02 (GMT)
commit0b2e002d4f281edfef0e6c036cf58d9fdb7ae978 (patch)
tree2bcf0fb10bb2a2fc288681441b64c636fb4bfd13 /src/Remember.cc
parent93b0c5322a7482d83e38657b36e9814f8415e47b (diff)
downloadfluxbox_pavel-0b2e002d4f281edfef0e6c036cf58d9fdb7ae978.zip
fluxbox_pavel-0b2e002d4f281edfef0e6c036cf58d9fdb7ae978.tar.bz2
use AutoReloadHelper in apps file, check for changes automatically
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc28
1 files changed, 14 insertions, 14 deletions
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() {
281Remember *Remember::s_instance = 0; 281Remember *Remember::s_instance = 0;
282 282
283Remember::Remember(): 283Remember::Remember():
284 m_pats(new Patterns()), 284 m_pats(new Patterns()) {
285 m_last_timestamp(0)
286{
287 if (s_instance != 0) 285 if (s_instance != 0)
288 throw string("Can not create more than one instance of Remember"); 286 throw string("Can not create more than one instance of Remember");
289 287
290 s_instance = this; 288 s_instance = this;
291 enableUpdate(); 289 enableUpdate();
290
291 m_reloader.setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Remember>(*this, &Remember::reload)));
292 reconfigure(); 292 reconfigure();
293} 293}
294 294
@@ -579,11 +579,12 @@ Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlis
579 579
580 580
581void Remember::reconfigure() { 581void Remember::reconfigure() {
582 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename()); 582 m_reloader.setMainFile(Fluxbox::instance()->getAppsFilename());
583 m_reloader.checkReload();
584}
583 585
584 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 586void Remember::reload() {
585 if (m_last_timestamp > 0 && m_last_timestamp == timestamp) 587 string apps_string = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getAppsFilename());
586 return;
587 588
588#ifdef DEBUG 589#ifdef DEBUG
589 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; 590 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl;
@@ -598,7 +599,6 @@ void Remember::reconfigure() {
598 m_startups.clear(); 599 m_startups.clear();
599 600
600 if (!apps_file.fail()) { 601 if (!apps_file.fail()) {
601 m_last_timestamp = timestamp;
602 if (!apps_file.eof()) { 602 if (!apps_file.eof()) {
603 string line; 603 string line;
604 int row = 0; 604 int row = 0;
@@ -687,7 +687,7 @@ void Remember::reconfigure() {
687#endif 687#endif
688 } 688 }
689 } else { 689 } else {
690 cerr << "apps file failure" << endl; 690 cerr << "failed to open apps file" << endl;
691 } 691 }
692 692
693 // Clean up old state 693 // Clean up old state
@@ -895,11 +895,8 @@ void Remember::save() {
895 apps_file << "[end]" << endl; 895 apps_file << "[end]" << endl;
896 } 896 }
897 apps_file.close(); 897 apps_file.close();
898 898 // update timestamp to avoid unnecessary reload
899 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 899 m_reloader.addFile(Fluxbox::instance()->getAppsFilename());
900 if (timestamp > 0)
901 m_last_timestamp = timestamp;
902
903} 900}
904 901
905bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { 902bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
@@ -1216,6 +1213,9 @@ void Remember::setupClient(WinClient &winclient) {
1216 if (winclient.screen().isRestart()) 1213 if (winclient.screen().isRestart())
1217 return; 1214 return;
1218 1215
1216 // check if apps file has changed
1217 reconfigure();
1218
1219 Application *app = find(winclient); 1219 Application *app = find(winclient);
1220 if (app == 0) 1220 if (app == 0)
1221 return; // nothing to do 1221 return; // nothing to do