Files
Py-Backup/pyimage_ui/header_frame.py
Désiré Werner Menrath 2d685e1d97 refactor: Rework encrypted backup UI and logic
- Centralizes backup content view logic into a single BackupContentFrame.
- Removes the separate, now obsolete EncryptedBackupContentFrame.
- Adds a toggle button within the BackupContentFrame to switch between viewing normal and encrypted backups.
- Centralizes the Restore, Delete, and Edit Comment buttons into a single button bar in BackupContentFrame.
- Corrects the path resolution logic to find backups and encrypted containers within the /pybackup subdirectory.
- Fixes UI bugs where action buttons would disappear when switching tabs.
2025-09-04 23:22:12 +02:00

98 lines
3.3 KiB
Python

import tkinter as tk
import os
from pbp_app_config import Msg
from shared_libs.common_tools import IconManager
class HeaderFrame(tk.Frame):
def __init__(self, container, image_manager, encryption_manager, app, **kwargs):
super().__init__(container, bg="#455A64", **kwargs)
self.image_manager = image_manager
self.encryption_manager = encryption_manager
self.app = app
# Configure grid weights for internal layout
self.columnconfigure(1, weight=1) # Make the middle column expand
self.rowconfigure(0, weight=1) # Make the top row expand
# Left side: Icon and Main Title/Subtitle
left_frame = tk.Frame(self, bg="#455A64")
left_frame.grid(row=0, column=0, rowspan=2, sticky="nsew")
left_frame.columnconfigure(0, weight=1)
left_frame.rowconfigure(0, weight=1)
icon_label = tk.Label(
left_frame,
image=self.image_manager.get_icon(
"backup_extralarge"), # Using a generic backup icon
bg="#455A64",
)
icon_label.grid(row=0, column=0, sticky="e", padx=10, pady=5)
title_label = tk.Label(
self,
text=Msg.STR["header_title"],
font=("Helvetica", 16, "bold"),
fg="#ffffff",
bg="#455A64",
)
title_label.grid(row=0, column=1, sticky="w",
padx=(5, 20), pady=(15, 5))
subtitle_label = tk.Label(
self,
text=Msg.STR["header_subtitle"],
font=("Helvetica", 10),
fg="#bdc3c7",
bg="#455A64",
)
subtitle_label.grid(row=1, column=1, sticky="w",
padx=(5, 20), pady=(0, 10))
# Right side: Keyring status
right_frame = tk.Frame(self, bg="#455A64")
right_frame.grid(row=0, column=2, rowspan=2, sticky="nsew")
right_frame.columnconfigure(0, weight=1)
right_frame.rowconfigure(0, weight=1)
self.keyring_status_label = tk.Label(
right_frame,
text="",
font=("Helvetica", 10, "bold"),
bg="#455A64",
)
self.keyring_status_label.grid(row=0, column=0, sticky="ne", padx=(10, 10), pady=(10, 0))
self.refresh_status()
def refresh_status(self):
"""Checks the keyring status based on the current destination and updates the label."""
dest_path = self.app.destination_path
if not dest_path:
self.keyring_status_label.config(
text="Keyring: N/A",
fg="#A9A9A9" # DarkGray
)
return
username = os.path.basename(dest_path.rstrip('/'))
mapper_name = f"pybackup_{username}"
mount_point = f"/mnt/{mapper_name}"
if os.path.ismount(mount_point):
self.keyring_status_label.config(
text="Keyring: In Use",
fg="#2E8B57" # SeaGreen
)
elif self.encryption_manager.is_key_in_keyring(username):
self.keyring_status_label.config(
text="Keyring: Available",
fg="#FFD700" # Gold
)
else:
self.keyring_status_label.config(
text="Keyring: Not in Use",
fg="#A9A9A9" # DarkGray
)