aboutsummaryrefslogtreecommitdiff
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
parent143cb6562bcfffdbf5b495169e40b72a30425839 (diff)
downloadfluxbox_paul-ac215248a00d06bdb1e9dd4b373d415bda4ad4b1.zip
fluxbox_paul-ac215248a00d06bdb1e9dd4b373d415bda4ad4b1.tar.bz2
load default key bindings on error
-rw-r--r--ChangeLog4
-rw-r--r--src/Keys.cc45
-rw-r--r--src/Keys.hh3
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 @@
1 (Format: Year/Month/Day) 1 (Format: Year/Month/Day)
2Changes for 1.0.0: 2Changes for 1.0.0:
3*07/09/30:
4 * Load menu and workspacemenu mouse bindings if error when loading
5 initial key bindings. Else can't get to menu to reload config (Simon)
6 Keys.hh/cc
3*07/09/20: 7*07/09/20:
4 * Updated ru_RU ( Thanks Slava Semushin ) 8 * Updated ru_RU ( Thanks Slava Semushin )
5*07/09/13: 9*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() {
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
diff --git a/src/Keys.hh b/src/Keys.hh
index c075d38..a83a0ec 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -97,6 +97,9 @@ private:
97 void grabButton(unsigned int button, unsigned int mod); 97 void grabButton(unsigned int button, unsigned int mod);
98 void ungrabButtons(); 98 void ungrabButtons();
99 99
100 // Load default keybindings for when there are errors loading the initial one
101 void loadDefaults();
102
100 std::string m_filename; 103 std::string m_filename;
101 104
102 class t_key; 105 class t_key;