| 90 | |
| 91 | @dataclass |
| 92 | class BootloaderConfiguration(SubConfig): |
| 93 | bootloader: Bootloader |
| 94 | uki: bool = False |
| 95 | removable: bool = True |
| 96 | plymouth: PlymouthTheme | None = None |
| 97 | |
| 98 | @override |
| 99 | def json(self) -> dict[str, Any]: |
| 100 | data = {'bootloader': self.bootloader.json(), 'uki': self.uki, 'removable': self.removable} |
| 101 | |
| 102 | if self.plymouth is not None: |
| 103 | data['plymouth'] = self.plymouth.value |
| 104 | return data |
| 105 | |
| 106 | @override |
| 107 | def summary(self) -> list[str]: |
| 108 | out = [tr('Bootloader "{}"').format(self.bootloader.value)] |
| 109 | |
| 110 | if self.uki: |
| 111 | out.append(tr('UKI enabled')) |
| 112 | if self.removable: |
| 113 | out.append(tr('Removable')) |
| 114 | if self.plymouth is not None: |
| 115 | out.append(tr('Plymouth "{}"').format(self.plymouth.value)) |
| 116 | |
| 117 | return out |
| 118 | |
| 119 | @classmethod |
| 120 | def parse_arg(cls, config: dict[str, Any], skip_boot: bool) -> Self: |
| 121 | bootloader = Bootloader.from_arg(config.get('bootloader', ''), skip_boot) |
| 122 | uki = config.get('uki', False) |
| 123 | removable = config.get('removable', True) |
| 124 | plymouth = PlymouthTheme.from_arg(config.get('plymouth', None)) |
| 125 | return cls(bootloader=bootloader, uki=uki, removable=removable, plymouth=plymouth) |
| 126 | |
| 127 | @classmethod |
| 128 | def get_default(cls, uefi: bool, skip_boot: bool = False) -> Self: |
| 129 | bootloader = Bootloader.get_default(uefi, skip_boot) |
| 130 | removable = uefi and bootloader.has_removable_support() |
| 131 | uki = uefi and bootloader.has_uki_support() |
| 132 | plymouth = None |
| 133 | return cls(bootloader=bootloader, uki=uki, removable=removable, plymouth=plymouth) |
| 134 | |
| 135 | def preview(self, uefi: bool) -> str: |
| 136 | text = f'{tr("Bootloader")}: {self.bootloader.value}' |
| 137 | text += '\n' |
| 138 | if uefi and self.bootloader.has_uki_support(): |
| 139 | if self.uki: |
| 140 | uki_string = tr('Enabled') |
| 141 | else: |
| 142 | uki_string = tr('Disabled') |
| 143 | text += f'UKI: {uki_string}' |
| 144 | text += '\n' |
| 145 | if uefi and self.bootloader.has_removable_support(): |
| 146 | if self.removable: |
| 147 | removable_string = tr('Enabled') |
| 148 | else: |
| 149 | removable_string = tr('Disabled') |
no outgoing calls