(self)
Parse bindings and mangle into an appropriate form
Parse bindings and mangle into an appropriate form
Parse bindings and mangle into an appropriate form
def reload(self):
        """Parse bindings and mangle into an appropriate form"""
        self._lookup = {}
        self._masks = 0
        for action, bindings in list(self.keys.items()):
            if not isinstance(bindings, tuple):
                bindings = (bindings,)

            for binding in bindings:
                if not binding or binding == "None":
                    continue

                try:
                    keyval, mask = self._parsebinding(binding)
                    # Does much the same, but with poorer error handling.
                    #keyval, mask = Gtk.accelerator_parse(binding)
                except KeymapError as e:
                  err ("keybindings.reload failed to parse binding '%s': %s" % (binding, e))
                else:
                    if mask & Gdk.ModifierType.SHIFT_MASK:
                        if keyval == Gdk.KEY_Tab:
                            keyval = Gdk.KEY_ISO_Left_Tab
                            mask &= ~Gdk.ModifierType.SHIFT_MASK
                        else:
                            keyvals = Gdk.keyval_convert_case(keyval)
                            if keyvals[0] != keyvals[1]:
                                keyval = keyvals[1]
                                mask &= ~Gdk.ModifierType.SHIFT_MASK
                    else:
                        keyval = Gdk.keyval_to_lower(keyval)
                    self._lookup.setdefault(mask, {})
                    self._lookup[mask][keyval] = action
                    self._masks |= mask
def reload ( self ) : self . _lookup = { } self . _masks = 0 for action , bindings in list ( self . keys . items ( ) ) : if not isinstance ( bindings , tuple ) : bindings = ( bindings , ) for binding in bindings : if not binding or binding == "None" : continue try : keyval , mask = self . _parsebinding ( binding ) # Does much the same, but with poorer error handling. #keyval, mask = Gtk.accelerator_parse(binding) except KeymapError as e : err ( "keybindings.reload failed to parse binding '%s': %s" % ( binding , e ) ) else : if mask & Gdk . ModifierType . SHIFT_MASK : if keyval == Gdk . KEY_Tab : keyval = Gdk . KEY_ISO_Left_Tab mask &= ~ Gdk . ModifierType . SHIFT_MASK else : keyvals = Gdk . keyval_convert_case ( keyval ) if keyvals [ 0 ] != keyvals [ 1 ] : keyval = keyvals [ 1 ] mask &= ~ Gdk . ModifierType . SHIFT_MASK else : keyval = Gdk . keyval_to_lower ( keyval ) self . _lookup . setdefault ( mask , { } ) self . _lookup [ mask ] [ keyval ] = action self . _masks |= mask