From 472ec43a01427a59e82600055ebeb2bfe4be3adc Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 8 Jul 2017 14:54:33 +0200 Subject: cmake: fix inkscape-version for linked worktrees (they don't have a '.git/' directory, but only a '.git' file storing the link to the gitdir) --- CMakeScripts/inkscape-version.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeScripts/inkscape-version.cmake b/CMakeScripts/inkscape-version.cmake index 9ffa7f8c7..40c1c4364 100644 --- a/CMakeScripts/inkscape-version.cmake +++ b/CMakeScripts/inkscape-version.cmake @@ -11,7 +11,7 @@ set(INKSCAPE_REVISION "unknown") set(INKSCAPE_CUSTOM "custom") -if(EXISTS ${INKSCAPE_SOURCE_DIR}/.git/) +if(EXISTS ${INKSCAPE_SOURCE_DIR}/.git) execute_process(COMMAND git describe WORKING_DIRECTORY ${INKSCAPE_SOURCE_DIR} -- cgit v1.2.3 From ef507c3c654d59575e8928e0a225c433bbe79aa7 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 8 Jul 2017 18:21:32 +0200 Subject: Hackfest Regression: Fix profile_path() not returning the correct directory Also drop some unnecessary defines from the pre-XP era --- src/inkscape.cpp | 14 -------------- src/io/resource.cpp | 11 ++++++++--- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 22f7230a0..24a744bbd 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -30,20 +30,6 @@ #include "debug/simple-event.h" #include "debug/event-tracker.h" -#ifndef WIN32 -# define HAS_PROC_SELF_EXE //to get path of executable -#else - -#if !defined(_WIN32_IE) || (_WIN32_IE < 0x0400) -# undef _WIN32_IE -# define _WIN32_IE 0x0400 -#endif -//#define HAS_SHGetSpecialFolderPath -#define HAS_SHGetSpecialFolderLocation -#define HAS_GetModuleFileName -# include -#endif - #include #include #include diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 7ecfceb81..4610efd46 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -20,6 +20,10 @@ #include "config.h" #endif +#ifdef WIN32 +#include // for SHGetSpecialFolderLocation +#endif + #include #include #include @@ -271,9 +275,10 @@ char *profile_path(const char *filename) prefdir = g_strdup(userenv); } -#ifdef HAS_SHGetSpecialFolderLocation - // prefer c:\Documents and Settings\UserName\Application Data\ to - // c:\Documents and Settings\userName\; +#ifdef WIN32 + // prefer c:\Documents and Settings\UserName\Application Data\ to c:\Documents and Settings\userName\; + // TODO: CSIDL_APPDATA is C:\Users\UserName\AppData\Roaming these days + // should we switch to AppData\Local? Then we can simply use the portable g_get_user_config_dir() if (!prefdir) { ITEMIDLIST *pidl = 0; if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) { -- cgit v1.2.3 From 138cbd4d43a5e63b477aae5f310c9c7dcb7c8ecb Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sat, 8 Jul 2017 18:39:57 +0200 Subject: Replace deprecated SHGetSpecialFolderLocation with SHGetFolderLocation --- src/io/resource.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/io/resource.cpp b/src/io/resource.cpp index 4610efd46..dfb851d58 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -278,10 +278,10 @@ char *profile_path(const char *filename) #ifdef WIN32 // prefer c:\Documents and Settings\UserName\Application Data\ to c:\Documents and Settings\userName\; // TODO: CSIDL_APPDATA is C:\Users\UserName\AppData\Roaming these days - // should we switch to AppData\Local? Then we can simply use the portable g_get_user_config_dir() + // should we migrate to AppData\Local? Then we can simply use the portable g_get_user_config_dir() if (!prefdir) { ITEMIDLIST *pidl = 0; - if ( SHGetSpecialFolderLocation( NULL, CSIDL_APPDATA, &pidl ) == NOERROR ) { + if ( SHGetFolderLocation( NULL, CSIDL_APPDATA, NULL, 0, &pidl ) == S_OK ) { gchar * utf8Path = NULL; { -- cgit v1.2.3 From 75d34b7742c2e9861167fd55a1885128947e511a Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Jul 2017 00:41:47 +0200 Subject: Hackest regression: We can not exlude the shortcuts file default.xml from the list of shortcut files - it's the default and selected by default! (the exlusion in the original code was targeted at the default.xml file in the profile directory only, as only the user's modifications are stored there and it's not a complete shortcut map) Also properly sort the entries in the dropdown (default.xml first, rest of shortcut files alphabetically) --- src/shortcuts.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index e7343c5e4..e22fe2dae 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -217,7 +217,12 @@ Inkscape::XML::Document *sp_shortcut_create_template_file(char const *filename) void sp_shortcut_get_file_names(std::vector *names, std::vector *paths) { using namespace Inkscape::IO::Resource; - for(auto &filename: get_filenames(KEYS, {".xml"}, {"default.xml", "inkscape.xml"})) { + std::vector filenames = get_filenames(SYSTEM, KEYS, {".xml"}); + std::vector filenames_user = get_filenames(USER, KEYS, {".xml"}, {"default.xml"}); // exclude default.xml as it only includes the user's modifications + filenames.insert(filenames.end(), filenames_user.begin(), filenames_user.end()); + + std::vector> names_and_paths; + for(auto &filename: filenames) { Glib::ustring label = Glib::path_get_basename(filename); XML::Document *doc = sp_repr_read_file(filename.c_str(), NULL); @@ -226,21 +231,40 @@ void sp_shortcut_get_file_names(std::vector *names, std::vectorroot(); if (!strcmp(root->name(), "keys")) { gchar const *name=root->attribute("name"); if (name) { label = Glib::ustring(name) + " (" + label + ")"; } - paths->push_back(filename.c_str()); - names->push_back(label.c_str()); + std::pair name_and_path; + name_and_path = std::make_pair(label, filename); + names_and_paths.push_back(name_and_path); } else { g_warning("Not a shortcut keys file %s", filename.c_str()); } Inkscape::GC::release(doc); } - + + // sort by name + std::sort(names_and_paths.begin(), names_and_paths.end(), + [](std::pair& pair1, std::pair& pair2) { + return Glib::path_get_basename(pair1.first).compare(Glib::path_get_basename(pair2.first)) < 0; + }); + auto it_default = std::find_if(names_and_paths.begin(), names_and_paths.end(), + [](std::pair& pair) { + return !Glib::path_get_basename(pair.second).compare("default.xml"); + }); + if (it_default != names_and_paths.end()) { + std::rotate(names_and_paths.begin(), it_default, it_default+1); + } + + // transform pairs to output vectors + std::transform(names_and_paths.begin(),names_and_paths.end(), std::back_inserter(*names), + [](const std::pair& pair) { return pair.first; }); + std::transform(names_and_paths.begin(),names_and_paths.end(), std::back_inserter(*paths), + [](const std::pair& pair) { return pair.second; }); } Glib::ustring sp_shortcut_get_file_path() -- cgit v1.2.3 From 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Jul 2017 02:07:57 +0200 Subject: Shortcuts: if loading the shortcuts file set in preferences fails fall back to default.xml and finally to inkscape.xml --- src/shortcuts.cpp | 31 ++++++++++++++++++++++++++----- 1 file 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 *user_shortcuts = NULL; void sp_shortcut_init() { - verbs = new std::map(); primary_shortcuts = new std::map(); user_shortcuts = new std::map(); + // 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; } /* -- cgit v1.2.3 From 9f170194f56a3825b67c9a24b80f4890273e7607 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Jul 2017 02:27:33 +0200 Subject: Shortcuts: remove default.xml from repo to resolve any confusion on what file to update (inkscape.xml is the primary shortcut file!) - default.xml will now be autogenerated during "cmake install" - the changes to inkscape.xml correspond to the changes from 72f835c00565835a536531cd81dc6d9a607b615a that were only applied to default.xml - for the error-prone case of running inkscape without installation 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 should provide the proper fallback to inkscape.xml --- share/keys/CMakeLists.txt | 7 + share/keys/default.xml | 715 ---------------------------------------------- share/keys/inkscape.xml | 371 ++++++++++++------------ 3 files changed, 193 insertions(+), 900 deletions(-) delete mode 100644 share/keys/default.xml diff --git a/share/keys/CMakeLists.txt b/share/keys/CMakeLists.txt index c3a745ae8..34b83a509 100644 --- a/share/keys/CMakeLists.txt +++ b/share/keys/CMakeLists.txt @@ -1,2 +1,9 @@ file(GLOB _FILES "*.xml") install(FILES ${_FILES} DESTINATION ${INKSCAPE_SHARE_INSTALL}/keys) + +# install a duplicate of inkscape.xml as default.xml +# default.xml is the default keymap that will be used by inkscape after installation +# replace this with a keymap of your own to override the Inkscape default shortcuts +install(FILES inkscape.xml + DESTINATION ${INKSCAPE_SHARE_INSTALL}/keys + RENAME default.xml) diff --git a/share/keys/default.xml b/share/keys/default.xml deleted file mode 100644 index 9a072d9da..000000000 --- a/share/keys/default.xml +++ /dev/null @@ -1,715 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/share/keys/inkscape.xml b/share/keys/inkscape.xml index b56e1d957..88694e6be 100644 --- a/share/keys/inkscape.xml +++ b/share/keys/inkscape.xml @@ -11,7 +11,9 @@ source locally, you can view that file at: http://git.gnome.org/browse/gtk+/plain/gdk/gdkkeysyms.h - The "modifiers" attribute contains a comma-separated list of modifiers, which can be -one or more of: "Ctrl", "Shift", "Alt". +one or more of: "Ctrl", "Shift", "Alt", "Meta", "Super", "Hyper", or "Primary". + +"Primary" means Meta on Apple and Ctrl everywhere else, it's recommended over the use of Ctrl. - The "action" attribute contains the name of the action. The complete list of actions (called "verbs") is in the file src/verbs.cpp in Inkscape source; there you can see @@ -41,44 +43,42 @@ override) the bindings in the main default.xml. - - + + - - + + - - + + - - - - - + + - - + + - + + - - + + - - + + - - + + - - + + - - + + @@ -154,7 +154,7 @@ override) the bindings in the main default.xml. - + @@ -176,13 +176,13 @@ override) the bindings in the main default.xml. - + - + @@ -234,8 +234,8 @@ override) the bindings in the main default.xml. - - + + @@ -247,12 +247,12 @@ override) the bindings in the main default.xml. - + - - - - + + + + @@ -268,11 +268,11 @@ override) the bindings in the main default.xml. - - + + - - + + @@ -283,8 +283,8 @@ override) the bindings in the main default.xml. - - + + @@ -297,35 +297,35 @@ override) the bindings in the main default.xml. - - - + + + - - - - + + + + - - + + - - + + - - - + + + - - + + - - + + - - + + @@ -338,8 +338,8 @@ override) the bindings in the main default.xml. - - + + @@ -354,13 +354,13 @@ override) the bindings in the main default.xml. - - + + - - + + @@ -384,10 +384,11 @@ override) the bindings in the main default.xml. + - - + + @@ -415,8 +416,8 @@ override) the bindings in the main default.xml. - - + + @@ -424,18 +425,18 @@ override) the bindings in the main default.xml. - - + + - - - - + + + + - - - - + + + + @@ -472,46 +473,46 @@ override) the bindings in the main default.xml. - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - - - + + + + + - - + + - - + + - - - + + + - - - - + + + + @@ -519,10 +520,10 @@ override) the bindings in the main default.xml. - - - - + + + + @@ -530,14 +531,14 @@ override) the bindings in the main default.xml. - - + + - - + + - - + + @@ -555,32 +556,32 @@ override) the bindings in the main default.xml. - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + @@ -590,8 +591,8 @@ override) the bindings in the main default.xml. - - + + @@ -609,46 +610,46 @@ override) the bindings in the main default.xml. - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -660,26 +661,26 @@ override) the bindings in the main default.xml. - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -700,15 +701,15 @@ override) the bindings in the main default.xml. effect id from the .inx file, for example "org.ekips.filter.addnodes" for the Add Nodes effect. --> - - + + - - + + -- cgit v1.2.3 From a40cb0162028c553032407ec3bd553dcbcd2f3ba Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 9 Jul 2017 13:02:10 +0200 Subject: Shortcuts: Fix for 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 (is_user_set was not properly set anymore) --- src/shortcuts.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index c5ec7ed50..52248b81f 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -50,7 +50,7 @@ using namespace Inkscape; using namespace Inkscape::IO::Resource; -static bool try_shortcuts_file(char const *filename); +static bool try_shortcuts_file(char const *filename, bool const is_user_set=false); static void read_shortcuts_file(char const *filename, bool const is_user_set=false); unsigned int sp_shortcut_get_key(unsigned int const shortcut); @@ -107,15 +107,15 @@ void sp_shortcut_init() } // load shortcuts adjusted by user - try_shortcuts_file(get_path(USER, KEYS, "default.xml")); + try_shortcuts_file(get_path(USER, KEYS, "default.xml"), true); } -static bool try_shortcuts_file(char const *filename) { +static bool try_shortcuts_file(char const *filename, bool const is_user_set) { 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); + read_shortcuts_file(filename, is_user_set); return true; } -- cgit v1.2.3