add Gtkmm2ext::Keyboard::reset_bindings()
This commit is contained in:
parent
6cadefcb19
commit
8859ebe56e
|
@ -156,6 +156,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
|
|||
static std::string current_binding_name () { return _current_binding_name; }
|
||||
static std::map<std::string,std::string> binding_files;
|
||||
|
||||
int reset_bindings ();
|
||||
|
||||
struct AccelKeyLess {
|
||||
bool operator() (const Gtk::AccelKey a, const Gtk::AccelKey b) const {
|
||||
if (a.get_key() != b.get_key()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user