[gimp] Bug 689572 - F1 appears remappable but isn't



commit 54618228e3ebfd8a117789a04f38d6a4cd198916
Author: Michael Natterer <mitch gimp org>
Date:   Thu Dec 6 01:20:07 2012 +0100

    Bug 689572 - F1 appears remappable but isn't
    
    Make any shortcut involving F1 unchangable in the shortcut editor.

 app/widgets/gimpactionview.c |   47 ++++++++++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/app/widgets/gimpactionview.c b/app/widgets/gimpactionview.c
index 5af0387..41a2f98 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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]