summaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
authorsimonb <simonb>2007-09-30 11:35:20 (GMT)
committersimonb <simonb>2007-09-30 11:35:20 (GMT)
commitac215248a00d06bdb1e9dd4b373d415bda4ad4b1 (patch)
treeb29b003a02718fb198c44082be8b650af8261c0d /src/Keys.cc
parent143cb6562bcfffdbf5b495169e40b72a30425839 (diff)
downloadfluxbox_lack-ac215248a00d06bdb1e9dd4b373d415bda4ad4b1.zip
fluxbox_lack-ac215248a00d06bdb1e9dd4b373d415bda4ad4b1.tar.bz2
load default key bindings on error
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc45
1 files changed, 35 insertions, 10 deletions
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() {
166 @return true on success else false 166 @return true on success else false
167*/ 167*/
168bool Keys::load(const char *filename) { 168bool Keys::load(const char *filename) {
169 if (!filename) 169 // an intentionally empty file will still have one root mapping
170 return false; 170 bool firstload = m_map.empty();
171
172 //free memory of previous grabs
173 deleteTree();
174 171
175 m_map["default:"] = new t_key(0,0,0,0); 172 if (!filename) {
173 if (firstload)
174 loadDefaults();
175 return false;
176 }
176 177
177 FbTk::App::instance()->sync(false); 178 FbTk::App::instance()->sync(false);
178 179
179 //open the file 180 // open the file
180 ifstream infile(filename); 181 ifstream infile(filename);
181 if (!infile) 182 if (!infile) {
182 return false; // faild to open file 183 if (firstload)
184 loadDefaults();
183 185
184 unsigned int current_line = 0;//so we can tell the user where the fault is 186 return false; // failed to open file
187 }
188
189 // free memory of previous grabs
190 deleteTree();
191
192 m_map["default:"] = new t_key(0,0,0,0);
193
194 unsigned int current_line = 0; //so we can tell the user where the fault is
185 195
186 while (!infile.eof()) { 196 while (!infile.eof()) {
187 string linebuffer; 197 string linebuffer;
@@ -204,6 +214,21 @@ bool Keys::load(const char *filename) {
204 return true; 214 return true;
205} 215}
206 216
217/**
218 * Load critical key/mouse bindings for when there are fatal errors reading the keyFile.
219 */
220void Keys::loadDefaults() {
221#ifdef DEBUG
222 cerr<<"Loading default key bindings"<<endl;
223#endif
224 deleteTree();
225 m_map["default:"] = new t_key(0,0,0,0);
226 addBinding("OnDesktop Mouse1 :HideMenus");
227 addBinding("OnDesktop Mouse2 :WorkspaceMenu");
228 addBinding("OnDesktop Mouse3 :RootMenu");
229 keyMode("default");
230}
231
207bool Keys::save(const char *filename) const { 232bool Keys::save(const char *filename) const {
208 //!! 233 //!!
209 //!! TODO: fix keybinding saving 234 //!! TODO: fix keybinding saving