From b90d9b67aa0800489ac10012753fcd196ed37475 Mon Sep 17 00:00:00 2001 From: deajan Date: Wed, 5 Mar 2025 08:13:26 +0100 Subject: [PATCH] !fixup: GUI: Hide blocked window when new window appears --- npbackup/gui/__main__.py | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/npbackup/gui/__main__.py b/npbackup/gui/__main__.py index b01c170..7d4182f 100644 --- a/npbackup/gui/__main__.py +++ b/npbackup/gui/__main__.py @@ -325,17 +325,16 @@ def _make_treedata_from_json(ls_result: List[dict]) -> sg.TreeData: return treedata -def ls_window(repo_config: dict, snapshot_id: str) -> bool: - with HideWindow(window): - result = gui_thread_runner( - repo_config, - "ls", - snapshot=snapshot_id, - __stdout=False, - __autoclose=True, - __compact=True, - __backend_binary=backend_binary, - ) +def ls_window(parent_window: sg.Window, repo_config: dict, snapshot_id: str) -> bool: + result = gui_thread_runner( + repo_config, + "ls", + snapshot=snapshot_id, + __stdout=False, + __autoclose=True, + __compact=True, + __backend_binary=backend_binary, + ) if not result or not result["result"]: sg.Popup(_t("main_gui.snapshot_is_empty")) return None, None @@ -425,23 +424,24 @@ def ls_window(repo_config: dict, snapshot_id: str) -> bool: del result gc.collect() - while True: - event, values = window.read() - if event in (sg.WIN_CLOSED, sg.WIN_X_EVENT, "quit", "-WINDOW CLOSE ATTEMPED-"): - break - if event == "restore_to": - if not values["-TREE-"]: - sg.PopupError(_t("main_gui.select_folder"), keep_on_top=True) - continue - restore_window(repo_config, snapshot_id, values["-TREE-"]) + with HideWindow(parent_window): + while True: + event, values = window.read() + if event in (sg.WIN_CLOSED, sg.WIN_X_EVENT, "quit", "-WINDOW CLOSE ATTEMPED-"): + break + if event == "restore_to": + if not values["-TREE-"]: + sg.PopupError(_t("main_gui.select_folder"), keep_on_top=True) + continue + restore_window(repo_config, snapshot_id, values["-TREE-"]) - # Closing a big sg.Tree is really slow - # We can workaround this by emptying the Tree with a new sg.TreeData() object - # before closing the window - window["-TREE-"].update(values=sg.TreeData()) - window.close() - del window - return True + # Closing a big sg.Tree is really slow + # We can workaround this by emptying the Tree with a new sg.TreeData() object + # before closing the window + window["-TREE-"].update(values=sg.TreeData()) + window.close() + del window + return True def restore_window( @@ -1132,8 +1132,8 @@ def _main_gui(viewer_mode: bool): if len(values["snapshot-list"]) > 1: sg.Popup(_t("main_gui.select_only_one_snapshot")) continue - snapshot_to_see = snapshot_list[values["snapshot-list"][0]][0] - ls_window(repo_config, snapshot_to_see) + snapshot_id = snapshot_list[values["snapshot-list"][0]][0] + ls_window(parent_window=window, repo_config=repo_config, snapshot_id=snapshot_id) gc.collect() if event == "--FORGET--": if not full_config: