From 54618228e3ebfd8a117789a04f38d6a4cd198916 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 6 Dec 2012 01:20:07 +0100 Subject: [PATCH] Bug 689572 - F1 appears remappable but isn't Make any shortcut involving F1 unchangable in the shortcut editor. --- app/widgets/gimpactionview.c | 47 ++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c index 5af0387ea7..41a2f98481 100644 --- a/app/widgets/gimpactionview.c +++ b/app/widgets/gimpactionview.c @@ -707,7 +707,9 @@ gimp_action_view_conflict_confirm (GimpActionView *view, static const gchar * gimp_action_view_get_accel_action (GimpActionView *view, const gchar *path_string, - GtkAction **action_return) + GtkAction **action_return, + guint *action_accel_key, + GdkModifierType *action_accel_mask) { GtkTreeModel *model; GtkTreePath *path; @@ -724,7 +726,9 @@ gimp_action_view_get_accel_action (GimpActionView *view, GtkAction *action; gtk_tree_model_get (model, &iter, - GIMP_ACTION_VIEW_COLUMN_ACTION, &action, + GIMP_ACTION_VIEW_COLUMN_ACTION, &action, + GIMP_ACTION_VIEW_COLUMN_ACCEL_KEY, action_accel_key, + GIMP_ACTION_VIEW_COLUMN_ACCEL_MASK, action_accel_mask, -1); if (! action) @@ -752,15 +756,23 @@ gimp_action_view_accel_edited (GtkCellRendererAccel *accel, guint hardware_keycode, GimpActionView *view) { - GtkAction *action; - const gchar *accel_path; + GtkAction *action; + guint action_accel_key; + GdkModifierType action_accel_mask; + const gchar *accel_path; accel_path = gimp_action_view_get_accel_action (view, path_string, - &action); + &action, + &action_accel_key, + &action_accel_mask); if (! accel_path) return; + if (accel_key == action_accel_key && + accel_mask == action_accel_mask) + return; + if (! accel_key || /* Don't allow arrow keys, they are all swallowed by the canvas @@ -777,6 +789,13 @@ gimp_action_view_accel_edited (GtkCellRendererAccel *accel, G_OBJECT (view), GIMP_MESSAGE_ERROR, _("Invalid shortcut.")); } + else if (accel_key == GDK_KEY_F1 || + action_accel_key == GDK_KEY_F1) + { + gimp_message_literal (view->manager->gimp, + G_OBJECT (view), GIMP_MESSAGE_ERROR, + _("F1 cannot be remapped.")); + } else if (! gtk_accel_map_change_entry (accel_path, accel_key, accel_mask, FALSE)) { @@ -851,15 +870,27 @@ gimp_action_view_accel_cleared (GtkCellRendererAccel *accel, const char *path_string, GimpActionView *view) { - GtkAction *action; - const gchar *accel_path; + GtkAction *action; + guint action_accel_key; + GdkModifierType action_accel_mask; + const gchar *accel_path; accel_path = gimp_action_view_get_accel_action (view, path_string, - &action); + &action, + &action_accel_key, + &action_accel_mask); if (! accel_path) return; + if (action_accel_key == GDK_KEY_F1) + { + gimp_message_literal (view->manager->gimp, + G_OBJECT (view), GIMP_MESSAGE_ERROR, + _("F1 cannot be remapped.")); + return; + } + if (! gtk_accel_map_change_entry (accel_path, 0, 0, FALSE)) { gimp_message_literal (view->manager->gimp,