mirror of
https://forge.fsky.io/oneflux/omegafox.git
synced 2026-02-10 13:22:05 -08:00
Merge pull request #203 from alternativshik/main
Minor dev UI improvements
This commit is contained in:
commit
1b7cf7b7a5
2 changed files with 58 additions and 25 deletions
|
|
@ -77,9 +77,8 @@ def list_patches(root_dir='../patches', suffix='*.patch'):
|
||||||
"""List all patch files"""
|
"""List all patch files"""
|
||||||
return sorted(list_files(root_dir, suffix), key=os.path.basename)
|
return sorted(list_files(root_dir, suffix), key=os.path.basename)
|
||||||
|
|
||||||
|
|
||||||
def is_bootstrap_patch(name):
|
def is_bootstrap_patch(name):
|
||||||
re.match(r'\d+\-.*', os.path.basename(name))
|
return bool(re.match(r'\d+\-.*', os.path.basename(name)))
|
||||||
|
|
||||||
|
|
||||||
def script_exit(statuscode):
|
def script_exit(statuscode):
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,11 @@
|
||||||
"""
|
"""
|
||||||
GUI for managing Camoufox patches.
|
GUI for managing Camoufox patches.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import easygui
|
import easygui
|
||||||
|
|
||||||
from _mixin import find_src_dir, is_bootstrap_patch, list_patches, patch, run, temp_cd
|
from _mixin import find_src_dir, is_bootstrap_patch, list_patches, patch, run, temp_cd
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,17 +29,39 @@ def reset_camoufox():
|
||||||
def run_patches(reverse=False):
|
def run_patches(reverse=False):
|
||||||
"""Apply patches"""
|
"""Apply patches"""
|
||||||
patch_files = list_patches()
|
patch_files = list_patches()
|
||||||
if reverse:
|
|
||||||
title = "Unpatch files"
|
|
||||||
else:
|
|
||||||
title = "Patch files"
|
|
||||||
selected_patches = easygui.multchoicebox(title, "Patches", patch_files)
|
|
||||||
if not selected_patches:
|
|
||||||
return
|
|
||||||
|
|
||||||
for patch_file in selected_patches:
|
# Create a display list with status labels and a reverse lookup mapping
|
||||||
|
display_choices = []
|
||||||
|
mapping = {}
|
||||||
|
for patch_file in patch_files:
|
||||||
|
# If the patch is a bootstrap patch, mark it with the appropriate label
|
||||||
|
if is_bootstrap_patch(patch_file):
|
||||||
|
status = "BOOTSTRAP"
|
||||||
|
else:
|
||||||
|
can_apply, can_reverse, broken = check_patch(patch_file)
|
||||||
|
if broken:
|
||||||
|
status = "BROKEN"
|
||||||
|
elif can_reverse:
|
||||||
|
status = "APPLIED"
|
||||||
|
elif can_apply:
|
||||||
|
status = "NOT APPLIED"
|
||||||
|
else:
|
||||||
|
status = "UNKNOWN"
|
||||||
|
# Format the display string (remove the '../patches/' prefix)
|
||||||
|
display_name = f"[{status}] {patch_file[len('../patches/'):].strip()}"
|
||||||
|
display_choices.append(display_name)
|
||||||
|
mapping[display_name] = patch_file
|
||||||
|
|
||||||
|
title = "Unpatch files" if reverse else "Patch files"
|
||||||
|
selected_display = easygui.multchoicebox(title, "Patches", display_choices, preselect=[])
|
||||||
|
if not selected_display:
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Convert the selected items back to filenames
|
||||||
|
for display_name in selected_display:
|
||||||
|
patch_file = mapping[display_name]
|
||||||
patch(patch_file, reverse=reverse)
|
patch(patch_file, reverse=reverse)
|
||||||
|
return True
|
||||||
|
|
||||||
def open_patch_workspace(selected_patch, stop_at_patch=False):
|
def open_patch_workspace(selected_patch, stop_at_patch=False):
|
||||||
"""
|
"""
|
||||||
|
|
@ -223,12 +244,14 @@ def handle_choice(choice):
|
||||||
easygui.msgbox("Checkpoint set.", "Checkpoint Set")
|
easygui.msgbox("Checkpoint set.", "Checkpoint Set")
|
||||||
|
|
||||||
case "Select patches":
|
case "Select patches":
|
||||||
run_patches(reverse=False)
|
result = run_patches(reverse=False)
|
||||||
easygui.msgbox("Patching completed.", "Patching Complete")
|
if result:
|
||||||
|
easygui.msgbox("Patching completed.", "Patching Complete")
|
||||||
|
|
||||||
case "Reverse patches":
|
case "Reverse patches":
|
||||||
run_patches(reverse=True)
|
result = run_patches(reverse=True)
|
||||||
easygui.msgbox("Unpatching completed.", "Unpatching Complete")
|
if result:
|
||||||
|
easygui.msgbox("Unpatching completed.", "Unpatching Complete")
|
||||||
|
|
||||||
case "Find broken patches (resets workspace)":
|
case "Find broken patches (resets workspace)":
|
||||||
reset_camoufox()
|
reset_camoufox()
|
||||||
|
|
@ -277,13 +300,24 @@ def handle_choice(choice):
|
||||||
|
|
||||||
case "Edit a patch":
|
case "Edit a patch":
|
||||||
patch_files = list_patches()
|
patch_files = list_patches()
|
||||||
ui_choices = [
|
ui_choices = []
|
||||||
(
|
for n, file_name in enumerate(patch_files):
|
||||||
f'{n+1}. {"BOOTSTRAP:" if is_bootstrap_patch(file_name) else ""} '
|
# If the patch is bootstrap, label it
|
||||||
f'{file_name[len("../patches/") :]}'
|
if is_bootstrap_patch(file_name):
|
||||||
)
|
status = "BOOTSTRAP"
|
||||||
for n, file_name in enumerate(patch_files)
|
else:
|
||||||
]
|
can_apply, can_reverse, broken = check_patch(file_name)
|
||||||
|
if broken:
|
||||||
|
status = "BROKEN"
|
||||||
|
elif can_reverse:
|
||||||
|
status = "APPLIED"
|
||||||
|
elif can_apply:
|
||||||
|
status = "NOT APPLIED"
|
||||||
|
else:
|
||||||
|
status = "UNKNOWN"
|
||||||
|
display_name = f"{n+1}. [{status}] {file_name[len('../patches/'):]}".strip()
|
||||||
|
ui_choices.append(display_name)
|
||||||
|
|
||||||
selected_patch = easygui.choicebox(
|
selected_patch = easygui.choicebox(
|
||||||
"Select patch to open in workspace",
|
"Select patch to open in workspace",
|
||||||
"Patches",
|
"Patches",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue