mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-05 20:44:51 +08:00
!fixup: GUI: Refactor file/folder icons
This commit is contained in:
parent
f26e40c760
commit
b677bbd616
4 changed files with 20 additions and 12 deletions
|
@ -34,6 +34,8 @@ from resources.customization import (
|
||||||
INHERITED_IRREGULAR_FILE_ICON,
|
INHERITED_IRREGULAR_FILE_ICON,
|
||||||
MISSING_FILE_ICON,
|
MISSING_FILE_ICON,
|
||||||
INHERITED_MISSING_FILE_ICON,
|
INHERITED_MISSING_FILE_ICON,
|
||||||
|
SYMLINK_ICON,
|
||||||
|
INHERITED_SYMLINK_ICON,
|
||||||
)
|
)
|
||||||
from npbackup.task import create_scheduled_task
|
from npbackup.task import create_scheduled_task
|
||||||
|
|
||||||
|
@ -271,22 +273,27 @@ def config_gui(full_config: dict, config_file: str):
|
||||||
if not file_path:
|
if not file_path:
|
||||||
icon = MISSING_FILE_ICON
|
icon = MISSING_FILE_ICON
|
||||||
inherited_icon = INHERITED_MISSING_FILE_ICON
|
inherited_icon = INHERITED_MISSING_FILE_ICON
|
||||||
|
elif os.path.isdir(file_path):
|
||||||
|
if os.access(file_path, os.X_OK):
|
||||||
|
icon = FOLDER_ICON
|
||||||
|
inherited_icon = INHERITED_FOLDER_ICON
|
||||||
|
else:
|
||||||
|
icon = IRREGULAR_FILE_ICON
|
||||||
|
inherited_icon = INHERITED_IRREGULAR_FILE_ICON
|
||||||
elif os.path.isfile(file_path):
|
elif os.path.isfile(file_path):
|
||||||
icon = FILE_ICON
|
icon = FILE_ICON
|
||||||
inherited_icon = INHERITED_FILE_ICON
|
inherited_icon = INHERITED_FILE_ICON
|
||||||
elif os.path.isdir(file_path):
|
|
||||||
icon = FOLDER_ICON
|
|
||||||
inherited_icon = INHERITED_FOLDER_ICON
|
|
||||||
elif os.path.islink(file_path):
|
elif os.path.islink(file_path):
|
||||||
icon = IRREGULAR_FILE_ICON
|
icon = SYMLINK_ICON
|
||||||
inherited_icon = INHERITED_IRREGULAR_FILE_ICON
|
inherited_icon = INHERITED_SYMLINK_ICON
|
||||||
else:
|
else:
|
||||||
icon = MISSING_FILE_ICON
|
icon = MISSING_FILE_ICON
|
||||||
inherited_icon = INHERITED_MISSING_FILE_ICON
|
inherited_icon = INHERITED_MISSING_FILE_ICON
|
||||||
except (OSError, PermissionError, TypeError):
|
except (OSError, PermissionError, TypeError) as exc:
|
||||||
# We might not be able to check paths that are not present
|
# We might not be able to check paths that are not present
|
||||||
# on current computer when preparing configuration files
|
# on current computer when preparing configuration files
|
||||||
# In that case, just assume it's a file
|
# In that case, just assume it's a file
|
||||||
|
logger.debug(f"Current path {file_path} cannot be processed: {exc}")
|
||||||
icon = IRREGULAR_FILE_ICON
|
icon = IRREGULAR_FILE_ICON
|
||||||
inherited_icon = INHERITED_IRREGULAR_FILE_ICON
|
inherited_icon = INHERITED_IRREGULAR_FILE_ICON
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
BIN
resources/inherited_symlink_icon.png
Normal file
BIN
resources/inherited_symlink_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 660 B |
|
@ -7,7 +7,7 @@ __intname__ = "npbackup.customization_creator"
|
||||||
__author__ = "Orsiris de Jong"
|
__author__ = "Orsiris de Jong"
|
||||||
__copyright__ = "Copyright (C) 2024-2025 NetInvent"
|
__copyright__ = "Copyright (C) 2024-2025 NetInvent"
|
||||||
__license__ = "GPL-3.0-only"
|
__license__ = "GPL-3.0-only"
|
||||||
__build__ = "2025041601"
|
__build__ = "2025051101"
|
||||||
__version__ = "1.0.0"
|
__version__ = "1.0.0"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -45,10 +45,11 @@ def update_custom_icons():
|
||||||
"INHERITED_IRREGULAR_FILE_ICON": "inherited_irregular_file_icon.png",
|
"INHERITED_IRREGULAR_FILE_ICON": "inherited_irregular_file_icon.png",
|
||||||
"INHERITED_NEUTRAL_ICON": "inherited_neutral_icon.png",
|
"INHERITED_NEUTRAL_ICON": "inherited_neutral_icon.png",
|
||||||
"INHERITED_TREE_ICON": "inherited_tree_icon.png",
|
"INHERITED_TREE_ICON": "inherited_tree_icon.png",
|
||||||
"IRREGULER_FILE_ICON": "irregular_file_icon.png",
|
"IRREGULAR_FILE_ICON": "irregular_file_icon.png",
|
||||||
"NON_INHERITED_ICON": "non_inherited_icon.png",
|
"NON_INHERITED_ICON": "non_inherited_icon.png",
|
||||||
"MISSING_FILE_ICON": "missing_file_icon.png",
|
"MISSING_FILE_ICON": "missing_file_icon.png",
|
||||||
"INHERITED_MISSING_FILE_ICON": "inherited_missing_file_icon.png",
|
"INHERITED_MISSING_FILE_ICON": "inherited_missing_file_icon.png",
|
||||||
|
"INHERITED_SYMLINK_ICON": "inherited_symlink_icon.png",
|
||||||
"SYMLINK_ICON": "symlink_icon.png",
|
"SYMLINK_ICON": "symlink_icon.png",
|
||||||
"TREE_ICON": "tree_icon.png",
|
"TREE_ICON": "tree_icon.png",
|
||||||
"LOADING_ANIMATION": "loading.gif",
|
"LOADING_ANIMATION": "loading.gif",
|
||||||
|
@ -62,12 +63,11 @@ def update_custom_icons():
|
||||||
customization = f.read()
|
customization = f.read()
|
||||||
for var_name, file in custom_resources.items():
|
for var_name, file in custom_resources.items():
|
||||||
file_path = os.path.join(resources_dir, file)
|
file_path = os.path.join(resources_dir, file)
|
||||||
print(file_path)
|
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
print(f"Updating {var_name} with {file_path}")
|
print(f"Updating {var_name} with {file_path}")
|
||||||
encoded_b64 = image_to_data_url(file_path)
|
encoded_b64 = image_to_data_url(file_path)
|
||||||
customization = re.sub(
|
customization = re.sub(
|
||||||
f'{var_name} = b".*"', f'{var_name} = b"{encoded_b64}"', customization
|
f'\n{var_name} = .*', f'\n{var_name} = b"{encoded_b64}"', customization, re.MULTILINE
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("No file found for", var_name)
|
print("No file found for", var_name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue