From 817ee1c6601663ccec35dcdfeb1fb07466b63c74 Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 12 Apr 2023 14:22:55 +0200 Subject: [PATCH] app, docs, etc.: transform menurc in shortcutsrc after an update. Also get rid of various old references to menurc and don't install it anymore to etc/ (neither the new shortcutsrc as it doesn't look like it brings much value to do so). --- README | 2 +- app/core/gimp-user-install.c | 179 ++++++++++++----------------- app/tests/gimpdir-empty/.gitignore | 2 +- app/tests/gimpdir/.gitignore | 2 +- docs/gimp.1.in | 2 +- etc/Makefile.am | 1 - etc/menurc | 3 - etc/meson.build | 1 - 8 files changed, 79 insertions(+), 113 deletions(-) delete mode 100644 etc/menurc diff --git a/README b/README index 5fb15d17e3..0c27002cca 100644 --- a/README +++ b/README @@ -91,7 +91,7 @@ Additionally, GIMP reads `${XDG_CONFIG_HOME}/GIMP/2.99/gimp.css` so you can have settings that only apply to GIMP. You can also manually change the keybindings to any of your choice by -editing: `${XDG_CONFIG_HOME}/GIMP/2.99/menurc`. +editing: `${XDG_CONFIG_HOME}/GIMP/2.99/shortcutsrc`. Have fun, diff --git a/app/core/gimp-user-install.c b/app/core/gimp-user-install.c index 371fdfc576..ab8e41dd6e 100644 --- a/app/core/gimp-user-install.c +++ b/app/core/gimp-user-install.c @@ -90,7 +90,6 @@ static const struct } gimp_user_install_items[] = { - { "menurc", USER_INSTALL_COPY }, { "brushes", USER_INSTALL_MKDIR }, { "dynamics", USER_INSTALL_MKDIR }, { "fonts", USER_INSTALL_MKDIR }, @@ -489,16 +488,8 @@ user_install_mkdir_with_parents (GimpUserInstall *install, * the next release */ #define MENURC_OVER20_UPDATE_PATTERN \ - "\"/buffers/buffers-paste-as-new\"" "|" \ - "\"/edit/edit-paste-as-new\"" "|" \ - "\"/file/file-export\"" "|" \ - "\"/file/file-export-to\"" "|" \ - "\"/layers/layers-text-tool\"" "|" \ - "\"/plug-in/plug-in-gauss\"" "|" \ - "\"/tools/tools-value-[1-4]-.*\"" "|" \ - "\"/vectors/vectors-path-tool\"" "|" \ - "\"/tools/tools-blend\"" "|" \ - "\"/view/view-rotate-reset\"" + "(;)? *\\(gtk_accel_path \"/[a-zA-Z0-9-]*/([a-zA-Z0-9-]*)\" *\"([a-zA-Z0-9<>_]*)\"\\)" "|" \ + "(;.*)" /** * callback to use for updating a menurc from GIMP over 2.0. @@ -510,103 +501,79 @@ user_update_menurc_over20 (const GMatchInfo *matched_value, GString *new_value, gpointer data) { - GimpUserInstall *install = (GimpUserInstall *) data; - gchar *match = g_match_info_fetch (matched_value, 0); + GimpUserInstall *install = (GimpUserInstall *) data; + gchar *comment_match = g_match_info_fetch (matched_value, 1); + gchar *action_match = g_match_info_fetch (matched_value, 2); + gchar *accel_match = g_match_info_fetch (matched_value, 3); + gchar *ignore_match = g_match_info_fetch (matched_value, 4); + gchar *new_action_name = NULL; - /* "*-paste-as-new" renamed to "*-paste-as-new-image" - */ - if (g_strcmp0 (match, "\"/buffers/buffers-paste-as-new\"") == 0) + if (strlen (ignore_match) == 0) { - g_string_append (new_value, "\"/buffers/buffers-paste-as-new-image\""); - } - else if (g_strcmp0 (match, "\"/edit/edit-paste-as-new\"") == 0) - { - g_string_append (new_value, "\"/edit/edit-paste-as-new-image\""); - } - /* file-export-* changes to follow file-save-* patterns. Actions - * available since GIMP 2.8, changed for 2.10 in commit 4b14ed2. - */ - else if (g_strcmp0 (match, "\"/file/file-export\"") == 0) - { - if (install->old_major == 2 && install->old_minor <= 8) - g_string_append (new_value, "\"/file/file-export-as\""); - else - /* Don't change from a 2.10 config. */ - g_string_append (new_value, match); - } - else if (g_strcmp0 (match, "\"/file/file-export-to\"") == 0) - { - if (install->old_major == 2 && install->old_minor <= 8) - g_string_append (new_value, "\"/file/file-export\""); - else - /* Don't change from a 2.10 config. */ - g_string_append (new_value, match); - } - else if (g_strcmp0 (match, "\"/layers/layers-text-tool\"") == 0) - { - g_string_append (new_value, "\"/layers/layers-edit\""); - } - /* plug-in-gauss doesn't exist anymore since commit ff59aebbe88. - * The expected replacement would be filters-gaussian-blur which is - * gegl:gaussian-blur operation. See also bug 775931. - */ - else if (g_strcmp0 (match, "\"/plug-in/plug-in-gauss\"") == 0) - { - g_string_append (new_value, "\"/filters/filters-gaussian-blur\""); - } - /* Tools settings renamed more user-friendly. Actions available - * since GIMP 2.4, changed for 2.10 in commit 0bdb747. - */ - else if (g_str_has_prefix (match, "\"/tools/tools-value-1-")) - { - g_string_append (new_value, "\"/tools/tools-opacity-"); - g_string_append (new_value, match + 31); - } - else if (g_str_has_prefix (match, "\"/tools/tools-value-2-")) - { - g_string_append (new_value, "\"/tools/tools-size-"); - g_string_append (new_value, match + 31); - } - else if (g_str_has_prefix (match, "\"/tools/tools-value-3-")) - { - g_string_append (new_value, "\"/tools/tools-aspect-"); - g_string_append (new_value, match + 31); - } - else if (g_str_has_prefix (match, "\"/tools/tools-value-4-")) - { - g_string_append (new_value, "\"/tools/tools-angle-"); - g_string_append (new_value, match + 31); - } - else if (g_strcmp0 (match, "\"/vectors/vectors-path-tool\"") == 0) - { - g_string_append (new_value, "\"/vectors/vectors-edit\""); - } - else if (g_strcmp0 (match, "\"/tools/tools-blend\"") == 0) - { - g_string_append (new_value, "\"/tools/tools-gradient\""); - } - else if (g_strcmp0 (match, "\"/view/view-rotate-reset\"") == 0) - { - /* view-rotate-reset became view-reset and new view-rotate-reset - * and view-flip-reset actions were created. - * See commit 15fb4a7be0. + /* "*-paste-as-new" renamed to "*-paste-as-new-image" */ + if (g_strcmp0 (action_match, "buffers-paste-as-new") == 0) + new_action_name = g_strdup ("buffers-paste-as-new-image"); + else if (g_strcmp0 (action_match, "edit-paste-as-new") == 0) + new_action_name = g_strdup ("edit-paste-as-new-image"); + /* file-export-* changes to follow file-save-* patterns. Actions + * available since GIMP 2.8, changed for 2.10 in commit 4b14ed2. */ - if (install->old_major == 2) - g_string_append (new_value, "\"/view/view-reset\""); - else - /* In advance for a migration from a 3.0 config to higher ones. */ - g_string_append (new_value, match); - } - else - { - /* Should not happen. Just in case we match something unexpected by - * mistake. + else if (g_strcmp0 (action_match, "file-export") == 0 && + install->old_major == 2 && install->old_minor <= 8) + new_action_name = g_strdup ("file-export-as"); + else if (g_strcmp0 (action_match, "file-export-to") == 0 && + install->old_major == 2 && install->old_minor <= 8) + new_action_name = g_strdup ("file-export"); + else if (g_strcmp0 (action_match, "layers-text-tool") == 0) + new_action_name = g_strdup ("layers-edit"); + /* plug-in-gauss doesn't exist anymore since commit ff59aebbe88. + * The expected replacement would be filters-gaussian-blur which is + * gegl:gaussian-blur operation. See also bug 775931. */ - g_message ("(WARNING) %s: invalid match \"%s\"", G_STRFUNC, match); - g_string_append (new_value, match); + else if (g_strcmp0 (action_match, "plug-in-gauss") == 0) + new_action_name = g_strdup ("filters-gaussian-blur"); + /* Tools settings renamed more user-friendly. Actions available + * since GIMP 2.4, changed for 2.10 in commit 0bdb747. + */ + else if (g_str_has_prefix (action_match, "tools-value-1-")) + new_action_name = g_strdup ("tools-opacity-"); + else if (g_str_has_prefix (action_match, "tools-value-2-")) + new_action_name = g_strdup_printf ("tools-size-%s", action_match + 14); + else if (g_str_has_prefix (action_match, "tools-value-3-")) + new_action_name = g_strdup_printf ("tools-aspect-%s", action_match + 14); + else if (g_str_has_prefix (action_match, "tools-value-4-")) + new_action_name = g_strdup_printf ("tools-angle-%s", action_match + 14); + else if (g_strcmp0 (action_match, "vectors-path-tool") == 0) + new_action_name = g_strdup ("vectors-edit"); + else if (g_strcmp0 (action_match, "tools-blend") == 0) + new_action_name = g_strdup ("tools-gradient"); + /* view-rotate-reset became view-reset and new view-rotate-reset and + * view-flip-reset actions were created. See commit 15fb4a7be0. + */ + else if (g_strcmp0 (action_match, "view-rotate-reset") == 0 && + install->old_major == 2) + new_action_name = g_strdup ("view-reset"); + + if (new_action_name == NULL) + new_action_name = g_strdup (action_match); + + if (g_strcmp0 (comment_match, ";") == 0) + g_string_append (new_value, "# "); + + if (strlen (accel_match) > 0) + g_string_append_printf (new_value, "(action \"%s\" \"%s\")", + new_action_name, accel_match); + else + g_string_append_printf (new_value, "(action \"%s\")", + new_action_name); } - g_free (match); + g_free (comment_match); + g_free (action_match); + g_free (accel_match); + g_free (ignore_match); + g_free (new_action_name); + return FALSE; } @@ -1004,7 +971,8 @@ user_install_migrate_files (GimpUserInstall *install) while ((basename = g_dir_read_name (dir)) != NULL) { - gchar *source = g_build_filename (install->old_dir, basename, NULL); + gchar *source = g_build_filename (install->old_dir, basename, NULL); + const gchar *new_dest = NULL; if (g_file_test (source, G_FILE_TEST_IS_REGULAR)) { @@ -1041,6 +1009,8 @@ user_install_migrate_files (GimpUserInstall *install) default: update_pattern = MENURC_OVER20_UPDATE_PATTERN; update_callback = user_update_menurc_over20; + /* menurc becomes shortcutsrc in 3.0. */ + new_dest = "shortcutsrc"; break; } } @@ -1062,7 +1032,8 @@ user_install_migrate_files (GimpUserInstall *install) } g_snprintf (dest, sizeof (dest), "%s%c%s", - gimp_directory (), G_DIR_SEPARATOR, basename); + gimp_directory (), G_DIR_SEPARATOR, + new_dest ? new_dest : basename); user_install_file_copy (install, source, dest, update_pattern, update_callback); diff --git a/app/tests/gimpdir-empty/.gitignore b/app/tests/gimpdir-empty/.gitignore index fa44da7a4f..04f05da19d 100644 --- a/app/tests/gimpdir-empty/.gitignore +++ b/app/tests/gimpdir-empty/.gitignore @@ -1,7 +1,7 @@ /colorrc /controllerrc /dockrc -/menurc +/shortcutsrc /parasiterc /pluginrc /sessionrc diff --git a/app/tests/gimpdir/.gitignore b/app/tests/gimpdir/.gitignore index a1b97276bf..7c7f4aa9d4 100644 --- a/app/tests/gimpdir/.gitignore +++ b/app/tests/gimpdir/.gitignore @@ -1,6 +1,6 @@ /colorrc /controllerrc -/menurc +/shortcutsrc /parasiterc /pluginrc /templaterc diff --git a/docs/gimp.1.in b/docs/gimp.1.in index 42512a15c0..9b0cf50069 100644 --- a/docs/gimp.1.in +++ b/docs/gimp.1.in @@ -210,7 +210,7 @@ here. @gimpsysconfdir@/gtkrc - system wide default set of GIMP-specific GTK config settings. -@manpage_gimpdir@/menurc - user's set of keybindings. +@manpage_gimpdir@/shortcutsrc - user's set of keybindings. @manpage_gimpdir@/parasiterc - Stores all persistent GIMP parasites. This file will be rewritten every time you quit GIMP. diff --git a/etc/Makefile.am b/etc/Makefile.am index 7365a47138..e8c8f09f4e 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -3,7 +3,6 @@ gimpsysconf = \ controllerrc \ gimp.css \ - menurc \ sessionrc \ templaterc \ toolrc \ diff --git a/etc/menurc b/etc/menurc deleted file mode 100644 index 9f5dda0917..0000000000 --- a/etc/menurc +++ /dev/null @@ -1,3 +0,0 @@ -; gimp GtkAccelMap rc-file -*- scheme -*- -; -(gtk_accel_path "/plug-in/file-print-gtk" "p") diff --git a/etc/meson.build b/etc/meson.build index b3b20717ea..222b9b6347 100644 --- a/etc/meson.build +++ b/etc/meson.build @@ -11,7 +11,6 @@ install_data( configuration: etcconf, ), 'gimp.css', - 'menurc', 'sessionrc', 'templaterc', 'toolrc',