From 69a881cee8c96eb6f40a3554ce3828cd73a86709 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Sat, 24 Jan 2026 09:11:54 +0900 Subject: [PATCH] feat: emit warning if icon is missing --- dzgui/controllers/mc.py | 6 +- dzgui/util/strings.py | 147 +++++++++++++++++++++++----------------- dzgui/views/base.py | 13 ++-- 3 files changed, 94 insertions(+), 72 deletions(-) diff --git a/dzgui/controllers/mc.py b/dzgui/controllers/mc.py index d668b2d..59e373e 100644 --- a/dzgui/controllers/mc.py +++ b/dzgui/controllers/mc.py @@ -467,7 +467,7 @@ class Controller(GObject.GObject): # NOTE: manipulates mod store case ContextMenu.DELETE_MOD: self.delete_single_mod(path) - # TODO: hook treeview changed signal + # TODO: hook treeview changed signal automatically # Gtk.TreeModel, row-inserted/row-deleted self.update_mod_statusbar() remove_stale_signatures( @@ -539,7 +539,6 @@ class Controller(GObject.GObject): import time time.sleep(1) - # TODO: use model managers, etc. self.data = ( ["BAR", "a", "a", "a", 1, 1, 1, "185.207.214.16:2302", 0, 0, "a", False], ["BAR", "a", "a", "a", 1, 1, 1, "172.111.51.156:2302", 0, 0, "a", False], @@ -564,9 +563,7 @@ class Controller(GObject.GObject): def dump_test_2(self) -> None: import time - time.sleep(1) - # TODO: use model managers, etc. self.data = ( ["BAR", "a", "a", "a", 1, 1, 1, "185.207.214.16:2302", 0, 0, "a", False], ) @@ -582,6 +579,7 @@ class Controller(GObject.GObject): for row in data: manager.append_row(row) treeview.set_loaded(True) + # TODO: emit custom "servers finished loading" signal self.mediator.statusbar.emit("server_page_changed", context) treeview.grab_focus() diff --git a/dzgui/util/strings.py b/dzgui/util/strings.py index 31c0365..94529cd 100644 --- a/dzgui/util/strings.py +++ b/dzgui/util/strings.py @@ -2,6 +2,7 @@ from dataclasses import dataclass from dzgui.const.constants import SYSTEM_LOG + def build_missing(build: str) -> str: msg = ( f"This server is running {build}. You can install " @@ -20,6 +21,7 @@ def build_path_invalid(build: str) -> str: ) return msg + # General dialog_header = "DZGUI - Dialog" dz = "DayZ" @@ -93,21 +95,24 @@ something_wrong = "Something went wrong. See the detailed error below." steam_key_missing = "No Steam API key is set." malformed_mods = "Found mods on system, but was unable to parse results." steam_missing = "Local Steam installation is not set, possibly malformed config file." -build_corrupted = "Steam settings or DayZ installation may be corrupted. Try restarting Steam." +build_corrupted = ( + "Steam settings or DayZ installation may be corrupted. Try restarting Steam." +) api_warn_msg = """No servers returned. Possible causes: no servers in favorites/history, local network issue, or API key on cooldown. Return to the main menu, wait 30s, and try again. If this issue persists, your API key may be defunct. """ server_timeout = "Timed out when querying server, check IP or try again later" -server_error = "Error while contacting server, possibly timed out. Please wait and try again." -server_protected = ( +server_error = ( + "Error while contacting server, possibly timed out. Please wait and try again." +) +server_protected = ( "This server is password-protected and you will be " "prompted when connecting. Do you want to proceed?" ) - # KeybindingsDialog navigation = { "Enter/space/double click": "select row item", @@ -155,13 +160,9 @@ label_main_menu = "Main menu" # buttons ping_servers = "Ping servers" debug_mode = "Debug mode" -debug_tooltip = ( - "Used to perform a dry run without\n" - "actually connecting to a server" -) +debug_tooltip = "Used to perform a dry run without\n" "actually connecting to a server" ping_tooltip = ( - "Refresh the ping for visible servers.\n" - "Available once per unique filter context" + "Refresh the ping for visible servers.\n" "Available once per unique filter context" ) # statusbar_helptext = "Select a row to see its detailed description" @@ -235,12 +236,14 @@ class Dialog: working: str updating_mods: str + @dataclass(slots=True, frozen=True) class Init: is_steam_running: str is_dayz_running: str requires_steam: str + @dataclass(slots=True, frozen=True) class Button: servers_label: str @@ -254,6 +257,7 @@ class Button: exit_label: str exit_tooltip: str + @dataclass(slots=True, frozen=True) class Crumbs: changelog: str @@ -266,12 +270,14 @@ class Crumbs: thanks: str developers: str + @dataclass(slots=True, frozen=True) class Thanks: header: str description: str users: list[str] + @dataclass(slots=True, frozen=True) class Options: header: str @@ -310,42 +316,43 @@ class Options: testing: str manual_sub_msg: str + init = Init( - is_steam_running = "Is Steam running? DZGUI must be run on top of Steam.", - is_dayz_running = "Is DayZ already running? DZGUI cannot launch DayZ if another process is using it.", - requires_steam = "DZGUI requires that Steam or Flatpak Steam be installed on the system.", + is_steam_running="Is Steam running? DZGUI must be run on top of Steam.", + is_dayz_running="Is DayZ already running? DZGUI cannot launch DayZ if another process is using it.", + requires_steam="DZGUI requires that Steam or Flatpak Steam be installed on the system.", ) mod_panel = ModPanelStrings( - header = "Mod actions", - unhighlight_stale = "Unhighlight stale", - unhighlight_stale_tooltip = "Clears highlight from stale mods", - highlight_stale = "Highlight stale", - highlight_stale_tooltip = ( + header="Mod actions", + unhighlight_stale="Unhighlight stale", + unhighlight_stale_tooltip="Clears highlight from stale mods", + highlight_stale="Highlight stale", + highlight_stale_tooltip=( "Shows locally-installed mods which are not used by any server " "in your Saved Servers" ), - delete_selected = "Delete selected", - delete_selected_tooltip = "Deletes selected mods from the system", - unselect_all = "Unselect all", - unselect_all_tooltip = "Bulk unselects all mods", - select_all = "Select all", - select_all_tooltip = "Bulk selects all mods", - bulk_select = "Bulk selects all currently highlighted mods", - clear_highlights = "Clears highlights and reverts the table to a default state", - select_stale = "Select stale", - select_stale_tooltip = "Only selects highlighted stale mods", + delete_selected="Delete selected", + delete_selected_tooltip="Deletes selected mods from the system", + unselect_all="Unselect all", + unselect_all_tooltip="Bulk unselects all mods", + select_all="Select all", + select_all_tooltip="Bulk selects all mods", + bulk_select="Bulk selects all currently highlighted mods", + clear_highlights="Clears highlights and reverts the table to a default state", + select_stale="Select stale", + select_stale_tooltip="Only selects highlighted stale mods", ) thanks = Thanks( - header = "# Special thanks", - description = ( + header="# Special thanks", + description=( "This page recognizes beta testers, collaborators, code " "contributors, and sponsors of the project in alphabetical order.\n" "If you wish to be removed from this list, please submit a ticket." - ), - users = [ + ), + users=[ "bongjutsu", "Deku", "dj3hac", @@ -383,29 +390,28 @@ options = Options( manual_dl="Manual", auto_dl="Auto", update="Update", - install_mode = "Mod install mode", - force_update = "Force update local mods", - dl_eventbox = ( - "Manual: prompt to subscribe to mods in Steam. " - "Auto: unmanned downloads." + install_mode="Mod install mode", + force_update="Force update local mods", + dl_eventbox=( + "Manual: prompt to subscribe to mods in Steam. " "Auto: unmanned downloads." ), - force_eventbox = "Synchronize all local mods. Automatic mode must be enabled.", - self_update = ( + force_eventbox="Synchronize all local mods. Automatic mode must be enabled.", + self_update=( "Stable: only contains stable features. " "Testing: pre-release beta, contains new features." ), - no_self_update = ( + no_self_update=( "In-app updates are disabled when DZGUI is " "installed globally (e.g., via package manager)." ), - api_keys = "API Keys", - prefs = "Preferences", - mods = "Mods", - version = "Version", - branch = "DZGUI branch", - stable = "Stable", - testing = "Testing", -manual_sub_msg = """When switching from MANUAL to AUTO mod install mode, + api_keys="API Keys", + prefs="Preferences", + mods="Mods", + version="Version", + branch="DZGUI branch", + stable="Stable", + testing="Testing", + manual_sub_msg="""When switching from MANUAL to AUTO mod install mode, DZGUI will manage mod installation and deletion for you. To prevent conflicts with Steam Workshop subscriptions and old mods from being downloaded when Steam updates, you should unsubscribe from any existing Workshop mods you manually subscribed to. @@ -415,14 +421,14 @@ on the right-hand side. ) dialog = Dialog( - querying = "Querying server", - fetching = "Fetching server metadata", - filtering = "Filtering servers", - refreshing = "Refreshing player count", - details = "Fetching details", - modlist = "Fetching modlist", - working = "Working", - updating_mods = "Updating mods", + querying="Querying server", + fetching="Fetching server metadata", + filtering="Filtering servers", + refreshing="Refreshing player count", + details="Fetching details", + modlist="Fetching modlist", + working="Working", + updating_mods="Updating mods", ) buttons = Button( @@ -454,6 +460,7 @@ checkmark = "✓" no_mods = "No local mods found." no_servers = "No server metadata to list." + @dataclass(slots=True, frozen=True) class Flags: description: str @@ -461,6 +468,7 @@ class Flags: uninstall: str developers: str + flags = Flags( description="DayZ server browser and mod manager", version="Print version information", @@ -468,17 +476,21 @@ flags = Flags( developers="Enables developer debugging features", ) + @dataclass(slots=True, frozen=True) class FilePicker: title: str placeholder: str + picker = FilePicker( - title = "Save diagnostic log to file", - placeholder = SYSTEM_LOG, + title="Save diagnostic log to file", + placeholder=SYSTEM_LOG, ) -api_error = "API key validation error or timeout. See 'Help > Show debug log' for details." +api_error = ( + "API key validation error or timeout. See 'Help > Show debug log' for details." +) @dataclass(slots=True, frozen=True) @@ -488,13 +500,15 @@ class DevelopersPage: prefs_label: str columns: list[str] + developers = DevelopersPage( header="Developers", paths_label="Resolved XDG paths", prefs_label="Boot preferences", - columns=["Key", "Value"] + columns=["Key", "Value"], ) + @dataclass(slots=True, frozen=True) class ServerLabels: browser: str @@ -502,6 +516,7 @@ class ServerLabels: recent: str lan: str + server_labels = ServerLabels( browser="Server Browser", saved="Saved Servers", @@ -509,6 +524,7 @@ server_labels = ServerLabels( lan="LAN", ) + @dataclass(slots=True, frozen=True) class ConnectPanel: connect: str @@ -519,6 +535,7 @@ class ConnectPanel: add_tooltip: str connect_tooltip: str + connect_panel = ConnectPanel( connect="Connect", add="Add", @@ -532,16 +549,19 @@ connect_panel = ConnectPanel( connect_tooltip="Connect to this server", ) + @dataclass(slots=True, frozen=True) class FavPanel: heading: str no_fav: str + fav_panel = FavPanel( heading="Favorite server", no_fav="None set. Right click a server and select 'Set favorite' to set.", ) + @dataclass(slots=True, frozen=True) class LanPanel: heading: str @@ -552,6 +572,7 @@ class LanPanel: entry_tooltip: str scan_tooltip: str + lan_panel = LanPanel( heading="LAN query port", default_button="Default port (27016)", @@ -559,12 +580,13 @@ lan_panel = LanPanel( scan_button="Scan", placeholder="Enter the query port (1-65535)", entry_tooltip="Specify the port to search for DayZ servers on the local network", - scan_tooltip="Scan for servers" + scan_tooltip="Scan for servers", ) distance_suffix = "Distance: calculating..." dialog_error = "ERROR" + @dataclass(slots=True, frozen=True) class AtomicButton: refresh: str @@ -573,6 +595,7 @@ class AtomicButton: keys: str keys_tooltip: str + atomic_buttons = AtomicButton( refresh="Refresh", refresh_tooltip="Refresh server data", @@ -580,3 +603,5 @@ atomic_buttons = AtomicButton( keys="Keys", keys_tooltip="Toggles the keybindings dialog", ) + +steam_icon_missing="Steam icon not found in IconTheme" diff --git a/dzgui/views/base.py b/dzgui/views/base.py index d5096c9..636c87b 100644 --- a/dzgui/views/base.py +++ b/dzgui/views/base.py @@ -5,10 +5,9 @@ import warnings from typing import TYPE_CHECKING, Literal from dzgui.const.enum import NotebookPage -from dzgui.const.constants import APP_NAME, APP_NAME_LOWER +from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, STEAM_TRAY_MONO from dzgui.controllers.mc import Controller from dzgui.util import css, strings -from dzgui.util.format import embolden # NOTEBOOK ITEMS # TODO: import notebook only and add components there? @@ -399,8 +398,8 @@ class App(Gtk.Application): MainController = Controller() -# TODO: icon sanity check, log result -# theme = Gtk.IconTheme.get_default() -# icons = theme.list_icons(None) -# print("steam_tray_mono" in icons) -# FIXME: +theme = Gtk.IconTheme.get_default() +icons = theme.list_icons(None) +if STEAM_TRAY_MONO not in icons: + logger.warn(strings.steam_icon_missing) + warnings.warn(strings.steam_icon_missing, stacklevel=2)