'Set the new shortcut and update buttons.'

def set_sequence(self, sequence):

    if ((not sequence) or (self.sequence == sequence)):
        self.button_ok.setEnabled(False)
        different_sequence = False
    else:
        self.button_ok.setEnabled(True)
        different_sequence = True
    if (sys.platform == 'darwin'):
        if ('Meta+Ctrl' in sequence):
            shown_sequence = sequence.replace('Meta+Ctrl', 'Ctrl+Cmd')
        elif ('Ctrl+Meta' in sequence):
            shown_sequence = sequence.replace('Ctrl+Meta', 'Cmd+Ctrl')
        elif ('Ctrl' in sequence):
            shown_sequence = sequence.replace('Ctrl', 'Cmd')
        elif ('Meta' in sequence):
            shown_sequence = sequence.replace('Meta', 'Ctrl')
        else:
            shown_sequence = sequence
    else:
        shown_sequence = sequence
    self.text_new_sequence.setText(shown_sequence)
    self.new_sequence = sequence
    conflicts = self.check_conflicts()
    blacklist = (self.new_sequence in BLACKLIST)
    individual_keys = self.new_sequence.split('+')
    if (conflicts and different_sequence):
        warning_type = SEQUENCE_CONFLICT
    elif blacklist:
        warning_type = IN_BLACKLIST
    elif ((len(individual_keys) == 2) and (individual_keys[0] == 'Shift')):
        warning_type = SHIFT_BLACKLIST
    else:
        warning_type = NO_WARNING
    self.update_warning(warning_type=warning_type, conflicts=conflicts)
