Index: keybindings.py
===================================================================
RCS file: /cvs/gnome/orca/src/orca/keybindings.py,v
retrieving revision 1.10
diff -u -r1.10 keybindings.py
--- keybindings.py	6 Oct 2006 07:59:03 -0000	1.10
+++ keybindings.py	31 Oct 2006 11:42:45 -0000
@@ -64,6 +64,31 @@
             _keycodeCache[keysym] = 0
     return _keycodeCache[keysym]
 
+def getModifiersNames(mods):
+    """ Gets the modifier names of a numeric modifier mask
+    """
+
+    text = ""
+    if mods & 256:
+        text += "Ins+"
+    if mods & 128:
+        text += "Alt_R+"
+    if mods & 64:
+        text += "Super+"
+    if mods & 32:
+        text += "??+"
+    #if mods & 16:
+    #    text += "Num_Lock+"
+    if mods & 8:
+        text += "Alt_L+"
+    if mods & 4:
+        text += "Ctrl+"
+    #if mods & 2:
+    #    text += "Caps_Lock+"
+    if mods & 1:
+        text += "Shift+"
+    return text
+
 class KeyBinding:
     """A single key binding, consisting of a keycode, a modifier mask,
     and the InputEventHandler.
@@ -129,6 +154,35 @@
             if keyBinding == self.keyBindings[i]:
                 del self.keyBindings[i]
 
+    def hasKeyBinding (self, newKeyBinding, typeOfSearch="strict"):
+        """Return True if keyBinding is already in self.keyBindings.
+        
+           The typeOfSearch can be:
+              "strict":      matches everything (description, modifiers and key).
+              "description": matches only description.
+              "keys":        matches only modifiers and key.
+        """
+        
+        hasIt = False
+        
+        for keyBinding in self.keyBindings:
+            if typeOfSearch == "strict":
+                if keyBinding.handler._description == newKeyBinding.handler._description and \
+                    keyBinding.keysymstring        == newKeyBinding.keysymstring and \
+                    keyBinding.modifier_mask       == newKeyBinding.modifier_mask and \
+                    keyBinding.modifiers           == newKeyBinding.modifiers:
+                        hasIt = True
+            elif typeOfSearch == "description":
+                if keyBinding.handler._description == newKeyBinding.handler._description:
+                        hasIt = True
+            elif typeOfSearch == "keys":
+                if keyBinding.keysymstring   == newKeyBinding.keysymstring and \
+                    keyBinding.modifier_mask == newKeyBinding.modifier_mask and \
+                    keyBinding.modifiers     == newKeyBinding.modifiers:
+                        hasIt = True
+            
+        return hasIt
+        
     def getInputHandler(self, keyboardEvent):
         """Returns the input handler of the key binding that matches the
         given keycode and modifiers, or None if no match exists.
