[gimp] app: delete the previous mapping when changing modifier.



commit 60d08c87f48bebfc5805bcc8bb2cffeda3f150a1
Author: Jehan <jehan girinstud io>
Date:   Sun Aug 21 12:50:17 2022 +0200

    app: delete the previous mapping when changing modifier.
    
    Previously, when updating a modifier mapping, we ended up with a
    duplicate for the same action.

 app/widgets/gimpmodifierseditor.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/app/widgets/gimpmodifierseditor.c b/app/widgets/gimpmodifierseditor.c
index 4e1414cdaf..f19829a677 100644
--- a/app/widgets/gimpmodifierseditor.c
+++ b/app/widgets/gimpmodifierseditor.c
@@ -477,6 +477,7 @@ gimp_modifiers_editor_add_mapping (GimpModifiersEditor *editor,
                     editor);
   gtk_widget_show (minus_button);
 
+  g_object_set_data (G_OBJECT (shortcut), "shortcut-modifiers", GINT_TO_POINTER (modifiers));
   g_object_set_data (G_OBJECT (shortcut), "shortcut-button", shortcut);
   g_object_set_data (G_OBJECT (shortcut), "shortcut-action", combo);
   g_object_set_data (G_OBJECT (shortcut), "shortcut-action-action", action_button);
@@ -557,8 +558,10 @@ gimp_modifiers_editor_notify_accelerator (GtkWidget           *widget,
   GtkWidget          *combo;
   GtkWidget          *action_button;
   GimpModifierAction  action = GIMP_MODIFIER_ACTION_NONE;
+  GdkModifierType     old_modifiers;
+  GdkModifierType     modifiers;
 
-  GdkModifierType  modifiers;
+  old_modifiers = (GdkModifierType) g_object_get_data (G_OBJECT (widget), "shortcut-modifiers");
 
   shortcut      = g_object_get_data (G_OBJECT (widget), "shortcut-button");
   combo         = g_object_get_data (G_OBJECT (widget), "shortcut-action");
@@ -566,6 +569,12 @@ gimp_modifiers_editor_notify_accelerator (GtkWidget           *widget,
 
   gimp_shortcut_button_get_keys (GIMP_SHORTCUT_BUTTON (shortcut), NULL, &modifiers);
 
+  if (old_modifiers != modifiers)
+    gimp_modifiers_manager_remove (editor->priv->manager, editor->priv->device,
+                                   editor->priv->button, old_modifiers);
+
+  g_object_set_data (G_OBJECT (shortcut), "shortcut-modifiers", GINT_TO_POINTER (modifiers));
+
   if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), (gint *) &action))
     {
       const gchar *action_desc;


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