From d6a86b1ab7bdf957d2a04fc35e6bebcfaf8a55bf Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 12 Apr 2023 14:55:30 +0200 Subject: [PATCH] =?UTF-8?q?app:=20fix=20"Remove=20all=20Keyboard=20Shortcu?= =?UTF-8?q?ts"=20and=20"Reset=20Keyboard=20Shortcuts=20to=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … Default Values" buttons in Preferences. I considered just deleting the "Remove all shortcuts" action, because really I am wondering how useful (and often used) it is, and if we are not over-featuring the shortcut code. I could find the origin commit 6da388be93a, from 2006. Basically the use case is for people who want such a different mapping overall that it's much better to start from a blank slate (e.g. DVORAK users, like in the original report). See: https://bugzilla.gnome.org/show_bug.cgi?id=331839 So in the end, I just reimplemented this with newer code. Also this commit fixes the "Reset Keyboard Shortcuts to Default Values" code. --- app/menus/menus.c | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) diff --git a/app/menus/menus.c b/app/menus/menus.c index c8cd39c17a..da477c4e34 100644 --- a/app/menus/menus.c +++ b/app/menus/menus.c @@ -31,6 +31,7 @@ #include "core/gimp.h" +#include "widgets/gimpaction.h" #include "widgets/gimpactionfactory.h" #include "widgets/gimpdashboard.h" #include "widgets/gimpmenufactory.h" @@ -48,12 +49,6 @@ /* local function prototypes */ -static void menus_remove_accels (gpointer data, - const gchar *accel_path, - guint accel_key, - GdkModifierType accel_mods, - gboolean changed); - /* private variables */ @@ -465,23 +460,16 @@ menus_clear (Gimp *gimp, GError **error) { GFile *file; - GFile *source; gboolean success = TRUE; GError *my_error = NULL; g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); - file = gimp_directory_file ("menurc", NULL); - source = gimp_sysconf_directory_file ("menurc", NULL); + file = gimp_directory_file ("shortcutsrc", NULL); - if (g_file_copy (source, file, G_FILE_COPY_OVERWRITE, - NULL, NULL, NULL, NULL)) - { - menurc_deleted = TRUE; - } - else if (! g_file_delete (file, NULL, &my_error) && - my_error->code != G_IO_ERROR_NOT_FOUND) + if (! g_file_delete (file, NULL, &my_error) && + my_error->code != G_IO_ERROR_NOT_FOUND) { g_set_error (error, my_error->domain, my_error->code, _("Deleting \"%s\" failed: %s"), @@ -494,7 +482,6 @@ menus_clear (Gimp *gimp, } g_clear_error (&my_error); - g_object_unref (source); g_object_unref (file); return success; @@ -503,9 +490,20 @@ menus_clear (Gimp *gimp, void menus_remove (Gimp *gimp) { + gchar **actions; + g_return_if_fail (GIMP_IS_GIMP (gimp)); - gtk_accel_map_foreach (gimp, menus_remove_accels); + actions = g_action_group_list_actions (G_ACTION_GROUP (gimp->app)); + for (gint i = 0; actions[i] != NULL; i++) + { + GimpAction *action; + + action = (GimpAction *) g_action_map_lookup_action (G_ACTION_MAP (gimp->app), + actions[i]); + gimp_action_set_accels (action, (const gchar *[]) { NULL }); + } + g_strfreev (actions); } GimpMenuFactory * @@ -539,16 +537,3 @@ menus_get_image_manager_singleton (Gimp *gimp) return image_ui_manager; } - - -/* private functions */ - -static void -menus_remove_accels (gpointer data, - const gchar *accel_path, - guint accel_key, - GdkModifierType accel_mods, - gboolean changed) -{ - gtk_accel_map_change_entry (accel_path, 0, 0, TRUE); -}