Simplify finalization menu

Addresses issue #220
This commit is contained in:
2Shirt 2023-08-26 16:57:33 -07:00
parent d933ec6415
commit 5147a4105f
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -179,11 +179,9 @@ def get_ddrescue_settings(settings_menu) -> list:
def finalize_recovery(state: State, dry_run: bool = True) -> None:
"""Show recovery finalization options and run selected functions."""
options = (
'Zero-fill Extra Space',
)
toggles = (
'Relocate Backup GPT',
'Zero-fill Gaps',
'Zero-fill Extra Space',
)
# Get destination size
@ -200,7 +198,7 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
len(state.block_pairs) == 1
and not state.source.parent
)
disable_gpt_toggle = not bool(
disable_gpt_option = not bool(
## Breakdown of below tests:
## Only offer this option when cloning a whole, non-child device
## where the source is using a GUID_Partition_Table
@ -216,13 +214,11 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
menu.add_action('Start')
menu.add_action('Quit')
for name in options:
menu.add_option(name, details={'Selected': True})
for name in toggles:
details = {'Selected': True}
if 'GPT' in name and disable_gpt_toggle:
if 'GPT' in name and disable_gpt_option:
details['Disabled'] = True
details['Selected'] = False
menu.add_toggle(name, details)
menu.add_option(name, details)
# Show menu
selection = menu.advanced_select()
@ -230,9 +226,9 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
return
# Run functions
if menu.toggles['Relocate Backup GPT']['Selected']:
if menu.options['Relocate Backup GPT']['Selected']:
relocate_backup_gpt(state, dry_run=dry_run)
if menu.toggles['Zero-fill Gaps']['Selected']:
if menu.options['Zero-fill Gaps']['Selected']:
zero_fill_gaps(
state,
dest_size=dest_size,