diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-10 11:04:04 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-07-10 11:04:04 -0400 |
commit | 8859ebe56efb3a1be14ae464853ad7b9d2eec24d (patch) | |
tree | fb40fc7699df32f49c34efe3c4292e9c0e8fa775 /libs/gtkmm2ext/keyboard.cc | |
parent | 6cadefcb1982c98f4a2a9c78b88e80e9222ed1dc (diff) |
add Gtkmm2ext::Keyboard::reset_bindings()
Diffstat (limited to 'libs/gtkmm2ext/keyboard.cc')
-rw-r--r-- | libs/gtkmm2ext/keyboard.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 2bfb5fa58b..48fcae8482 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -23,18 +23,23 @@ #include <fstream> #include <iostream> +#include <cerrno> #include <ctype.h> +#include <glib/gstdio.h> + #include <gtkmm/widget.h> #include <gtkmm/window.h> #include <gtkmm/accelmap.h> #include <gdk/gdkkeysyms.h> #include "pbd/error.h" +#include "pbd/convert.h" #include "pbd/file_utils.h" #include "pbd/search_path.h" #include "pbd/xml++.h" #include "pbd/debug.h" +#include "pbd/unwind.h" #include "gtkmm2ext/keyboard.h" #include "gtkmm2ext/actions.h" @@ -585,3 +590,24 @@ Keyboard::load_keybindings (string path) return true; } +int +Keyboard::reset_bindings () +{ + if (Glib::file_test (user_keybindings_path, Glib::FILE_TEST_EXISTS)) { + + string new_path = user_keybindings_path; + new_path += ".old"; + + if (::g_rename (user_keybindings_path.c_str(), new_path.c_str())) { + error << string_compose (_("Cannot rename your own keybinding file (%1)"), strerror (errno)) << endmsg; + return -1; + } + } + + { + PBD::Unwinder<bool> uw (can_save_keybindings, false); + setup_keybindings (); + } + + return 0; +} |