diff options
| author | Eduard Braun <eduard.braun2@gmx.de> | 2017-07-09 00:07:57 +0000 |
|---|---|---|
| committer | Eduard Braun <eduard.braun2@gmx.de> | 2017-07-09 00:07:57 +0000 |
| commit | 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 (patch) | |
| tree | ea439bf5b850b3cb124e1f7e1307494edb45a9c7 /src/shortcuts.cpp | |
| parent | Hackest regression: We can not exlude the shortcuts file default.xml from the... (diff) | |
| download | inkscape-7d248fbba5b0c24d9a24cda8c3f2e79f96395553.tar.gz inkscape-7d248fbba5b0c24d9a24cda8c3f2e79f96395553.zip | |
Shortcuts: if loading the shortcuts file set in preferences fails fall back to default.xml and finally to inkscape.xml
Diffstat (limited to 'src/shortcuts.cpp')
| -rw-r--r-- | src/shortcuts.cpp | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index e22fe2dae..c5ec7ed50 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -50,7 +50,7 @@ using namespace Inkscape; using namespace Inkscape::IO::Resource; -static void try_shortcuts_file(char const *filename); +static bool try_shortcuts_file(char const *filename); static void read_shortcuts_file(char const *filename, bool const is_user_set=false); unsigned int sp_shortcut_get_key(unsigned int const shortcut); @@ -78,28 +78,49 @@ static std::map<Inkscape::Verb *, unsigned int> *user_shortcuts = NULL; void sp_shortcut_init() { - verbs = new std::map<unsigned int, Inkscape::Verb * >(); primary_shortcuts = new std::map<Inkscape::Verb *, unsigned int>(); user_shortcuts = new std::map<Inkscape::Verb *, unsigned int>(); + // try to load shortcut file as set in preferences + // if preference is unset or loading fails fallback to share/keys/default.xml and finally share/keys/inkscape.xml Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring shortcutfile = prefs->getString("/options/kbshortcuts/shortcutfile"); + bool success = false; + gchar const *reason; if (shortcutfile.empty()) { - shortcutfile = Glib::ustring(get_path(SYSTEM, KEYS, "default.xml")); + reason = "No key file set in preferences"; + } else { + success = try_shortcuts_file(shortcutfile.c_str()); + reason = "Unable to read key file set in preferences"; + } + if (!success) { + g_info("%s. Falling back to 'default.xml'.", reason); + success = try_shortcuts_file(get_path(SYSTEM, KEYS, "default.xml")); + } + if (!success) { + g_info("Could not load 'default.xml' either. Falling back to 'inkscape.xml'."); + success = try_shortcuts_file(get_path(SYSTEM, KEYS, "inkscape.xml")); + } + if (!success) { + g_warning("Could not load any keyboard shortcut file (including fallbacks to 'default.xml' and 'inkscape.xml')."); } - read_shortcuts_file(shortcutfile.c_str()); + // load shortcuts adjusted by user try_shortcuts_file(get_path(USER, KEYS, "default.xml")); } -static void try_shortcuts_file(char const *filename) { +static bool try_shortcuts_file(char const *filename) { using Inkscape::IO::file_test; /* ah, if only we had an exception to catch... (permission, forgiveness) */ if (file_test(filename, G_FILE_TEST_EXISTS)) { read_shortcuts_file(filename, true); + return true; } + + g_info("Unable to read keyboard shortcuts from %s (does not exist)", filename); + return false; } /* |
