aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-05-12 19:16:37 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-05-12 19:16:37 (GMT)
commitdcdc78332431ff2b258c54a99d6fac382c6a0595 (patch)
treec667adfc3cf2a2a90972d1342147f31bd6beeb40 /src/Keys.cc
parenta56492c0d538c9c3a019812558938df0b6afedeb (diff)
downloadfluxbox-dcdc78332431ff2b258c54a99d6fac382c6a0595.zip
fluxbox-dcdc78332431ff2b258c54a99d6fac382c6a0595.tar.bz2
only reload the keys file if the contents have changed
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index eb3d9d5..ec1fde0 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -170,7 +170,9 @@ Keys::t_key::~t_key() {
170 170
171 171
172 172
173Keys::Keys() : next_key(0) { } 173Keys::Keys(): next_key(0) {
174 m_reloader.setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload)));
175}
174 176
175Keys::~Keys() { 177Keys::~Keys() {
176 ungrabKeys(); 178 ungrabKeys();
@@ -255,27 +257,25 @@ void Keys::grabWindow(Window win) {
255/** 257/**
256 Load and grab keys 258 Load and grab keys
257 TODO: error checking 259 TODO: error checking
258 @return true on success else false
259*/ 260*/
260bool Keys::load(const char *filename) { 261void Keys::reload() {
261 // an intentionally empty file will still have one root mapping 262 // an intentionally empty file will still have one root mapping
262 bool firstload = m_map.empty(); 263 bool firstload = m_map.empty();
263 264
264 if (!filename) { 265 if (m_filename.empty()) {
265 if (firstload) 266 if (firstload)
266 loadDefaults(); 267 loadDefaults();
267 return false; 268 return;
268 } 269 }
269 270
270 FbTk::App::instance()->sync(false); 271 FbTk::App::instance()->sync(false);
271 272
272 // open the file 273 // open the file
273 ifstream infile(filename); 274 ifstream infile(m_filename.c_str());
274 if (!infile) { 275 if (!infile) {
275 if (firstload) 276 if (firstload)
276 loadDefaults(); 277 loadDefaults();
277 278 return; // failed to open file
278 return false; // failed to open file
279 } 279 }
280 280
281 // free memory of previous grabs 281 // free memory of previous grabs
@@ -301,9 +301,7 @@ bool Keys::load(const char *filename) {
301 } 301 }
302 } // end while eof 302 } // end while eof
303 303
304 m_filename = filename;
305 keyMode("default"); 304 keyMode("default");
306 return true;
307} 305}
308 306
309/** 307/**
@@ -321,19 +319,6 @@ void Keys::loadDefaults() {
321 keyMode("default"); 319 keyMode("default");
322} 320}
323 321
324bool Keys::save(const char *filename) const {
325 //!!
326 //!! TODO: fix keybinding saving
327 //!! (we probably need to save key actions
328 //!! as strings instead of creating new Commands)
329
330 // open file for writing
331 // ofstream outfile(filename);
332 // if (!outfile)
333 return false;
334 // return true;
335}
336
337bool Keys::addBinding(const string &linebuffer) { 322bool Keys::addBinding(const string &linebuffer) {
338 323
339 vector<string> val; 324 vector<string> val;
@@ -583,8 +568,10 @@ void Keys::unregisterWindow(Window win) {
583 deletes the tree and load configuration 568 deletes the tree and load configuration
584 returns true on success else false 569 returns true on success else false
585*/ 570*/
586bool Keys::reconfigure(const char *filename) { 571void Keys::reconfigure() {
587 return load(filename); 572 m_filename = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getKeysFilename());
573 m_reloader.setMainFile(m_filename);
574 m_reloader.checkReload();
588} 575}
589 576
590void Keys::keyMode(const string& keyMode) { 577void Keys::keyMode(const string& keyMode) {