@@ -859,12 +859,38 @@ def maybe_update_binding(self, current_keybinding, accel_string, accel_label, po
859859 self ._proxy_send_kb_changed (current_keybinding )
860860 return True
861861
862+ def _filter_duplicate_applet_keybindings (self , keybindings ):
863+ all_same = False
864+ by_uuids = {}
865+
866+ ret = []
867+
868+ for keybinding in keybindings :
869+ uuid = keybinding .dbus_info .get ("uuid" , None )
870+ if uuid is None :
871+ ret .append (keybinding )
872+ continue
873+
874+ try :
875+ by_uuids [uuid ].append (keybinding )
876+ except KeyError :
877+ by_uuids [uuid ] = [keybinding ]
878+
879+ for uuid in by_uuids .keys ():
880+ ret .append (by_uuids [uuid ][- 1 ])
881+
882+ return ret
883+
862884 def check_for_collisions (self ):
863885 dupes = [dupe for dupe in self ._collision_table .keys () if len (self ._collision_table [dupe ]) > 1 ]
864886
865887 if len (dupes ) == 0 :
866888 return
867889 for accel_string in dupes :
890+ bindings = self ._filter_duplicate_applet_keybindings (self ._collision_table [accel_string ])
891+ if len (bindings ) < 2 :
892+ continue
893+
868894 key , codes , mods = Gtk .accelerator_parse_with_keycode (accel_string )
869895 if (key == 0 and len (codes ) == 0 ):
870896 if accel_string == "XF86Keyboard" :
@@ -884,17 +910,17 @@ def check_for_collisions(self):
884910 msg += _ ("Choose the assignment you wish to keep. The others will be cleared." )
885911 dialog .set_markup (msg % {'combination' : escape (label )})
886912
887- for i in range (len (self . _collision_table [ accel_string ] )):
888- keybinding = self . _collision_table [ accel_string ] [i ]
913+ for i in range (len (bindings )):
914+ keybinding = bindings [i ]
889915 dialog .add_button (keybinding .label , i )
890916
891917 dialog .show_all ()
892918 response = dialog .run ()
893919 dialog .destroy ()
894920
895921 try :
896- keep_keybinding = self . _collision_table [ accel_string ] [response ]
897- for keybinding in self . _collision_table [ accel_string ] :
922+ keep_keybinding = bindings [response ]
923+ for keybinding in bindings :
898924 if keybinding != keep_keybinding :
899925 for i in range (len (keybinding .entries )):
900926 if keybinding .entries [i ] == accel_string :
0 commit comments