From ac215248a00d06bdb1e9dd4b373d415bda4ad4b1 Mon Sep 17 00:00:00 2001 From: simonb Date: Sun, 30 Sep 2007 11:35:20 +0000 Subject: load default key bindings on error --- ChangeLog | 4 ++++ src/Keys.cc | 45 +++++++++++++++++++++++++++++++++++---------- src/Keys.hh | 3 +++ 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f6d2f28..aa3c575 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 1.0.0: +*07/09/30: + * Load menu and workspacemenu mouse bindings if error when loading + initial key bindings. Else can't get to menu to reload config (Simon) + Keys.hh/cc *07/09/20: * Updated ru_RU ( Thanks Slava Semushin ) *07/09/13: diff --git a/src/Keys.cc b/src/Keys.cc index fd96fe8..72d59cd 100644 --- a/src/Keys.cc +++ b/src/Keys.cc @@ -166,22 +166,32 @@ void Keys::ungrabButtons() { @return true on success else false */ bool Keys::load(const char *filename) { - if (!filename) - return false; - - //free memory of previous grabs - deleteTree(); + // an intentionally empty file will still have one root mapping + bool firstload = m_map.empty(); - m_map["default:"] = new t_key(0,0,0,0); + if (!filename) { + if (firstload) + loadDefaults(); + return false; + } FbTk::App::instance()->sync(false); - //open the file + // open the file ifstream infile(filename); - if (!infile) - return false; // faild to open file + if (!infile) { + if (firstload) + loadDefaults(); - unsigned int current_line = 0;//so we can tell the user where the fault is + return false; // failed to open file + } + + // free memory of previous grabs + deleteTree(); + + m_map["default:"] = new t_key(0,0,0,0); + + unsigned int current_line = 0; //so we can tell the user where the fault is while (!infile.eof()) { string linebuffer; @@ -204,6 +214,21 @@ bool Keys::load(const char *filename) { return true; } +/** + * Load critical key/mouse bindings for when there are fatal errors reading the keyFile. + */ +void Keys::loadDefaults() { +#ifdef DEBUG + cerr<<"Loading default key bindings"<