app: fix "Remove all Keyboard Shortcuts" and "Reset Keyboard Shortcuts to…

… 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 6da388be93, 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.
This commit is contained in:
Jehan 2023-04-12 14:55:30 +02:00
parent beb093f549
commit d6a86b1ab7

View file

@ -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);
}