load default key bindings on error
This commit is contained in:
parent
143cb6562b
commit
ac215248a0
3 changed files with 43 additions and 11 deletions
|
@ -1,5 +1,9 @@
|
||||||
(Format: Year/Month/Day)
|
(Format: Year/Month/Day)
|
||||||
Changes for 1.0.0:
|
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:
|
*07/09/20:
|
||||||
* Updated ru_RU ( Thanks Slava Semushin )
|
* Updated ru_RU ( Thanks Slava Semushin )
|
||||||
*07/09/13:
|
*07/09/13:
|
||||||
|
|
47
src/Keys.cc
47
src/Keys.cc
|
@ -166,22 +166,32 @@ void Keys::ungrabButtons() {
|
||||||
@return true on success else false
|
@return true on success else false
|
||||||
*/
|
*/
|
||||||
bool Keys::load(const char *filename) {
|
bool Keys::load(const char *filename) {
|
||||||
if (!filename)
|
// an intentionally empty file will still have one root mapping
|
||||||
return false;
|
bool firstload = m_map.empty();
|
||||||
|
|
||||||
//free memory of previous grabs
|
if (!filename) {
|
||||||
|
if (firstload)
|
||||||
|
loadDefaults();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FbTk::App::instance()->sync(false);
|
||||||
|
|
||||||
|
// open the file
|
||||||
|
ifstream infile(filename);
|
||||||
|
if (!infile) {
|
||||||
|
if (firstload)
|
||||||
|
loadDefaults();
|
||||||
|
|
||||||
|
return false; // failed to open file
|
||||||
|
}
|
||||||
|
|
||||||
|
// free memory of previous grabs
|
||||||
deleteTree();
|
deleteTree();
|
||||||
|
|
||||||
m_map["default:"] = new t_key(0,0,0,0);
|
m_map["default:"] = new t_key(0,0,0,0);
|
||||||
|
|
||||||
FbTk::App::instance()->sync(false);
|
unsigned int current_line = 0; //so we can tell the user where the fault is
|
||||||
|
|
||||||
//open the file
|
|
||||||
ifstream infile(filename);
|
|
||||||
if (!infile)
|
|
||||||
return false; // faild to open file
|
|
||||||
|
|
||||||
unsigned int current_line = 0;//so we can tell the user where the fault is
|
|
||||||
|
|
||||||
while (!infile.eof()) {
|
while (!infile.eof()) {
|
||||||
string linebuffer;
|
string linebuffer;
|
||||||
|
@ -204,6 +214,21 @@ bool Keys::load(const char *filename) {
|
||||||
return true;
|
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"<<endl;
|
||||||
|
#endif
|
||||||
|
deleteTree();
|
||||||
|
m_map["default:"] = new t_key(0,0,0,0);
|
||||||
|
addBinding("OnDesktop Mouse1 :HideMenus");
|
||||||
|
addBinding("OnDesktop Mouse2 :WorkspaceMenu");
|
||||||
|
addBinding("OnDesktop Mouse3 :RootMenu");
|
||||||
|
keyMode("default");
|
||||||
|
}
|
||||||
|
|
||||||
bool Keys::save(const char *filename) const {
|
bool Keys::save(const char *filename) const {
|
||||||
//!!
|
//!!
|
||||||
//!! TODO: fix keybinding saving
|
//!! TODO: fix keybinding saving
|
||||||
|
|
|
@ -97,6 +97,9 @@ private:
|
||||||
void grabButton(unsigned int button, unsigned int mod);
|
void grabButton(unsigned int button, unsigned int mod);
|
||||||
void ungrabButtons();
|
void ungrabButtons();
|
||||||
|
|
||||||
|
// Load default keybindings for when there are errors loading the initial one
|
||||||
|
void loadDefaults();
|
||||||
|
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
|
|
||||||
class t_key;
|
class t_key;
|
||||||
|
|
Loading…
Reference in a new issue