[gtk/fix-action-muxer-signals] actionmuxer: Don't emit signals for irrelevant changes



commit 8d8005d892a50d2d9d005ee776f860214dca1b0e
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Feb 4 12:45:07 2020 +0100

    actionmuxer: Don't emit signals for irrelevant changes
    
    If the action muxer has an action, there is no need to
    react to parent changes for that same action.
    
    Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2398

 gtk/gtkactionmuxer.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkactionmuxer.c b/gtk/gtkactionmuxer.c
index 521f77e6f0..c44bbf7426 100644
--- a/gtk/gtkactionmuxer.c
+++ b/gtk/gtkactionmuxer.c
@@ -357,7 +357,8 @@ gtk_action_muxer_action_added_to_parent (GActionGroup *action_group,
 {
   GtkActionMuxer *muxer = user_data;
 
-  gtk_action_muxer_action_added (muxer, action_name, action_group, action_name);
+  if (!gtk_action_muxer_find_group (muxer, action_name, NULL))
+    gtk_action_muxer_action_added (muxer, action_name, action_group, action_name);
 }
 
 static void
@@ -394,7 +395,8 @@ gtk_action_muxer_action_removed_from_parent (GActionGroup *action_group,
 {
   GtkActionMuxer *muxer = user_data;
 
-  gtk_action_muxer_action_removed (muxer, action_name);
+  if (!gtk_action_muxer_find_group (muxer, action_name, NULL))
+    gtk_action_muxer_action_removed (muxer, action_name);
 }
 
 static void
@@ -1132,7 +1134,10 @@ gtk_action_muxer_set_parent (GtkActionMuxer *muxer,
 
       actions = g_action_group_list_actions (G_ACTION_GROUP (muxer->parent));
       for (it = actions; *it; it++)
-        gtk_action_muxer_action_removed (muxer, *it);
+        {
+          if (!gtk_action_muxer_find (muxer, *it, NULL))
+            gtk_action_muxer_action_removed (muxer, *it);
+        }
       g_strfreev (actions);
 
       emit_changed_accels (muxer, muxer->parent);
@@ -1157,7 +1162,10 @@ gtk_action_muxer_set_parent (GtkActionMuxer *muxer,
 
       actions = g_action_group_list_actions (G_ACTION_GROUP (muxer->parent));
       for (it = actions; *it; it++)
-        gtk_action_muxer_action_added (muxer, *it, G_ACTION_GROUP (muxer->parent), *it);
+        {
+          if (!gtk_action_muxer_find (muxer, *it, NULL))
+            gtk_action_muxer_action_added (muxer, *it, G_ACTION_GROUP (muxer->parent), *it);
+        }
       g_strfreev (actions);
 
       emit_changed_accels (muxer, muxer->parent);


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