Compare commits

...
Author SHA1 Message Date
aclist 1a4bc40cf6 drop: unused comment 2026-11-23 20:24:23 +09:00
aclist 4487833d99 chore: add debug logging 2026-11-23 20:23:55 +09:00
aclist e528580350 fix: f-string 2026-11-23 20:23:39 +09:00
aclist e5d94a8c52 chore: update log levels 2026-11-23 20:19:02 +09:00
aclist 29c2765732 docs: update DEVELOPERS.md 2026-11-23 20:08:59 +09:00
aclist 0d946de881 drop: unused import 2026-11-23 20:07:19 +09:00
aclist abf68b0962 Merge pull request #550 from aclist/chore/audit-strings
chore: audit strings (2)
2026-11-23 20:06:13 +09:00
aclist 47168cd0bf Merge pull request #547 from aclist/chore/audit-strings
chore: audit strings
2026-11-23 20:05:02 +09:00
aclist 5bd4f3502b chore: reword string
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-11-23 18:56:17 +09:00
aclist 07fb42bab1 drop: unused key 2026-11-23 18:55:50 +09:00
aclist 47eaa74868 drop: unused comment 2026-11-23 18:51:52 +09:00
aclist 13bf4f1cdf chore: add comment 2026-11-23 18:39:56 +09:00
aclist 4c4bc22647 chore: formatting 2026-11-23 18:25:00 +09:00
aclist a83d46d614 chore: add missing users 2026-11-23 18:24:18 +09:00
aclist d9e0151376 fix: column sort order 2026-11-23 17:54:13 +09:00
aclist be37473657 fix: missing string 2026-11-23 17:51:51 +09:00
aclist 8bfa2eeaae drop: legacy strings file 2026-11-23 17:49:32 +09:00
aclist cb52d2bac2 chore: add metadata strings file
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-11-23 17:44:58 +09:00
aclist c321a7c02f chore: move delimiter to constants 2026-11-23 17:44:46 +09:00
aclist c63007475c drop: unused strings 2026-11-23 17:42:07 +09:00
aclist 2d86a83445 fix: not a tuple 2026-11-23 17:40:23 +09:00
aclist 8c2cf77557 drop: unused imports 2026-11-23 17:39:43 +09:00
aclist 17b874f006 fix: namespace 2026-11-23 17:39:14 +09:00
aclist 6582d794a0 fix: typo 2026-11-23 17:38:26 +09:00
aclist 61fe55dad2 chore: abstract metadata strings 2026-11-23 17:38:16 +09:00
aclist aca4fb4cfd chore: abstract server labels 2026-11-23 17:27:38 +09:00
aclist 0533e2c51a chore: abstract init strings 2026-11-23 17:24:42 +09:00
aclist dabcd85990 chore: abstract options strings 2026-11-23 17:22:51 +09:00
aclist aa18129e19 drop: unused strings 2026-11-23 17:12:03 +09:00
aclist ffc5f70083 chore: abstract dialog strings 2026-11-23 17:11:52 +09:00
aclist 78e6ddb4da chore: abstract context menu, crumbs, errors 2026-11-23 17:10:44 +09:00
aclist a5529f079a drop: unused strings 2026-11-22 15:37:53 +09:00
aclist 5b9f245a51 fix: import
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-22 15:03:28 +09:00
aclist d4c4268eaa chore: abstract mod panel strings 2026-11-22 15:02:20 +09:00
aclist f2025dd48d chore: abstract side button strings 2026-11-22 14:58:11 +09:00
aclist ca7fea3601 chore: sort key list 2026-11-22 14:57:48 +09:00
aclist 30fba4ec10 chore: abstract button strings 2026-11-22 14:54:12 +09:00
aclist 21bc1222da chore: abstract CLI flags 2026-11-22 14:49:38 +09:00
aclist 9619047147 chore: update import 2026-11-22 14:44:41 +09:00
aclist 6dd053af8c chore: drop unused strings and abstract changelog 2026-11-22 14:44:17 +09:00
aclist 23637dafc9 chore: abstract statusbar strings 2026-11-22 14:43:14 +09:00
aclist ee18b9c513 chore: abstract dialog strings 2026-11-22 14:39:18 +09:00
aclist 4c59ba85d7 fix: drop dangling commas 2026-11-22 14:38:22 +09:00
aclist 3a9e1c6ff2 chore: merge dzgui7 branch 2026-11-22 14:27:42 +09:00
aclist 4cbda4e537 chore: add thanks file 2026-11-22 14:06:59 +09:00
aclist 417801ac41 chore: abstract developers and thanks page 2026-11-22 14:06:39 +09:00
aclist db2ddca9a5 Merge pull request #549 from aclist/chore/import-untyped
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
chore: clear typehinting errors
2026-11-22 14:00:05 +09:00
aclist 5c81f228b0 chore: clear typehinting errors 2026-11-22 13:59:22 +09:00
aclist 48d58ba5c9 Merge pull request #548 from aclist/feat/debug-filepicker-2
feat: export debug log to a named file
2026-11-22 13:53:31 +09:00
aclist cdfe59ce38 chore: revert change 2026-11-22 13:52:37 +09:00
aclist 3f74e71a10 feat: export debug log to a named file 2026-11-22 13:50:13 +09:00
aclist 533a77da23 Merge pull request #545 from aclist/chore/test-typehints
chore: refactor tests
2026-11-22 13:42:53 +09:00
aclist b98172e782 Merge branch 'dzgui7' into chore/test-typehints
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-22 13:41:52 +09:00
aclist 5febda79ca Merge pull request #544 from aclist/fix/custom_xdg_path
fix: parse custom xdg paths
2026-11-22 13:37:46 +09:00
aclist 17dedd79a7 chore: audit legacy strings file, first pass 2026-11-21 20:48:44 +09:00
aclist ede064858e chore: abstract keybindings strings 2026-11-21 20:48:25 +09:00
aclist a3068324fa chore: add test
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-21 18:00:20 +09:00
aclist 97c90b435b chore: log additional exceptions 2026-11-21 17:59:34 +09:00
aclist f300786546 feat: descend into path when making parents 2026-11-21 17:59:14 +09:00
aclist 2a6a8f0cb0 chore: clear typehinting errors
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-19 08:52:18 +09:00
aclist da718c684d change: block shortcut creation on snap client 2026-11-19 08:51:30 +09:00
aclist b42be20dc3 change: parse real home in sandbox
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-19 07:50:29 +09:00
aclist 16578eaeb3 chore: update changelog 2026-11-19 07:01:07 +09:00
aclist 1ea9428503 chore: drop unused imports 2026-11-19 06:46:38 +09:00
aclist 8aca23cf76 chore: cherry pick changes from test-typehints branch 2026-11-19 06:45:14 +09:00
aclist 663e57b8cd chore: cherry pick changes from test-typehints branch 2026-11-19 06:41:05 +09:00
aclist 5853e15b8e fix: return empty list if mod dir is missing 2026-11-19 06:22:05 +09:00
aclist dee566932a fix: wrap long error labels
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-19 06:10:49 +09:00
aclist 00741b0b60 fix: parse real home in sandbox 2026-11-19 06:10:24 +09:00
aclist 0f28885e7b chore: update thanks page
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-18 16:31:57 +09:00
aclist 29223a8a1f change: disambiguate custom XDG_DATA_HOME
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-18 16:27:11 +09:00
aclist 45c412e1ad change: make reference to snap more generic 2026-11-17 03:12:05 +09:00
aclist a32c99b3eb feat: support Ubuntu Snap path 2026-11-17 02:22:59 +09:00
aclist dfef2cfd75 drop: unused f-string
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-17 02:13:56 +09:00
aclist d47d7075e9 change: move try statement to outer function 2026-11-17 02:13:29 +09:00
aclist ea41503dad change: swallow stderr 2026-11-17 02:10:38 +09:00
aclist da474e274f chore: update tests 2026-11-17 01:45:26 +09:00
aclist d694aa56e8 chore: clear typehinting errors 2026-11-17 01:44:23 +09:00
aclist 6adecbedaa fix: parse custom xdg path correctly 2026-11-17 01:44:12 +09:00
aclist d2208787b4 chore: clear typehinting errors in build scripts 2026-11-12 12:01:59 +09:00
aclist 77682cacd4 change: refactor test for readability 2026-11-12 11:37:49 +09:00
aclist e8d7d9eb15 change: abstract flatpak ps command 2026-11-12 11:37:13 +09:00
aclist e935276e32 Merge pull request #542 from aclist/chore/test-typehints
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
chore: typehint tests
2026-11-12 07:47:03 +09:00
aclist 047b9dbbf6 Merge branch 'chore/test-typehints' of github.com:aclist/dzgui into chore/test-typehints 2026-11-12 07:45:36 +09:00
aclist d5c9f24ad5 chore: clear typehinting errors 2026-11-12 07:45:24 +09:00
aclist f486cc506f chore: clear typehinting errors 2026-11-12 07:44:34 +09:00
aclist 307792ba5b chore: drop unused import 2026-11-12 07:11:20 +09:00
aclist f7d95d5407 chore: clear typehinting errors 2026-11-12 07:10:27 +09:00
aclist 8b09622fe5 Merge branch 'dzgui7' into chore/test-typehints 2026-11-12 06:21:45 +09:00
aclist 7f6d61083c Merge pull request #541 from aclist/docs/7.0.0-spec
docs: update to DZGUI 7 spec
2026-11-12 06:20:56 +09:00
aclist 3e7b49203a chore: add mark to test 2026-11-12 06:20:16 +09:00
aclist 269ef18a48 Merge pull request #540 from aclist/drop/unused-imports-2
drop: unused imports-2
2026-11-12 06:18:37 +09:00
aclist 8aaa806cd3 chore: drop unused docs pages
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-12 06:11:48 +09:00
aclist e4dc545038 fix: URLs 2026-11-12 06:10:00 +09:00
aclist 35623b6456 change: use ServerRow classmethod
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-12 06:06:27 +09:00
aclist b9cb7ec973 chore: update repo URL 2026-11-12 06:03:40 +09:00
aclist e29433b388 chore: typehint tests 2026-11-12 05:10:02 +09:00
aclist 170990ee1d chore: downgrade FIXME tags 2026-11-12 05:06:51 +09:00
aclist 1dbbd5977d chore: drop Optional annotation 2026-11-12 05:05:59 +09:00
aclist c267b1bbc7 docs: update changelog
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-12 02:12:40 +09:00
aclist 439109d11d docs: update to DZGUI 7 spec 2026-11-12 02:07:49 +09:00
aclist d0b3a723c6 drop: unused comment 2026-11-12 02:06:36 +09:00
aclist 535bc505f7 chore: update comments 2026-11-12 02:06:20 +09:00
aclist f2375feeec feat: add get_index() method to ServerRow 2026-11-12 02:04:55 +09:00
aclist 1b9448735d chore: drop old comments 2026-11-12 02:03:59 +09:00
aclist d5693b07fb chore: update comments 2026-11-12 02:03:31 +09:00
aclist 7a6f4a2bb9 feat: immutable decorator 2026-11-11 07:52:05 +09:00
aclist ba92d15085 drop: unused signal logic 2026-11-11 07:50:54 +09:00
aclist 65e04c2fc4 fix: multiple signals being stacked 2026-11-11 07:50:38 +09:00
aclist 0907f5a474 change: immutable dataclass 2026-11-11 07:50:12 +09:00
aclist bfa83c3f94 change: import sort order 2026-11-11 07:15:53 +09:00
aclist aef48e515b fix: failing test 2026-11-11 07:15:28 +09:00
aclist e6ebeaeb5e chore: immutable dataclass 2026-11-11 07:04:25 +09:00
aclist 88c740105a chore: drop unused dataclasses 2026-11-11 07:02:23 +09:00
aclist b98a6f95a6 drop: unused imports 2026-11-11 07:00:17 +09:00
aclist 87d76e83ba chore: update DEVELOPERS.md 2026-11-11 06:57:56 +09:00
aclist a5374d1f1a Merge pull request #526 from aclist/fix/legacy-version-file
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
fix: legacy version file
2026-11-11 05:08:14 +09:00
aclist dcc4cb494b Merge branch 'dzgui7' into fix/legacy-version-file
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 05:07:35 +09:00
aclist ff1e150eb1 change: suppress logger message 2026-11-11 05:04:50 +09:00
aclist c7ef91f02e Merge pull request #539 from aclist/fix/remove-from-history
fix: restore missing route
2026-11-11 05:00:34 +09:00
aclist 95bc05eab5 Merge pull request #536 from aclist/change/server-row-dataclass
change: marshal server row data
2026-11-11 04:59:58 +09:00
aclist 89dc6aa8a8 chore: drop comment
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 04:52:50 +09:00
aclist 9e8e3730c7 fix: drop unused imports 2026-11-11 04:30:31 +09:00
aclist 52c126ff8c fix: restore missing route 2026-11-11 04:29:36 +09:00
aclist e5c8f2a69c chore: drop stale comment 2026-11-11 04:11:23 +09:00
aclist 63316a01a9 fix: extraneous newlines in log 2026-11-11 03:57:51 +09:00
aclist 0729273503 change: drop Union 2026-11-11 03:51:09 +09:00
aclist 91d164d666 chore: drop unused method 2026-11-11 03:49:43 +09:00
aclist 0d7f022c43 Merge branch 'dzgui7' into change/server-row-dataclass 2026-11-11 03:49:05 +09:00
aclist f76c400697 Merge pull request #535 from aclist/change/enum-dataclasses
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
change: enum dataclasses
2026-11-11 03:44:58 +09:00
aclist 7ae5880890 chore: update union
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 03:36:14 +09:00
aclist afbced228d Merge branch 'dzgui7' into change/enum-dataclasses 2026-11-11 03:33:44 +09:00
aclist f5d7bf713d Merge pull request #538 from aclist/fix/clipboard-button-controller
fix: clipboard button controller
2026-11-11 03:32:27 +09:00
aclist c1630adee1 chore: update return value 2026-11-11 03:31:17 +09:00
aclist 88f6b84bea fix: restore dropped typehint 2026-11-11 03:29:23 +09:00
aclist 134dcb6f0b fix: unused param blocking boot 2026-11-11 03:27:12 +09:00
aclist cc0354c881 chore: drop unused imports 2026-11-11 03:21:31 +09:00
aclist f2d21be347 Merge pull request #534 from aclist/chore/strict-typehinting
chore: clear strict typehinting errors
2026-11-11 03:19:29 +09:00
aclist f65fa153cc Merge branch 'chore/strict-typehinting' of github.com:aclist/dzgui into chore/strict-typehinting
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 03:18:50 +09:00
aclist 8aa7328d8f chore: drop unused import 2026-11-11 03:18:40 +09:00
aclist bb04854cd7 chore: add keybinding to strings 2026-11-11 03:17:29 +09:00
aclist 5014b2a467 Merge branch 'dzgui7' into chore/strict-typehinting 2026-11-11 03:15:26 +09:00
aclist d020295aa3 Merge pull request #537 from aclist/fix/cannot-acquire-lock
fix: cannot acquire lock
2026-11-11 03:12:31 +09:00
aclist 1879347831 chore: add typehints 2026-11-11 03:09:39 +09:00
aclist 5a1c098af7 fix: acquire lock prior to calling build_gui() 2026-11-11 03:09:14 +09:00
aclist 3d346dfb07 Merge pull request #531 from aclist/chore/update-strings-pass-1
chore: update strings pass 1
2026-11-11 03:06:43 +09:00
aclist cb03db6032 Merge branch 'dzgui7' into chore/strict-typehinting 2026-11-11 02:47:40 +09:00
aclist c69022f74c Merge pull request #532 from aclist/drop/no-e402
chore: drop unused Gtk imports
2026-11-11 02:44:40 +09:00
aclist 7f0bccad64 Merge pull request #528 from aclist/drop/abstract-constructor-params
drop: abstracted constructor params
2026-11-11 02:43:30 +09:00
aclist d6b5c7bbb4 chore: drop unused imports
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 01:45:00 +09:00
aclist f0a07cbbba Merge branch 'dzgui7' into drop/abstract-constructor-params 2026-11-11 01:41:58 +09:00
aclist 30fa762780 fix: update bool 2026-11-11 01:35:12 +09:00
aclist 807a530550 Merge pull request #529 from aclist/change/normalize-icon-names
change: normalize icon names
2026-11-11 01:31:08 +09:00
aclist f092cfdf4a Merge pull request #530 from aclist/change/normalize-endpoint-names
change: normalize endpoint names
2026-11-11 01:22:59 +09:00
aclist d5c597ab03 Merge pull request #527 from aclist/docs/history-file-2
docs: add history file
2026-11-11 01:15:33 +09:00
aclist 06c85fdfd8 chore: add remarks about release structure
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
2026-11-11 01:12:51 +09:00
aclist 9b948271e1 chore: add test 2026-11-11 00:57:12 +09:00
aclist 7322970c54 fix: define constants outside of FiltrationManager 2026-11-11 00:56:51 +09:00
aclist 504a2a724c fix: typo 2026-11-11 00:48:37 +09:00
aclist c66511b005 change: marshal server row data 2026-11-11 00:41:40 +09:00
aclist 0c4026daf8 chore: clear typehinting errors 2026-11-10 10:02:41 +09:00
aclist e03c6905c6 chore: clear typehinting errors 2026-11-10 06:30:12 +09:00
aclist 8fb3462f35 chore: add placeholder for row struct 2026-11-10 05:58:22 +09:00
aclist bfe9b9d147 chore: clear typehinting errors 2026-11-10 05:58:02 +09:00
aclist 9f36569fd4 drop: LoggerAlertsButton 2026-11-10 05:10:56 +09:00
aclist da18b41136 chore: drop Soup2 stubs 2026-11-10 05:09:02 +09:00
aclist f092207c61 chore: clear strict typehinting errors 2026-11-10 04:37:51 +09:00
aclist c94e4e73db chore: add strings file 2026-11-10 04:34:38 +09:00
aclist 8da264686a chore: clear typehinting errors 2026-11-10 04:33:54 +09:00
aclist 598973104c change: reference dataclass values in enum 2026-11-10 04:30:40 +09:00
aclist 15d4b71350 Merge pull request #533 from aclist/docs/more-attribution
Mirror to Codeberg / mirror-to-codeberg (push) Canceled after 0s
chore: add remarks to README
2026-11-10 03:08:12 +09:00
aclist 4e5fadf928 chore: drop old comments 2026-11-10 03:04:44 +09:00
aclist 3dc37561be chore: update pyproject.toml 2026-11-10 03:02:35 +09:00
aclist 13786591b3 chore: restore exclusion for GLibUnix 2026-11-10 03:02:06 +09:00
aclist 9eb1342877 drop: unused imports script 2026-11-10 03:00:35 +09:00
aclist 3f29484895 chore: drop unused Gtk imports 2026-11-10 02:59:22 +09:00
aclist fa2f86b03e chore: abstract string literals 2026-11-10 02:41:24 +09:00
aclist c8fe6ec056 chore: update strings files 2026-11-10 02:37:22 +09:00
aclist 6901e5456e drop: unused dataclass 2026-11-10 02:36:18 +09:00
aclist 49298d9943 change: normalize endpoint names 2026-11-09 23:51:19 +09:00
aclist 72e3d95808 change: normalize icon names 2026-11-09 23:48:10 +09:00
aclist a42c9d4389 drop: abstracted constructor params 2026-11-09 23:28:50 +09:00
aclist cc708c64b2 docs: add history file 2026-11-09 23:19:32 +09:00
aclist 3677b01fdc fix: exception handling 2026-11-09 22:25:13 +09:00
aclist 4f6223f90b fix: strip invalid values from versions file 2026-11-09 22:24:26 +09:00
aclist 441066a1a0 chore: update comments 2026-11-09 22:23:37 +09:00
aclist fa1ac8fa31 chore: update imports 2026-11-09 22:23:27 +09:00
181 changed files with 2358 additions and 2383 deletions

No files matched your search

+6 -7
View File
@@ -57,6 +57,8 @@
- List timestamp of last DayZ client update - List timestamp of last DayZ client update
- Validate mods via Mod page to pull in updates - Validate mods via Mod page to pull in updates
- Support for Nasdara (Badlands) DLC - Support for Nasdara (Badlands) DLC
- Load offline mods
- Support Snap package version of Steam
### Changed ### Changed
- Conform to PEP 440 versioning for beta versions - Conform to PEP 440 versioning for beta versions
@@ -99,16 +101,13 @@
- Current keyword filter not being applied when refreshing table - Current keyword filter not being applied when refreshing table
- Steam Flatpak cannot run DZGUI as a non-Steam game - Steam Flatpak cannot run DZGUI as a non-Steam game
- Collisions between native Steam and Steam Flatpak clients - Collisions between native Steam and Steam Flatpak clients
- Sticky toggle signal on radio buttons when reloading Options
### Unreleased - Handle missing mods directory if not installed previously
- Load offline mods - Filters not blocked by keyboard keys when filters are disabled
- Local documentation
- Raw debug command in context menu
### Developer-facing ### Developer-facing
- Add pyproject.toml file
- Show deprecation warnings
- Options -> Dev page - Options -> Dev page
- Raw debug command in preconnect menu
## [6.0.5] 2026-05-17 ## [6.0.5] 2026-05-17
### Changed ### Changed
+2 -3
View File
@@ -8,7 +8,7 @@ If you are a developer, you can skip to the end.
# Requesting help # Requesting help
If you encounter a problem with DZGUI, you can submit tickets on the GitHub If you encounter a problem with DZGUI, you can submit tickets on the GitHub
[issue tracker](https://github.com/aclist/dztui/issues) under the [issue tracker](https://github.com/aclist/dzgui/issues) under the
`troubleshooting` tag. `troubleshooting` tag.
# How can I help the project? # How can I help the project?
@@ -24,7 +24,7 @@ accordingly.
## Submitting a ticket ## Submitting a ticket
Navigate to the GitHub [issue tracker](https://github.com/aclist/dztui/issues). Navigate to the GitHub [issue tracker](https://github.com/aclist/dzgui/issues).
From there, follow the onscreen prompts. You will be asked questions such as: From there, follow the onscreen prompts. You will be asked questions such as:
- What version are you using? - What version are you using?
@@ -55,7 +55,6 @@ The following naming conventions apply for PRs:
- fix/<your-fix> - patch/hotfix branches - fix/<your-fix> - patch/hotfix branches
- feat/<your-feature> - feature branches - feat/<your-feature> - feature branches
- doc/<your-doc-branch> - documentation branches - doc/<your-doc-branch> - documentation branches
- infra/<your-infra-branch> - infrastructure branches
Implement your changes and test them locally. If they work, you may Implement your changes and test them locally. If they work, you may
open a merge request, and then we review your changes. If everything is OK, it open a merge request, and then we review your changes. If everything is OK, it
+11 -5
View File
@@ -5,7 +5,7 @@
### Fetch submodules ### Fetch submodules
git submodule update --recursive --init git submodule update --recursive --init
### Install with dev dependencies ### Install into editable venv with dev dependencies
uv pip install -e '.[dev]' uv pip install -e '.[dev]'
This includes all dependencies for building, linting, testing, and checking in code. This includes all dependencies for building, linting, testing, and checking in code.
@@ -16,7 +16,7 @@ docs: documentation tools
lint: code linting, fixing, and type checking lint: code linting, fixing, and type checking
test: unit and integration tests test: unit and integration tests
## Miscellaneous ## Build process
### Setting up precommit hooks ### Setting up precommit hooks
pre-commit install pre-commit install
@@ -25,6 +25,12 @@ pre-commit install
sphinx-build -M html source build -a sphinx-build -M html source build -a
### Building standalone release binaries ### Building standalone release binaries
1. Set up the build target: `rustup target add x86_64-unknown-linux-musl` 1. Install the applicable system package containing the 'musl-gcc' wrapper
2. Run `python3 scripts/release.py` 2. Set up the build target: `rustup target add x86_64-unknown-linux-musl`
3. Generate a release and tag against the resulting tarfile generated in `dist` 3. Run `python3 scripts/release.py`
4. Generate a release and tag against the resulting tarfile generated in `dist`
### Running tests
Some tests are environment specific and require real configuration files.
For a generally environment-agnostic test suite, invoke `pytest -m "not realconfig, not flatpak"`
+124
View File
@@ -0,0 +1,124 @@
# History of the project
This file collects notable milestones and events related to DZGUI, mainly around DZGUI as a framework and the history of development.
A chronological summary of features can be found in CHANGELOG.md.
## 2021
### 2021-12-03: DayZ adds support for Battleye over Proton
DayZ was among a handful of games with whitelisted anti-cheat support under Valve's emerging WINE-based Proton compatibility layer.
While adding anti-cheat compatibility at a technical level, this change did not actually allow the client to connect to servers running complex modlists.
Development of the precursor to DZGUI began at around this time.
### 2021-12-12: initial version of DZTUI is created
DZTUI, a Bash script and terminal user interface, was the precursor to DZGUI.
This was an initial attempt at bootstrapping the Steam client to handle mods correctly when launching DayZ.
Due to user interest, features continued to be added. This early tool is archived under the 'dztui' branch.
## 2022
### 2022-05-09: addition of zenity GUI and project name change (DZGUI)
With the introduction of the Steam Deck, more users wanted a graphical user interface
to interact with DZTUI. Being that DZTUI was purely a Bash script, a method of
drawing menus was needed, so the "zenity" package was used to create prefabricated dialogs.
While this met the minimum requirement to show prompts and selectable options, no rich customization was possible.
The introduction of zenity as a dependency marked the shift from "DZTUI" to "DZGUI".
Throughout 2022, the limits of zenity for DZGUI's purposes were tested, particularly in the context of SteamOS.
This led to the discovery of a number of bugs in zenity, GTK, and SteamOS, which were reported up to their respective channels.
While this was improving the SteamOS user experience, it started to become clear that a fully custom UI was needed.
This barebones version of DZGUI sufficed for some time, with the Bash script and some standalone Python modules doing the heavy lifting,
and this period served to surface a number of bugs and interesting interactions with the Steam client.
## 2023
### 2023-11-23: Python 3.10 dependency
Prior to this time, DZGUI open-endedly allowed you to use any Python version for its modules, without any significant handling for
the idiosyncrasies of different versions. A minimum requirement of Python 3.10 was thus instituted to normalize expected behavior.
Throughout 2023, various features related to server browsing were added, such as filters and more granular search parameters.
There were still a lot of unknowns at this time, so things were being resolved through trial and error.
## 2024
### 2024-01-31: DZGUI 5 API introduces GTK UI
Using zenity as a simple GUI had exposed some bugs and limitations in that package, particularly when trying to push huge lists of server records
into tables and sorting them in a performant manner.
Around this time it became clear that a more robust UI framework was needed. While keeping the original Bash script and Python modules for
background processing, PyGObject (GTK) was added to the project in order to ship a custom UI that could be designed from the ground up.
However, it should be noted that at this point, the DZGUI logic itself was still a (increasingly large) Bash script to which a GTK UI had been stitched on.
These were totally separate components, with UI actions on the GTK side triggering calls to Bash functions in an overly complex helper file.
The UI was basically a thin client around the old Bash logic, but this was still a far cry from an integrated application with proper signals and dedicated components.
Effectively, DZGUI 5 through 6 were a stepping stone that set the groundwork to go from DZGUI 4 (pure Bash script) to
DZGUI 7 (standalone Python application). Today, little of DZGUI 5's original logic remains outside of the basic UI grid.
### 2024-10-15: Frostline DLC released, widespread parsing problems
DayZ's first DLC introduced a new format for server responses that packed extra metadata into the A2S_RULES format.
Upon its release, all third-party DayZ launchers and server listing web sites were unable to parse the mod information being returned from Frostline servers.
For a period of two weeks, this remained unsolved and various attempts were made to understand the updated specification.
### 2024-10-30: DZGUI hotfix adds support for Frostline servers
DZGUI was the first third-party tool to fix parsing for Frostline servers and restore functionality.
This was a small milestone, because it meant DZGUI was evolving from a "dumb" launcher to a featureful tool
touching upon and improving all aspects of the end-to-end DayZ experience.
Particularly around this time, the sheer diversity of needs of modders, server operators, and players started to become clear.
Users had highly specific and diverse use cases for setting up their game environment, and requested a number of features to support that on
the DZGUI side.
## 2025
### 2025-01-17: DZGUI 6 API
With DZGUI 6, the difficult decision to enforce a Python 3.13 dependency was made.
While the previous dependency was Python 3.10+, it was deemed better to develop against and target identical versions.
However, due to the vagaries of managing Python environments on end-user systems, this change added unnecessary complexity and frustration.
Users had to properly set up virtual environments, install the relevant dependencies, and create a wrapper script to run this version, whereas
previous versions had essentially been point and click.
### 2025-10-23: DZGUI 7 API and the "Ship of Theseus"
It had become clear that the situation above was untenable and the legacy Bash script was unmaintainable given the project's enlarged scope.
The lack of a robust testing or typehinting framework made it difficult to diagnose rare bugs.
Shipping a standalone, turnkey application with zero or minimal dependencies was the most urgent priority.
DZGUI was still carrying around small bits and pieces of the old Bash script logic, so the decision was made to
refactor the application into a pure Python + GTK tool. This would effectively be a total rewrite of all logic,
only preserving the most minimal skeleton of the original UI layout as a reference.
Over the course of a year, a wholesale "Ship of Theseus" rewrite took place.
Nearly every component of DZGUI 6, both API and UI side, was taken apart and replaced.
A soft alpha and beta phase were used to iterate on this concept further. DZGUI 7 was increasingly recommended to users
as the preferred choice. This allowed for keeping the established userbase on the (relatively) stable DZGUI 6 spec, while building up
the new spec and making it available to more users as features were elaborated.
Through late 2025, several LLM-generated applications that recycled significant parts of DZGUI's code without the applicable GPL license were found.
The maintainers of those projects were advised to excise the offending segments or apply the necessary GPL licenses.
## 2026
### 2026-05-17: Switch to standalone releases
The DZGUI 7 beta starts shipping standalone glibc builds with an integrated setup wizard and installer.
DZGUI 6 had relied on "over the air" updates delivered via either a "stable" or "testing" branch
(archived respectively under the "dzgui" and "testing" branches). Effectively, the script would bootstrap itself and
fetch raw files directly from the repository. This was prone to problems because updates were monolithic, not giving
an easy escape hatch if the user needed to rollback in the event of a regression.
This was changed to atomic, tagged releases. In addition to updating directly through DZGUI, these prebuilt releases can be
downloaded manually as needed, and rollbacks are available for all prior versions under the DZGUI 7 specification.
### 2026-10-27: 500 tickets closed
The milestone of 500 tickets/PRs being closed was reached.
2026 was by far DZGUI's most intensive year by commits, perhaps suggesting the scope of the rewrite:
- 2021: 16
- 2022: 434
- 2023: 322
- 2024: 347
- 2025: 426
- 2026: 1300
DZGUI 7 is scheduled to release as a stable version within the year.
+7 -8
View File
@@ -1,11 +1,11 @@
Submitting a ticket Submitting a ticket
========================== ==========================
Tickets are tracked at the `DZGUI issue tracker <https://github.com/aclist/dztui/issues>`_. Tickets are tracked at the `DZGUI issue tracker <https://github.com/aclist/dzgui/issues>`_.
You will need to `register for a GitHub account <https://github.com/signup>`_ in order to submit one. You will need to `register for a GitHub account <https://github.com/signup>`_ in order to submit one.
If have checked the :doc:`kb` and `closed issues <https://github.com/aclist/dztui/issues?q=is%3Aissue+is%3Aclosed>`_ area and did not find a solution, three ticket types are provided for your If have checked the :doc:`kb` and `closed issues <https://github.com/aclist/dzgui/issues?q=is%3Aissue+is%3Aclosed>`_ area and did not find a solution, three ticket types are provided for your
convenience: convenience:
- **Bug report**: for unexpected, breaking behavior in the application - **Bug report**: for unexpected, breaking behavior in the application
@@ -20,18 +20,17 @@ Below are some examples of how to format a constructive report that will ensure
A non-actionable report A non-actionable report
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Subject: add button Subject: BUG: add button
hi, you must add a button to show how long I have to wait to join a full server, the app is useless without this...do your job, guys!!! ;-) hi, you must add a button to show how long I have to wait to join a full server, the app is useless without this...do your job, guys!!! ;-)
This report exhibits a number of problems: This report exhibits a number of problems:
- Vague title and summary: in addition to being unclear, this will slow down filing the incoming report.
- Problem space is poorly defined: it is not clear where the issue lies, where the feature is supposed to be implemented, nor why.
- Lack of context: the feature may already exist, but there is not enough information to go on. Alternatively, the feature may be technically impossible to implement, but there is not enough
information to go on.
- Incorrect report type: this is a feature request filed as a bug report. - Incorrect report type: this is a feature request filed as a bug report.
- Vague title and summary: this will slow down filing the incoming report.
- Problem space is poorly defined: it is not clear where the issue lies, where the feature is supposed to be implemented, nor why.
- Lack of context: the feature may already exist, but there is not enough information to go on. Alternatively, the feature may be technically impossible to implement.
- Unprofessional tone: the message is disrespectful towards project members and inserts the user's subjective opinion. - Unprofessional tone: the message is disrespectful towards project members and inserts the user's subjective opinion.
An actionable report An actionable report
@@ -56,5 +55,5 @@ This report is actionable because it is objective, specific, and detailed:
- The subject is clearly defined: specific details ensure it will be filed in a timely manner. - The subject is clearly defined: specific details ensure it will be filed in a timely manner.
- Scope is explicit: the specific version, settings, and conditions under which the problem occur were given. - Scope is explicit: the specific version, settings, and conditions under which the problem occur were given.
- Ample context: the user gave steps to reproduce the problem and clarified each one. - Ample context: the user gave steps to reproduce the problem and clarified each one.
- Courteous tone: the user interacted with project members in a professional manner.
- Supporting information: the user provided a crash dump to expedite resolution of the issue. - Supporting information: the user provided a crash dump to expedite resolution of the issue.
- Courteous tone: the user interacted with project members in a professional manner.
+3 -3
View File
@@ -15,7 +15,7 @@ author = 'aclist'
extensions = [] extensions = []
templates_path = ['_templates'] templates_path = ['_templates']
exclude_patterns = [] exclude_patterns = [] # type: ignore[var-annotated]
@@ -36,5 +36,5 @@ html_show_copyright = False
html_show_sourcelink = False html_show_sourcelink = False
today_fmt = "%Y-%m-%d" today_fmt = "%Y-%m-%d"
release = "6.x.x - 7.x.x" release = "7.x.x"
version = "6.x.x - 7.x.x" version = "7.x.x"
+5 -10
View File
@@ -1,19 +1,14 @@
Developers Developers
=========== ===========
This project is open source under the GPLv3 license. You can find the source code on This project is open source under the GPLv3 license. You can find the source code on
`GitHub <https://github.com/aclist/dztui>`_. If you wish to contribute to `GitHub <https://github.com/aclist/dzgui>`_. If you wish to contribute to
development, you will find further help in the development, you will find further help in the
`CONTRIBUTING.md <https://github.com/aclist/dztui/blob/main/CONTRIBUTING.md>`_ `CONTRIBUTING.md <https://github.com/aclist/dzgui/blob/dzgui7/CONTRIBUTING.md>`_
file. file.
All contributors are expected to act in accordance with the project's All contributors are expected to act in accordance with the project's
`code of conduct <https://github.com/aclist/dztui/blob/main/CODE_OF_CONDUCT.md>`_, `code of conduct <https://github.com/aclist/dzgui/blob/dzgui7/CODE_OF_CONDUCT.md>`_,
and follow the project's standards and guidelines. and follow the project's standards and guidelines.
To install DZGUI and related dependencies for linting, testing, and version control, Detailed instructions on setting up a build environment and installing DZGUI from source code
invoke the command ``uv pip install .[dev]``. can be found in the `DEVELOPERS.md <https://github.com/aclist/dzgui/blob/dzgui7/DEVELOPERS.md>`_ file.
After this process, install the applicable pre-commit hooks by invoking the command ``pre-commit install``.
These pre-commit hooks enforce code checks that prevent making commits unless the relevant tests pass.
-110
View File
@@ -1,110 +0,0 @@
Installation (DZGUI 6 legacy)
==================
Basic runtime dependencies
---------------------------------
If not already installed, the below can be found in your system’s package manager.
If any dependencies are missing when the application starts, it will warn you, so you need not take any preemptive measures here.
- curl
- jq
- steam
- wmctrl or xdotool
- zenity
.. note::
All dependencies are installed out of the box on Steam Deck.
UI dependencies (Python and PyGObject)
---------------------------------------
.. important::
As of version 6.0.0, you must have a valid Python 3.13 and matching PyGObject environment.
Depending on your distribution, this may require additional manual intervention.
Arch Linux (vanilla variants)
^^^^^^^^^^^^^^^^^^^^^^
You will need the ``python3.13`` package, if it is not already installed.
Install the following build dependencies:
.. code:: console
sudo pacman -S cmake gcc pkgconf python-cairo
.. include:: venv.rst
CachyOS (Arch)
^^^^^^^^^^^^^^^^^^^^^^^
Refer to the build instructions for Arch Linux first.
The ``python3.13`` package is not available on CachyOS, so it is recommended to
use ``uv`` to manage Python versions.
.. code:: console
sudo pacman -S uv
.. include:: venv.rst
Manjaro 26 (Arch)
^^^^^^^^^^^^^^^^^^^^^^^
If Python 3.13 is not already available out of the box, refer to the build instructions for :ref:`Arch Linux (vanilla variants)`.
Debian 13 variants
^^^^^^^^^^^^^^^^^^^^^^^
Python 3.13 and PyGObject are available out of the box. No additional steps are necessary.
You can proceed to the :ref:`Installscript`.
Fedora 43 variants
^^^^^^^^^^^^^^^^^^^^^^^
Fedora 43 ships with a newer version of Python (3.14), so you must set up Python 3.13 in its own
virtual environment (venv) to prevent it from conflicting with the system package.
Install the following build dependencies:
.. code:: console
sudo dnf install cairo cairo-devel cairo-gobject-devel gcc python3.13 python3.13-devel
.. include:: venv.rst
Ubuntu 24 variants
^^^^^^^^^^^^^^^^^^^^^^
Ubuntu ships with an older version of Python (3.12). You must install additional dependencies.
Add the PPA below to add Python 3.13 to your sources:
.. code:: console
sudo add-apt-repository ppa:deadsnakes/ppa
Install the following build dependencies:
.. code:: console
sudo apt install python3.13 python3.13-venv python3.13-dev build-essential python3-gi-cairo pkg-config libgirepository-2.0-dev libcairo2-dev
.. include:: venv.rst
Installscript
-----------------------
Invoke the command below from a terminal. This script fetches the main DZGUI script from the repository,
makes it executable, and launches DZGUI's first-time setup. After running this installscript, you will
have the file ``dzgui.sh`` wherever you invoked the command.
.. code:: console
curl -s "https://codeberg.org/aclist/dztui/raw/branch/dzgui/install.sh" | bash
nixOS installation
----------------------
Two packages are independently maintained by other contributors. Each takes a slightly different approach.
nixOS packages are standalone and do not require cloning the git repository.
- https://github.com/lelgenio/dzgui-nix
- https://github.com/jiriks74/dzgui.flake
Next steps
---------------
Proceed to the :doc:`setup` section for setup instructions.
-33
View File
@@ -1,33 +0,0 @@
Installation (DZGUI 7 beta)
==================
In order to make the first-time setup experience easier for end-users, DZGUI 7 no longer requires
the tool to be installed from source code into a working Python environment. All necessary dependencies and the
runtime environment are built-in.
Turnkey installer
------------------------
- Visit the project's `Releases page <https://github.com/aclist/dztui/releases/latest>`_.
- Extract the DZGUI tarball from the top of the **Assets** list.
- From a terminal, run the command ``./dzgui`` or double click on the extracted file in
a file explorer.
- Once the setup wizard opens, follow the steps at the bottom of this page.
UI dependencies (Python and PyGObject)
---------------------------------------
On most major distributions, GObject introspection libraries should be available by default.
If you receive an error about a missing ``libgirepository-2.0`` dependency, install it via your system's package manager.
On Debian-based distributions (Ubuntu, etc.), this package is not explicitly installed on the system.
You can install it via the following set of commands:
.. code:: console
sudo apt update
sudo apt install libgirepository-2.0-0
Next steps
---------------
Proceed to the :doc:`setup` section for setup instructions.
+12
View File
@@ -0,0 +1,12 @@
Command line launch flags
==========================
When run from the terminal, DZGUI provides several flags:
``-d, --debug``: enable developer debugging features. This does not add hidden or extra functionality; it merely enables developers to track deprecation warnings and see values stored in memory.
End-users will gain no benefit from using this flag.
``-m, --map``: check and update system map count value. Unnecessary on most modern systems. If your system does not meet the threshold, the DZGUI setup wizard will prompt you to use this flag.
``-u, --uninstall``: uninstall: granular selection of which state/configuration files to remove.
``-v, --version``: displays the DZGUI version.
+3 -3
View File
@@ -15,8 +15,8 @@ A DayZ server browser/mod manager for Linux. Used to list official and community
Source code: Source code:
- `GitHub <https://www.github.com/aclist/dztui>`_ - `GitHub <https://www.github.com/aclist/dzgui>`_
- `Codeberg (mirror) <https://codeberg.org/aclist/dztui>`_ - `Codeberg (mirror) <https://codeberg.org/aclist/dzgui>`_
Installation Installation
------------- -------------
@@ -56,8 +56,8 @@ See: :doc:`kb` or :ref:`Submitting a ticket`.
:maxdepth: 3 :maxdepth: 3
:hidden: :hidden:
steam
locale locale
flags
.. toctree:: .. toctree::
:caption: Help :caption: Help
+25 -16
View File
@@ -1,28 +1,37 @@
Installation Installation
================== ==================
As of this writing, you have a choice of two DZGUI versions: .. note::
Version 6 of DZGUI 6 has been fully replaced with DZGUI 7.
Users on existing DZGUI 6 installations should migrate to the DZGUI 7 build.
- DZGUI 6: Legacy stable version, more complicated to install In order to make the first-time setup experience easier for end-users, DZGUI 7 no longer requires
- DZGUI 7: Unstable beta version, much easier to install the tool to be installed from source code into a working Python environment. All necessary dependencies and the
runtime environment are built-in.
DZGUI 6 Turnkey installer
-------------------- ------------------------
This version is no longer receiving feature updates, but will receive security updates until it is replaced by DZGUI 7.
DZGUI 6 must be installed from the source code and has many more package dependencies and prerequisites for it to function correctly. - Visit the project's `Releases page <https://github.com/aclist/dzgui/releases/latest>`_.
If you are looking for a one-click, self-contained installer, use :ref:`DZGUI 7` instead. - Download the DZGUI archive from the top of the **Assets** list. This file will be labeled ``dzgui-<VERSION>-x86_64-unknown-linux-musl.tar.gz``.
- Extract the archive's contents.
- From a terminal, run the command ``./dzgui`` or double click on the extracted file in a file explorer.
- Once the setup wizard opens, follow the steps at the bottom of this page.
To install **DZGUI 6**, visit :doc:`dzgui6`. UI dependencies (Python and PyGObject)
---------------------------------------
On most major distributions, GObject introspection libraries should be available by default.
If you receive an error about a missing ``libgirepository-2.0`` dependency, install it via your system's package manager.
DZGUI 7 On Debian-based distributions (Ubuntu, etc.), this package is not explicitly installed on the system.
-------------------- You can install it via the following set of commands:
This version is currently in beta testing and has all of the features found in DZGUI 6, but may be unstable.
DZGUI 7 has an all-in-one installer and setup wizard, and many new features not found in DZGUI 6. .. code:: console
However, this codebase is newer and is provided as a pre-release beta candidate.
If you want the simplest installer and don't mind experiencing the occasional bug, use this version. sudo apt update
sudo apt install libgirepository-2.0-0
To install **DZGUI 7**, visit :doc:`dzgui7`. Next steps
---------------
Proceed to the :doc:`setup` section for setup instructions.
+15 -2
View File
@@ -98,15 +98,28 @@ tend to have less headroom for simultaneous connections than their wired counter
DZG-009: Floating dialogs appear maximized on tiling window managers DZG-009: Floating dialogs appear maximized on tiling window managers
------------------------------------------------------------------- -------------------------------------------------------------------
The main DZGUI window and its child dialogs are expected to be rendered as floating by your window manager. The main DZGUI window and its child dialogs are expected to be rendered as floating by your window manager.
DZGUI sends window manager hints to this effect, but tiling window managers designed to bisect the screen into quadrants (e.g., i3 window manager) DZGUI sends window manager hints to this effect, but tiling window managers designed to bisect the screen into quadrants (e.g., i3 window manager)
may try to always launch applications in fullscreen. may try to always launch applications in fullscreen.
To resolve this, set specific exclusions or window hints in your WM's configuration file. To resolve this, set specific exclusions or window hints in your WM's configuration file.
For example, for i3, add the following to your `XDG_CONFIG_HOME/i3/config` file (defaults to `$HOME/.config/i3/config`): For example, for i3, add the following to your ``XDG_CONFIG_HOME/i3/config`` file (defaults to ``$HOME/.config/i3/config``):
.. code:: console .. code:: console
for_window [instance="DZGUI"] floating enable, move position center for_window [instance="DZGUI"] floating enable, move position center
for_window [instance="DZGUI - Dialog"] floating enable, move position center for_window [instance="DZGUI - Dialog"] floating enable, move position center
DZG-010: Maps combobox extends to full height of window when there are many maps to choose from
---------------------------------------------------------------------------------------------------
This is a limitation of GTK 3. If and when DZGUI is refactored to support the GTK 4 API, this visual glitch is expected to be resolved.
DZG-011: GTK reports "Failed to load module 'xapp-gtk3-module' when starting DZGUI
---------------------------------------------------------------------------------------------------
This is a purely cosmetic message that appears when Cinnamon (Xapp) desktop integations are not present.
While you can suppress this message by installing the package ``xapp``, if you are not actually using Cinnamon as
part of your desktop environment, it will pull in a large number of unnecessary dependencies.
DZG-012: After adding the DZGUI Steam shortcut via the installer, shortcut icons do not appear in the small library list
-------------------------------------------------------------------------------------------------------------------------
It can take 1-2 restarts of the Steam client for these icons to synchronize.
+14 -5
View File
@@ -19,14 +19,14 @@ You will need at a minimum a :ref:`Steam Web API key<steam_api>` in order to bro
Steam Web API key Steam Web API key
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
**This step is required**. **This step is required**.
Register for a `Steam Web API key <https://steamcommunity.com/dev/apikey>`_ (free) using your Steam account. You will be asked for a unique URL for your app when registering. Register for a `Steam Web API key <https://steamcommunity.com/dev/apikey>`_ (free) using your Steam account.
Since this key is for a personal use application and does not actually call back anywhere, set a generic local identifier here like "127.0.0.1" or some other name that is meaningful to you. You will be asked for a unique URL for your app when registering. Typically, an API would send logs back to your URL in the form of callbacks.
However, since these API queries will be used for local consumption by a single user only, you can set a generic local identifier here like ``127.0.0.1`` to have the server discard them.
Once configured, you can insert this key in the app when launching it for the first time. Once configured, you can insert this API key in the app when launching it for the first time.
.. note:: .. note::
If you are confused about this requirement, please refer to DZGUI Knowledge Base article :ref:`DZG-007<DZG-007>` for additional information. If you are confused about this requirement, please refer to DZGUI Knowledge Base article :ref:`DZG-007<DZG-007>` for additional information.
@@ -36,7 +36,16 @@ Battlemetrics API key
.. warning:: .. warning::
This feature is no longer supported in DZGUI. Battlemetrics has switched to a paid service. This feature is no longer supported in DZGUI. Battlemetrics has switched to a paid service.
Battlemetrics queries are expected to fail in DZGUI 6. In DZGUI 7, this feature has been removed entirely.
Choosing a Steam client
^^^^^^^^^^^^^^^^^^^^^^^^^
If multiple Steam clients are available (native Steam client/Flatpak Steam client), you will be
asked to choose which you want to use. Due to the way Steam's inter-process communication and internal URIs work,
if you choose one or the other, you should not run both clients simultaneously. This can lead DZGUI to send requests to the wrong one.
.. note::
If you decide to switch to using a different Steam client with DZGUI, please uninstall fully (``dzgui -u``) and re-run the first time setup.
Next steps Next steps
-------------- --------------
-94
View File
@@ -1,94 +0,0 @@
Steam integration
====================
.. note::
In :doc:`DZGUI 7 <dzgui7>`, Steam shortcut creation and cover art setup are handled automatically during setup. You can skip this step unless you are using DZGUI 6.
DZGUI can be added to Steam as a "non-Steam game" in order to facilitate integration with Steam Deck or desktop environments.
First, launch Steam in the **Large** (default) view.
.. attention::
Steam Deck users: Gaming Mode has limited support for configuration of custom games. You will need to switch to **Desktop Mode** in order to add a non-Steam game.
.. figure:: images/01.png
:scale: 70%
:alt: Adding a non-Steam game
Select **Add a Game** > **Add a Non-Steam Game** from the bottom left corner of the Steam client.
Navigate to ``$HOME/.local/share/applications`` and select ``dzgui.desktop``.
Select **Add Selected Programs** to add a shortcut to DZGUI.
Artwork
^^^^^^^^^^
DZGUI ships with custom artwork that provides various cover/splash images to allow it to integrate with the rest of your games library.
.. figure:: images/02.png
:scale: 70%
:alt: Adding a non-Steam game
From the main library view, navigate to the app’s details page and right-click the blank image header at the top.
.. figure:: images/03.png
:scale: 70%
:alt: Adding a non-Steam game
Select **Set Custom Background**
Select to display **All Files** from the **File type** dropdown
Navigate to ``$HOME/.local/share/dzgui`` and select ``hero.png``.
.. figure:: images/04.png
:scale: 70%
:alt: Adding a non-Steam game
Next, right-click the image background and select **Set Custom Logo**.
Navigate to ``$HOME/.local/share/dzgui`` and select ``logo.png``.
.. figure:: images/05.png
:scale: 70%
:alt: Adding a non-Steam game
Notice that this removes the redundant app name that occluded the image, as seen above.
.. figure:: images/06.png
:scale: 70%
:alt: Adding a non-Steam game
Next, navigate to your Library index (looks like a bookshelf of cover art) and find the DZGUI app.
Right-click its cover and select **Manage** > **Set custom artwork**.
Navigate to ``$HOME/.local/share/dzgui`` and select ``grid.png``.
.. figure:: images/07.png
:scale: 70%
:alt: Adding a non-Steam game
The final result will create box art looking like the above.
.. figure:: images/08.png
:scale: 100%
:alt: Adding a non-Steam game
Next, right-click the DZGUI entry in your Library and select **Properties** to open the properties dialog. Next to the **Shortcut** field, you will see a small square box which represents the game’s
icon. Click this to open a file explorer, navigate to ``$HOME/.local/share/dzgui``, and select ``icon.png``. This will add a small icon to the list view.
Finally, after you launch DZGUI for the first time, you should quit the application and return to the Library view. Select the **Recent Games** dropdown on the right-hand side.
Steam shows a collection of box art based on categories like "Play Next", "Recent Games", etc. Look for a **downward-pointing caret icon** and click it, then select the **Recent Games** category.
.. figure:: images/09.png
:scale: 100%
:alt: Adding a non-Steam game
If DZGUI was the last item played, it will be shown with a landscape, rather than portrait, orientation cover, which is initially blank.
To customize this cover, right click it and select **Manage** > **Set custom artwork**, navigate to ``$HOME/.local/share/dzgui``, then select ``hero.png``.
+3 -7
View File
@@ -1,12 +1,8 @@
Uninstallation Uninstallation
================== ==================
To uninstall DZGUI and its associated files, invoke ``./dzgui`` from the terminal with the ``-u`` or ``--uninstall`` flag.
To uninstall DZGUI and its associated files, invoke ``./dzgui.sh`` with the ``-u`` or ``--uninstall`` flag. You will be prompted to select atomic files you wish to remove.
Follow the prompts to choose from:
- **Full uninstall** -- removes the application and all user-defined configuration files
- **Partial uninstall** -- removes the application, but keeps user-defined configuration files
.. tip:: .. tip::
If you intend to reinstall DZGUI again, keeping your configuration files is recommended. If you intend to reinstall DZGUI again, keeping your configuration files at a minimum is recommended.
+12 -8
View File
@@ -1,25 +1,29 @@
Usage Usage
========= =========
It is always advised to have Steam running in the background. DZGUI is meant to run "on top of" Steam. It is always advised to have Steam running in the background. DZGUI is meant to run "on top of" Steam.
DZGUI can be launched in one of three ways. DZGUI can be launched in one of three ways.
From a terminal From a terminal
------------------ ------------------
Invoke the command ``./dzgui`` from wherever you downloaded DZGUI to.
Invoke the command ``./dzgui.sh`` from wherever you downloaded the DZGUI script to.
Launching from a terminal may give more verbose information in the event of a crash, and can be a good way of troubleshooting problems. Launching from a terminal may give more verbose information in the event of a crash, and can be a good way of troubleshooting problems.
From the shortcut shipped with the application From the shortcut shipped with the application
-------------------------------------------------- --------------------------------------------------
When completing the first-time setup, you will be asked if you want to create additional system shortcuts.
If applicable for yourDesktop Environment, these shortcuts can be created.
On most distributions, if you are using a desktop environment based on the Freedesktop specification, shortcuts will be installed for you. - One shortcut will be located under the ``Games`` category of your system’s applications list/start menu.
- The other is accessed via the ``DZGUI`` shortcut on the desktop
- One shortcut is located under the ``Games`` category of your system’s applications list/start menu.
- The other is accessed via the ``DZGUI`` desktop icon (Steam Deck only)
From Steam From Steam
-------------- --------------
See :doc:`steam`. DZGUI will also ask you if you want to add a "non-Steam game" shortcut to Steam.
This shortcut will launch DZGUI directly and comes with integrated grid and cover artwork.
You must restart Steam for this shortcut to take effect in your library.
.. note::
You can also pass DZGUI launch parameter's to the Steam shortcut via Steam's right-click menu. See :doc:`flags`.
+2 -1
View File
@@ -111,7 +111,8 @@ class WorkshopACF(ACF):
def __init__(self, file: Path) -> None: def __init__(self, file: Path) -> None:
super().__init__(file) super().__init__(file)
def unpack(self, d: dict, lines: list[Any] = []) -> str: def unpack(self, d: dict[str, Any], lines: list[Any] = []) -> str:
self.indent: int
t1 = "AppWorkshop" t1 = "AppWorkshop"
t2 = ("WorkshopItemsInstalled", "WorkshopItemDetails") t2 = ("WorkshopItemsInstalled", "WorkshopItemDetails")
for k, v in d.items(): for k, v in d.items():
+12 -19
View File
@@ -2,10 +2,9 @@ import hashlib
import logging import logging
import re import re
from concurrent.futures import wait from concurrent.futures import ThreadPoolExecutor, wait
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass
from pathlib import Path from pathlib import Path
from typing import Any
from dzgui.api.steam import get_app_path from dzgui.api.steam import get_app_path
from dzgui.api.servers import get_rules, fqip_to_record from dzgui.api.servers import get_rules, fqip_to_record
@@ -18,20 +17,11 @@ from dzgui.const.constants import (
from dzgui.config.query import lookup from dzgui.config.query import lookup
from dzgui.const.enum import Preferences from dzgui.const.enum import Preferences
from dzgui.init.migrate import clean_legacy_versions_file
from typing import Any
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@dataclass
class ModMeta:
protocol: str
published_id: str
name: str
timestamp: str
def get_local_mod_ids(steam_path: Path) -> list[int]: def get_local_mod_ids(steam_path: Path) -> list[int]:
workshop_path = get_local_mod_path(steam_path) workshop_path = get_local_mod_path(steam_path)
mods = get_local_mods(workshop_path) mods = get_local_mods(workshop_path)
@@ -45,6 +35,10 @@ def get_local_mod_path(steam_path: Path) -> Path:
def get_local_mods(workshop_path: Path) -> list[Path]: def get_local_mods(workshop_path: Path) -> list[Path]:
# NOTE: user may not have staged mods before
if workshop_path.is_dir() is False:
logger.debug("Mod directory not yet present, returning empty list")
return []
mods = [file for file in workshop_path.iterdir() if file.is_dir()] mods = [file for file in workshop_path.iterdir() if file.is_dir()]
return mods return mods
@@ -114,10 +108,6 @@ def get_delimited_mods(steam_path: Path) -> list[Any]:
return parse_mods(mods) return parse_mods(mods)
def get_missing_mods(local: list, remote: list) -> list:
return [mod for mod in remote if mod not in local]
def _hash(uid: str, use_custom: bool = False) -> str: def _hash(uid: str, use_custom: bool = False) -> str:
md5 = hashlib.md5() md5 = hashlib.md5()
md5.update(uid.encode("ascii")) md5.update(uid.encode("ascii"))
@@ -129,12 +119,15 @@ def remove_stale_signatures(
config: Path, versions: Path, ids: list[int] | None = None config: Path, versions: Path, ids: list[int] | None = None
) -> None: ) -> None:
if versions.is_file() is False: if versions.is_file() is False:
logger.warning("Creating new version signatures file") logger.debug("Creating new version signatures file")
versions.touch() versions.touch()
return return
clean_legacy_versions_file(versions)
path = lookup(config, Preferences.DEFAULT) path = lookup(config, Preferences.DEFAULT)
steam_path = Path(path) steam_path = Path(path)
if ids is None: if ids is None:
local_ids = get_local_mod_ids(steam_path) local_ids = get_local_mod_ids(steam_path)
@@ -152,7 +145,7 @@ def remove_stale_signatures(
def find_stale_mods(config: Path) -> list[int]: def find_stale_mods(config: Path) -> list[int]:
def push_record(rec: str) -> list: def push_record(rec: str) -> list[int]:
record = fqip_to_record(rec) record = fqip_to_record(rec)
if record is None: if record is None:
return [] return []
+35 -32
View File
@@ -9,12 +9,13 @@ import subprocess
import threading import threading
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Optional, TYPE_CHECKING, Union from typing import Any, TYPE_CHECKING, Union
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
from dzgui.const.endpoints import STEAM_SERVERS from dzgui.const.endpoints import STEAM_SERVERS
from dzgui.model.proxy_model import ServerRow
from dzgui.util.format import format_exception from dzgui.util.format import format_exception
from dzgui.util import strings from dzgui.strings import metadata
import a2s import a2s
import dayzquery import dayzquery
@@ -111,7 +112,7 @@ def get_netmask() -> str:
# TODO: rename # TODO: rename
def test_ip(suffix: int, port: int, event: threading.Event) -> dict | None: def test_ip(suffix: int, port: int, event: threading.Event) -> dict[str, Any] | None:
if event.is_set(): if event.is_set():
return None return None
netmask = get_netmask() netmask = get_netmask()
@@ -139,7 +140,9 @@ def sanitize(name: str) -> str:
return name return name
def parse_json(json: list) -> list: def parse_json(
json: list[dict[str, Any]],
) -> list[ServerRow]:
""" """
Server metadata is underspecified and server operators Server metadata is underspecified and server operators
tend to insert random garbage in the headers. In case tend to insert random garbage in the headers. In case
@@ -179,14 +182,14 @@ def parse_json(json: list) -> list:
continue continue
if "no3rd" in r: if "no3rd" in r:
view = strings.filter_1pp view = metadata.filter_1pp
else: else:
view = strings.filter_3pp view = metadata.filter_3pp
if "external" in r: if "external" in r:
provider = strings.filter_unofficial provider = metadata.filter_unofficial
else: else:
provider = strings.filter_official provider = metadata.filter_official
if "mod" in r: if "mod" in r:
modded = True modded = True
@@ -206,9 +209,9 @@ def parse_json(json: list) -> list:
if test_time: if test_time:
time = test_time.group(0) time = test_time.group(0)
else: else:
time = strings.unknown time = metadata.unknown
except AttributeError: except AttributeError:
time = strings.unknown time = metadata.unknown
try: try:
ip = row["addr"].split(":")[0] + ":" + str(row["gameport"]) ip = row["addr"].split(":")[0] + ":" + str(row["gameport"])
@@ -224,7 +227,7 @@ def parse_json(json: list) -> list:
mapname = row["map"].lower() mapname = row["map"].lower()
players = row["players"] players = row["players"]
max_players = row["max_players"] max_players = row["max_players"]
raw = ( raw = ServerRow(
name, name,
mapname, mapname,
view, view,
@@ -287,7 +290,7 @@ def query_direct(ip: str, qport: int, timeout: float = 3.0) -> dict[str, Any] |
def get_details(record: Record) -> Details | None: def get_details(record: Record) -> Details | None:
ip = record.ip ip = record.ip
qport = record.qport qport = record.qport
default_str = strings.none_provided default_str = metadata.none_provided
try: try:
info = a2s.info((ip, qport)) info = a2s.info((ip, qport))
@@ -297,9 +300,9 @@ def get_details(record: Record) -> Details | None:
logger.critical(e) logger.critical(e)
return None return None
battleye = strings.disabled battleye = metadata.disabled
if "battleye" in keywords: if "battleye" in keywords:
battleye = strings.enabled battleye = metadata.enabled
name = info.server_name name = info.server_name
day_accel = 1.0 day_accel = 1.0
@@ -319,48 +322,48 @@ def get_details(record: Record) -> Details | None:
try: try:
password = info.password_protected password = info.password_protected
if password is False: if password is False:
password = strings.disabled password = metadata.disabled
else: else:
password = strings.enabled password = metadata.enabled
except AttributeError: except AttributeError:
password = "-" password = "-"
try: try:
vac = info.vac_enabled vac = info.vac_enabled
if vac is False: if vac is False:
vac = strings.disabled vac = metadata.disabled
else: else:
vac = strings.enabled vac = metadata.enabled
except AttributeError: except AttributeError:
vac = strings.null vac = metadata.null
try: try:
version = info.version version = info.version
except AttributeError: except AttributeError:
version = strings.null version = metadata.null
try: try:
dlc = rules.dlc_flags dlc = rules.dlc_flags
match dlc: match dlc:
case 0: case 0:
dlc = strings.dlc_none dlc = metadata.dlc_none
case 2: case 2:
dlc = strings.dlc_frostline dlc = metadata.dlc_frostline
case 4: case 4:
dlc = strings.dlc_badlands dlc = metadata.dlc_badlands
case _: case _:
dlc = strings.unspecified dlc = metadata.unspecified
except AttributeError: except AttributeError:
dlc = strings.unspecified dlc = metadata.unspecified
try: try:
platform = rules.platform platform = rules.platform
if platform == "win": if platform == "win":
platform = strings.windows platform = metadata.windows
if platform == "?": if platform == "?":
platform = strings.linux platform = metadata.linux
except AttributeError: except AttributeError:
platform = strings.unspecified platform = metadata.unspecified
try: try:
description = rules.description.strip() description = rules.description.strip()
@@ -488,7 +491,7 @@ def query_by_record(record: Record, update_gameport: bool = False) -> A2SInfo:
return A2SInfo(record, None) return A2SInfo(record, None)
def short_ip_to_record(addr: str) -> Optional[Record]: def short_ip_to_record(addr: str) -> Record | None:
r = addr.split(":") r = addr.split(":")
# TODO: raise exceptions instead of Nonetype # TODO: raise exceptions instead of Nonetype
if len(r) != 2: if len(r) != 2:
@@ -496,7 +499,7 @@ def short_ip_to_record(addr: str) -> Optional[Record]:
return Record(r[0], 0, int(r[1])) return Record(r[0], 0, int(r[1]))
def fqip_to_record(addr: str) -> Optional[Record]: def fqip_to_record(addr: str) -> Record | None:
r = addr.split(":") r = addr.split(":")
if len(r) != 3: if len(r) != 3:
return None return None
@@ -507,14 +510,14 @@ def record_to_fqip(record: Record) -> str:
return f"{record.ip}:{record.gameport}:{record.qport}" return f"{record.ip}:{record.gameport}:{record.qport}"
def response_to_fqip(res: dict) -> str: def response_to_fqip(res: dict[str, Any]) -> str:
ip = res["addr"].split(":")[0] ip = res["addr"].split(":")[0]
gameport = res["gameport"] gameport = res["gameport"]
qport = res["addr"].split(":")[1] qport = res["addr"].split(":")[1]
return f"{ip}:{gameport}:{qport}" return f"{ip}:{gameport}:{qport}"
def response_to_record(res: dict) -> Record: def response_to_record(res: dict[str, Any]) -> Record:
ip = res["addr"].split(":")[0] ip = res["addr"].split(":")[0]
gameport = res["gameport"] gameport = res["gameport"]
qport = res["addr"].split(":")[1] qport = res["addr"].split(":")[1]
+6 -4
View File
@@ -2,7 +2,7 @@ import binascii
import ctypes import ctypes
import logging import logging
import shutil import shutil
import vdf # type: ignore import vdf # type: ignore[import-untyped]
from dataclasses import dataclass from dataclasses import dataclass
from importlib import resources from importlib import resources
@@ -12,7 +12,7 @@ from typing import Any
from dzgui.api.steam import find_user_id_32 from dzgui.api.steam import find_user_id_32
from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
from dzgui.util.dirs import copy_dzgui_to_xdg_data, make_parents from dzgui.util.dirs import copy_dzgui_to_xdg_data, make_parents
from dzgui.util.strings import unknown from dzgui.strings import metadata
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -61,10 +61,10 @@ class Shortcuts:
return str(self.shortcuts["shortcuts"][key]["AppName"]) return str(self.shortcuts["shortcuts"][key]["AppName"])
except Exception as e: except Exception as e:
logger.debug(e) logger.debug(e)
return unknown return metadata.unknown
except Exception as e: except Exception as e:
logger.debug(e) logger.debug(e)
return unknown return metadata.unknown
def get_shortcuts(self) -> Any: def get_shortcuts(self) -> Any:
return self.shortcuts return self.shortcuts
@@ -114,6 +114,7 @@ class Shortcuts:
make_parents(dest) make_parents(dest)
b = images.joinpath(img).with_suffix(".png").read_bytes() b = images.joinpath(img).with_suffix(".png").read_bytes()
dest.write_bytes(b) dest.write_bytes(b)
logger.debug(f"Wrote grid image to '{dest}'")
# NOTE: legacy Big Picture header # NOTE: legacy Big Picture header
b = images.joinpath("_hero.png").read_bytes() b = images.joinpath("_hero.png").read_bytes()
@@ -127,6 +128,7 @@ class Shortcuts:
except Exception: except Exception:
n = 0 n = 0
self.shortcuts["shortcuts"][str(n)] = entry self.shortcuts["shortcuts"][str(n)] = entry
logger.debug(f"Added shortcut at index {n}")
@classmethod @classmethod
def _create_entry(cls, meta: ShortcutMetadata) -> dict[str, Any]: def _create_entry(cls, meta: ShortcutMetadata) -> dict[str, Any]:
+30 -18
View File
@@ -4,7 +4,7 @@ import psutil
import re import re
import requests import requests
import subprocess import subprocess
import vdf # type: ignore import vdf # type: ignore[import-untyped]
from pathlib import Path from pathlib import Path
from requests.exceptions import HTTPError from requests.exceptions import HTTPError
@@ -12,9 +12,7 @@ from typing import Any, Generator, Union
from warnings import deprecated from warnings import deprecated
from dzgui.api.acf import ACF from dzgui.api.acf import ACF
from dzgui.const.endpoints import VALIDATE from dzgui.config.xdg import get_real_home
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.const.constants import ( from dzgui.const.constants import (
APPID_DAYZ, APPID_DAYZ,
APPID_DAYZ_EXP, APPID_DAYZ_EXP,
@@ -27,15 +25,19 @@ from dzgui.const.constants import (
FLATPAK_STEAM_PATH, FLATPAK_STEAM_PATH,
LIBRARYFOLDERS_PATH, LIBRARYFOLDERS_PATH,
REQUEST_TIMEOUT, REQUEST_TIMEOUT,
SNAP_STEAM_PATH,
UBUNTU_STEAM_PATH, UBUNTU_STEAM_PATH,
VDF_PATH, VDF_PATH,
) )
from dzgui.const.endpoints import ( from dzgui.const.endpoints import (
APP_DETAILS, STEAM_APP_DETAILS,
SUB_ENDPOINT,
STEAM_PUBLISHED_FILES, STEAM_PUBLISHED_FILES,
UNSUB_ENDPOINT, STEAM_SUB,
STEAM_UNSUB,
VALIDATE,
) )
from dzgui.init.prereqs import has_any_client
from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.strings import wizard from dzgui.strings import wizard
from dzgui.strings.errors import api_validation_error, workshop_endpoint_error from dzgui.strings.errors import api_validation_error, workshop_endpoint_error
from dzgui.util.bash import concat_bash_args from dzgui.util.bash import concat_bash_args
@@ -64,26 +66,36 @@ class VDFLoadError(Exception):
def get_steam_paths() -> list[tuple[Path, str]]: def get_steam_paths() -> list[tuple[Path, str]]:
paths = [] paths = []
if has_any_client(): if has_any_client():
HOME = Path.home() HOME = get_real_home()
env = os.environ.get("XDG_DATA_HOME") env = os.environ.get("XDG_DATA_HOME")
if env is not None: if env is not None:
XDG_DATA_HOME = env XDG_DATA_HOME = Path(env)
DEFAULT_PATH = XDG_DATA_HOME.joinpath("Steam")
default_label = wizard.desc_custom_path
else: else:
XDG_DATA_HOME = DEFAULT_STEAM_PATH DEFAULT_PATH = HOME.joinpath(DEFAULT_STEAM_PATH)
default_label = wizard.desc_default_path
DEFAULT_PATH = HOME.joinpath(XDG_DATA_HOME)
FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH) FLATPAK_PATH = HOME.joinpath(FLATPAK_STEAM_PATH)
UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH) UBUNTU_PATH = HOME.joinpath(UBUNTU_STEAM_PATH)
DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH) DEBIAN_PATH = HOME.joinpath(DEBIAN_STEAM_PATH)
SNAP_PATH = HOME.joinpath(SNAP_STEAM_PATH)
human = { human = {
DEFAULT_PATH: wizard.desc_default_path, DEFAULT_PATH: default_label,
FLATPAK_PATH: wizard.desc_flatpak_path, FLATPAK_PATH: wizard.desc_flatpak_path,
UBUNTU_PATH: wizard.desc_ubuntu_path, UBUNTU_PATH: wizard.desc_ubuntu_path,
SNAP_PATH: wizard.desc_snap_path,
DEBIAN_PATH: wizard.desc_debian_path, DEBIAN_PATH: wizard.desc_debian_path,
} }
for path in DEFAULT_PATH, FLATPAK_PATH, UBUNTU_PATH, DEBIAN_PATH: for path in (
DEFAULT_PATH,
FLATPAK_PATH,
UBUNTU_PATH,
SNAP_PATH,
DEBIAN_PATH,
):
if path is FLATPAK_PATH and has_flatpak_client() is False: if path is FLATPAK_PATH and has_flatpak_client() is False:
continue continue
if path is not FLATPAK_PATH and has_steam_client() is False: if path is not FLATPAK_PATH and has_steam_client() is False:
@@ -310,11 +322,11 @@ def update_workshop(key: str, mod: int, endpoint: str) -> None:
def subscribe(key: str, mod: int) -> None: def subscribe(key: str, mod: int) -> None:
update_workshop(key, mod, SUB_ENDPOINT) update_workshop(key, mod, STEAM_SUB)
def unsubscribe(key: str, mod: int) -> None: def unsubscribe(key: str, mod: int) -> None:
update_workshop(key, mod, UNSUB_ENDPOINT) update_workshop(key, mod, STEAM_UNSUB)
def validate_mod(client: str, mod: str) -> None: def validate_mod(client: str, mod: str) -> None:
@@ -485,11 +497,11 @@ def is_dayz_downloading(steam_path: Path, appid: int) -> bool:
def get_app_path(folders_path: Path, appid: int) -> Path: def get_app_path(folders_path: Path, appid: int) -> Path:
app_path = None app_path = None
try: try:
with open(folders_path / LIBRARYFOLDERS_PATH) as f: with open(folders_path / LIBRARYFOLDERS_PATH) as f:
folders = vdf.load(f) folders = vdf.load(f)
except Exception: except Exception as e:
logger.debug(e)
raise VDFLoadError("Failed to parse libraryfolders") raise VDFLoadError("Failed to parse libraryfolders")
for obj in folders["libraryfolders"]: for obj in folders["libraryfolders"]:
@@ -512,7 +524,7 @@ def get_app_path(folders_path: Path, appid: int) -> Path:
def get_app_name(appid: int) -> str | None: def get_app_name(appid: int) -> str | None:
payload = {"appids": [appid]} payload = {"appids": [appid]}
res = requests.get(APP_DETAILS, params=payload) res = requests.get(STEAM_APP_DETAILS, params=payload)
if res.status_code != 200: if res.status_code != 200:
return None return None
try: try:
+4 -12
View File
@@ -6,7 +6,6 @@ from importlib import resources
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.const.constants import ( from dzgui.const.constants import (
APP_NAME, APP_NAME,
APP_NAME_LOWER, APP_NAME_LOWER,
@@ -18,20 +17,18 @@ from dzgui.config.query import lookup
from dzgui.config.userprefs import UserPrefs from dzgui.config.userprefs import UserPrefs
from dzgui.config.xdg import get_xdg_paths, parse_filepaths from dzgui.config.xdg import get_xdg_paths, parse_filepaths
from dzgui.init.migrate import ( from dzgui.init.migrate import (
has_new_config,
copy_state_files, copy_state_files,
has_new_config,
migrate_cols_file, migrate_cols_file,
) )
from dzgui.init.flock import lock_acquire
from dzgui.init.prereqs import has_flatpak_client, has_steam_client from dzgui.init.prereqs import has_flatpak_client, has_steam_client
from dzgui.strings import boot from dzgui.strings import boot, errors
from dzgui.util.deck import is_steam_deck, is_game_mode from dzgui.util.deck import is_steam_deck, is_game_mode
from dzgui.util.dirs import make_parents from dzgui.util.dirs import make_parents
from dzgui.util.localize import set_locale from dzgui.util.localize import set_locale
from dzgui.util.map_count import test_map_count from dzgui.util.map_count import test_map_count
from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS
from dzgui.util.strings import init
from dzgui.views.base import App from dzgui.views.base import App
from dzgui.views.dialogs.boot import BootWindow from dzgui.views.dialogs.boot import BootWindow
@@ -108,7 +105,7 @@ def load_steam_icon() -> None:
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa from gi.repository import Gtk
try: try:
traversable = resources.files(APP_NAME_LOWER).joinpath(ICONS_PATH) traversable = resources.files(APP_NAME_LOWER).joinpath(ICONS_PATH)
@@ -122,8 +119,6 @@ def load_steam_icon() -> None:
def build_gui(version: str, is_debug: bool) -> App | None: def build_gui(version: str, is_debug: bool) -> App | None:
lock = lock_acquire() # noqa
set_locale() set_locale()
# NOTE: consider aborting this check if steam deck # NOTE: consider aborting this check if steam deck
xdg_paths = get_xdg_paths() xdg_paths = get_xdg_paths()
@@ -158,15 +153,12 @@ def build_gui(version: str, is_debug: bool) -> App | None:
f.truncate(0) f.truncate(0)
if _is_steam_deck is False: if _is_steam_deck is False:
# TODO: sudo escalation dialog
# count = get_map_count()
# TODO: move into module
if FLATPAK_ROOT_PATH in lookup(XDG.config, Preferences.DEFAULT): if FLATPAK_ROOT_PATH in lookup(XDG.config, Preferences.DEFAULT):
has_client = has_flatpak_client() has_client = has_flatpak_client()
else: else:
has_client = has_steam_client() has_client = has_steam_client()
if has_client is False: if has_client is False:
EarlyAlertDialog(init.requires_steam) EarlyAlertDialog(errors.requires_steam)
bootwin = BootWindow(XDG, version) bootwin = BootWindow(XDG, version)
local_coords, latest_release = bootwin.get_results() local_coords, latest_release = bootwin.get_results()
+3 -1
View File
@@ -3,6 +3,7 @@ import textwrap
from pathlib import Path from pathlib import Path
from dzgui.config.xdg import get_real_home
from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents from dzgui.util.dirs import copy_dzgui_to_xdg_data, find_icon_resource, make_parents
@@ -36,7 +37,8 @@ def write_desktop_file(exe_path: Path) -> Path:
def write_desktop_shortcut(desktop_file: Path) -> None: def write_desktop_shortcut(desktop_file: Path) -> None:
# NOTE: necessarily depends on the above (UI blocks creation without XDG entry first) # NOTE: necessarily depends on the above (UI blocks creation without XDG entry first)
link = Path.home().joinpath("Desktop/dzgui.desktop") home = get_real_home()
link = home.joinpath("Desktop/dzgui.desktop")
make_parents(link) make_parents(link)
if link.exists(): if link.exists():
link.unlink() link.unlink()
+2 -1
View File
@@ -5,6 +5,7 @@ from dzgui.util._json import read_json
from dzgui.const.enum import Preferences from dzgui.const.enum import Preferences
class ConfigFileError(Exception): class ConfigFileError(Exception):
pass pass
@@ -39,4 +40,4 @@ def get_favorites(path: Path) -> list[str]:
def enum_to_key(enum: Preferences) -> str: def enum_to_key(enum: Preferences) -> str:
return str(enum.dict["key"]) return str(enum.key)
+2 -1
View File
@@ -6,7 +6,8 @@ if TYPE_CHECKING:
from dzgui.util.ip import Coords from dzgui.util.ip import Coords
# NOTE: mutable dataclass, 'use_miles' key changes on demand # NOTE: mutable dataclass: 'use_miles' key changes on demand
# 'frozen' cannot be True
@dataclass(slots=True) @dataclass(slots=True)
class UserPrefs: class UserPrefs:
is_steam_deck: bool is_steam_deck: bool
+12 -9
View File
@@ -6,13 +6,11 @@ from dataclasses import dataclass
from dzgui.const.constants import ( from dzgui.const.constants import (
APP_NAME_LOWER, APP_NAME_LOWER,
DEBUG_LOG, DEBUG_LOG,
FLATPAK_ROOT_PATH,
SYSTEM_LOG, SYSTEM_LOG,
) )
from dzgui.init.proc import is_sandboxed
@dataclass @dataclass(slots=True, frozen=True)
class Xdg: class Xdg:
config: Path config: Path
columns: Path columns: Path
@@ -50,9 +48,17 @@ def is_writeable(path_str: str) -> bool:
file.unlink() file.unlink()
return True return True
def get_real_home() -> Path:
def get_xdg_paths() -> dict:
home = Path.home() home = Path.home()
if resolved := os.environ.get("SNAP_REAL_HOME"): # Snap
home = Path(resolved)
elif resolved := os.environ.get("HOME"): # Flatpak
home = Path(resolved)
return home
def get_xdg_paths() -> dict[str, Path]:
home = get_real_home()
xdg_paths = { xdg_paths = {
"XDG_CONFIG_HOME": home / ".config", "XDG_CONFIG_HOME": home / ".config",
"XDG_STATE_HOME": home / ".local" / "state", "XDG_STATE_HOME": home / ".local" / "state",
@@ -62,9 +68,6 @@ def get_xdg_paths() -> dict:
resolved_paths = {} resolved_paths = {}
for path in xdg_paths: for path in xdg_paths:
real_path = os.environ.get(path) real_path = os.environ.get(path)
if real_path is not None and is_sandboxed():
search_string = FLATPAK_ROOT_PATH + "/"
real_path = real_path.replace(search_string, "")
if real_path is not None and is_writeable(real_path): if real_path is not None and is_writeable(real_path):
new_path = Path(real_path) new_path = Path(real_path)
else: else:
@@ -73,7 +76,7 @@ def get_xdg_paths() -> dict:
return resolved_paths return resolved_paths
def parse_filepaths(xdg: dict) -> Xdg: def parse_filepaths(xdg: dict[str, Path]) -> Xdg:
config = xdg["XDG_CONFIG_HOME"] config = xdg["XDG_CONFIG_HOME"]
state = xdg["XDG_STATE_HOME"] state = xdg["XDG_STATE_HOME"]
share = xdg["XDG_DATA_HOME"] share = xdg["XDG_DATA_HOME"]
+2 -29
View File
@@ -37,37 +37,8 @@ HEX_GREEN = "#32CD32"
HEX_RED = "#FF0000" HEX_RED = "#FF0000"
HEX_ORANGE = "#FFAC1C" HEX_ORANGE = "#FFAC1C"
# TODO: normalize icon names
CALCULATOR = "accessories-calculator-symbolic"
CARET_DOWN = "go-down-symbolic"
CARET_UP = "go-up-symbolic"
CLIPBOARD = "edit-copy-symbolic"
CLOSE = "window-close-symbolic"
FOLDER = "folder-symbolic"
EDIT_DELETE = "edit-delete-symbolic"
ERROR = "dialog-error-symbolic"
HELP_BUBBLE = "help-about-symbolic"
INPUT_KEYBOARD = "input-keyboard-symbolic"
LIST_ADD = "list-add-symbolic"
REFRESH_ICON = "view-refresh-symbolic"
SEARCH_ICON = "system-search-symbolic"
STEAM_ICON = "steam-tray-symbolic"
VIEW_CONCEAL = "view-conceal-symbolic"
VIEW_REVEAL = "view-reveal-symbolic"
WARNING = "dialog-warning-symbolic"
WEB_BROWSER = "web-browser-symbolic"
DAY_ICON = "weather-clear-symbolic"
NIGHT_ICON = "weather-clear-night-symbolic"
SEPARATOR = "SEPARATOR" SEPARATOR = "SEPARATOR"
# TODO: drop
NO_PADDING = 0
NO_EXPAND = False
NO_FILL = False
EXPAND = True
FILL = True
SCROLL_INCREMENT = 50 SCROLL_INCREMENT = 50
WINDOW_DEFAULT_X = 1400 WINDOW_DEFAULT_X = 1400
WINDOW_DEFAULT_Y = 800 WINDOW_DEFAULT_Y = 800
@@ -81,6 +52,7 @@ SYSTEM_LOG = f"{APP_NAME}_SYSTEM.LOG"
CHANGELOG_PATH = "data/CHANGELOG.md" CHANGELOG_PATH = "data/CHANGELOG.md"
IMAGES_PATH = "data/images" IMAGES_PATH = "data/images"
ICONS_PATH = "data/images/gtk" ICONS_PATH = "data/images/gtk"
LOG_DELIMITER = "␞"
HERO_PATH = "data/images/_hero.png" HERO_PATH = "data/images/_hero.png"
CSS_PATH = "data/app.css" CSS_PATH = "data/app.css"
@@ -89,6 +61,7 @@ DEFAULT_STEAM_PATH = ".local/share/Steam"
FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam" FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam"
FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam" FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam"
UBUNTU_STEAM_PATH = ".steam/steam" UBUNTU_STEAM_PATH = ".steam/steam"
SNAP_STEAM_PATH = "snap/steam/common/" + DEFAULT_STEAM_PATH
DEBIAN_STEAM_PATH = ".steam/debian-installation" DEBIAN_STEAM_PATH = ".steam/debian-installation"
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG") LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
+5 -5
View File
@@ -3,14 +3,14 @@ STEAM_PUBLISHED_FILES = (
"https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1" "https://api.steampowered.com/ISteamRemoteStorage/GetPublishedFileDetails/v1"
) )
STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1" STEAM_SERVERS = "https://api.steampowered.com/IGameServersService/GetServerList/v1"
SUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1" STEAM_SUB = "https://api.steampowered.com/IPublishedFileService/Subscribe/v1"
UNSUB_ENDPOINT = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1" STEAM_UNSUB = "https://api.steampowered.com/IPublishedFileService/Unsubscribe/v1"
APP_DETAILS = "https://store.steampowered.com/api/appdetails?" STEAM_APP_DETAILS = "https://store.steampowered.com/api/appdetails?"
GITHUB = "https://github.com/aclist" GITHUB = "https://github.com/aclist"
GITHUB_RELEASES = "https://api.github.com/repos/aclist/dztui/releases/latest" GITHUB_RELEASES = "https://api.github.com/repos/aclist/dzgui/releases/latest"
CODEBERG_RELEASES = "https://codeberg.org/api/v1/repos/aclist/dzgui/releases/latest" CODEBERG_RELEASES = "https://codeberg.org/api/v1/repos/aclist/dzgui/releases/latest"
GITHUB_USER_RELEASES = "https://github.com/aclist/dztui/releases" GITHUB_USER_RELEASES = "https://github.com/aclist/dzgui/releases"
DB_IP = "https://db-ip.com/db/download/ip-to-city-lite" DB_IP = "https://db-ip.com/db/download/ip-to-city-lite"
IP_ECHO = "https://ipecho.net/plain" IP_ECHO = "https://ipecho.net/plain"
COORDS_API = "http://ip-api.com/json" COORDS_API = "http://ip-api.com/json"
+223 -208
View File
@@ -1,7 +1,8 @@
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum from enum import Enum
from typing import Any, Self
from dzgui.util import strings from dzgui.strings import crumbs, context_menu, mod_panel, rows, side_buttons
class Port(Enum): class Port(Enum):
@@ -46,125 +47,61 @@ class FilterMode(Enum):
TOGGLE_ON = 3 TOGGLE_ON = 3
class EnumWithAttrs(Enum): @dataclass(slots=True, frozen=True)
def __new__(cls, *args: Any, **kwargs: Any) -> Self: class ModButtonMeta:
value = len(cls.__members__) + 1 label: str
obj = object.__new__(cls) tooltip: str
obj._value_ = value
return obj
def __init__(self, d: dict):
self.dict = d
class Preferences(EnumWithAttrs): @dataclass(slots=True, frozen=True)
STEAM = { class ButtonTypeMeta:
"key": "steam_api", label: str
} tooltip: str
CLIENT = { opens: NotebookPage | None
"key": "client",
}
WINDOW = {
"key": "fullscreen",
}
DIST = {
"key": "use_miles",
}
NAME = {
"key": "name",
}
DEFAULT = {
"key": "default_steam_path",
}
FAV_LBL = {
"key": "fav_label",
}
FAV_SRV = {
"key": "fav_server",
}
IP_LIST = {
"key": "ip_list",
}
START_TAB = {
"key": "start_tab",
}
class NotebookPage(EnumWithAttrs): @dataclass(slots=True, frozen=True)
OFFLINE = {"crumbs": strings.crumbs.offline, "statusbar": True} class ConfigKey:
CHANGELOG = {"crumbs": strings.crumbs.changelog, "statusbar": True} key: str
DEVELOPERS = {"crumbs": strings.crumbs.developers, "statusbar": False}
HELP = {"crumbs": strings.crumbs._help, "statusbar": True}
KEYS = {"crumbs": strings.crumbs.keys, "statusbar": True}
LOG = {"crumbs": strings.crumbs.log, "statusbar": True}
MODS = {"crumbs": strings.crumbs.mods, "statusbar": True}
OPTIONS = {"crumbs": strings.crumbs.options, "statusbar": False}
SERVERS = {"crumbs": strings.crumbs.servers, "statusbar": True}
THANKS = {"crumbs": strings.crumbs.thanks, "statusbar": True}
CONNECTION = {"crumbs": "Connect", "statusbar": True}
class RowType(EnumWithAttrs): @dataclass(slots=True, frozen=True)
# TODO: strings class NotebookMeta:
CHANGELOG = { crumbs: str
"label": "View changelog", has_statusbar: bool
"tooltip": "Opens the DZGUI changelog",
}
SHOW_LOG = {
"label": "Show debug log",
"tooltip": "Read the DZGUI log generated since startup",
}
SEPARATOR = {
"label": "SEPARATOR",
"tooltip": "",
}
DUMP_LOG = {
"label": "Output system info to log file",
"tooltip": "Dump diagnostic data for troubleshooting",
}
DOCS = {
"label": "Documentation/help files (GitHub) ⧉",
"tooltip": "Open the DZGUI documentation in a browser",
}
DOCS_FALLBACK = {
"label": "Documentation/help files (Codeberg mirror) ⧉",
"tooltip": "Open the DZGUI documentation in a browser",
}
BUGS = {
"label": "Report a bug (GitHub) ⧉",
"tooltip": "Open the DZGUI issue tracker in a browser",
}
FORUM = {
"label": "DZGUI Subreddit ⧉",
"tooltip": "Open the DZGUI discussion forum in a browser",
}
SPONSOR = {
"label": "Sponsor (GitHub) ⧉",
"tooltip": "Sponsor development of the DZGUI project",
}
THANKS = {
"label": "Special thanks",
"tooltip": "A list of contributors, testers, and sponsors",
}
# TODO: rename to ContextMenuItem @dataclass(slots=True, frozen=True)
class ContextMenu(EnumWithAttrs): class RowMeta:
ADD_NOTE = {"label": strings.add_note} label: str
ADD_SERVER = {"label": strings.add} tooltip: str
CONNECT = {"label": strings.connect}
COPY_LOG_CLIPBOARD = {"label": strings.copy_log}
COPY_SERVER_IP = {"label": strings.copy_ip} @dataclass(slots=True, frozen=True)
COPY_SERVER_NAME = {"label": strings.copy_name} class ContextMenuMeta:
UNSUB_MOD = {"label": strings.unsub_mod} label: str
VALIDATE_MOD = {"label": strings.validate_mod}
OPEN_WORKSHOP = {"label": strings.open_workshop}
REFRESH_PLAYERS = {"label": strings.refresh_players} class ContextMenuItem(Enum):
REMOVE_HISTORY = {"label": strings.remove_history} ADD_NOTE = ContextMenuMeta(context_menu.add_note)
REMOVE_SERVER = {"label": strings.remove} ADD_SERVER = ContextMenuMeta(context_menu.add)
SET_FAV = {"label": strings.add_fav} CONNECT = ContextMenuMeta(context_menu.connect)
SHOW_DETAILS = {"label": strings.show_details} COPY_LOG_CLIPBOARD = ContextMenuMeta(context_menu.copy_log)
SHOW_MODS = {"label": strings.show_mods} COPY_SERVER_IP = ContextMenuMeta(context_menu.copy_ip)
COPY_SERVER_NAME = ContextMenuMeta(context_menu.copy_name)
UNSUB_MOD = ContextMenuMeta(context_menu.unsub_mod)
VALIDATE_MOD = ContextMenuMeta(context_menu.validate_mod)
OPEN_WORKSHOP = ContextMenuMeta(context_menu.open_workshop)
REFRESH_PLAYERS = ContextMenuMeta(context_menu.refresh_players)
REMOVE_HISTORY = ContextMenuMeta(context_menu.remove_history)
REMOVE_SERVER = ContextMenuMeta(context_menu.remove)
SET_FAV = ContextMenuMeta(context_menu.set_fav)
SHOW_DETAILS = ContextMenuMeta(context_menu.show_details)
SHOW_MODS = ContextMenuMeta(context_menu.show_mods)
@property
def label(self) -> str:
return self.value.label
class ContextMenuGroup(Enum): class ContextMenuGroup(Enum):
@@ -172,119 +109,197 @@ class ContextMenuGroup(Enum):
Groupings of context menu items Groupings of context menu items
""" """
SERVER_MOD = (ContextMenu.OPEN_WORKSHOP,) SERVER_MOD = (ContextMenuItem.OPEN_WORKSHOP,)
MOD = (ContextMenu.OPEN_WORKSHOP, ContextMenu.UNSUB_MOD, ContextMenu.VALIDATE_MOD) MOD = (
ContextMenuItem.OPEN_WORKSHOP,
ContextMenuItem.UNSUB_MOD,
ContextMenuItem.VALIDATE_MOD,
)
MOD_OFFLINE = (None,) MOD_OFFLINE = (None,)
LOG = (ContextMenu.COPY_LOG_CLIPBOARD,) LOG = (ContextMenuItem.COPY_LOG_CLIPBOARD,)
SERVER_BROWSER = ( SERVER_BROWSER = (
ContextMenu.CONNECT, ContextMenuItem.CONNECT,
ContextMenu.ADD_SERVER, ContextMenuItem.ADD_SERVER,
ContextMenu.SET_FAV, ContextMenuItem.SET_FAV,
ContextMenu.COPY_SERVER_NAME, ContextMenuItem.COPY_SERVER_NAME,
ContextMenu.COPY_SERVER_IP, ContextMenuItem.COPY_SERVER_IP,
ContextMenu.ADD_NOTE, ContextMenuItem.ADD_NOTE,
ContextMenu.SHOW_MODS, ContextMenuItem.SHOW_MODS,
ContextMenu.SHOW_DETAILS, ContextMenuItem.SHOW_DETAILS,
ContextMenu.REFRESH_PLAYERS, ContextMenuItem.REFRESH_PLAYERS,
) )
SCAN_LAN = ( SCAN_LAN = (
ContextMenu.CONNECT, ContextMenuItem.CONNECT,
ContextMenu.SET_FAV, ContextMenuItem.SET_FAV,
ContextMenu.COPY_SERVER_NAME, ContextMenuItem.COPY_SERVER_NAME,
ContextMenu.COPY_SERVER_IP, ContextMenuItem.COPY_SERVER_IP,
ContextMenu.ADD_NOTE, ContextMenuItem.ADD_NOTE,
ContextMenu.SHOW_MODS, ContextMenuItem.SHOW_MODS,
ContextMenu.SHOW_DETAILS, ContextMenuItem.SHOW_DETAILS,
ContextMenu.REFRESH_PLAYERS, ContextMenuItem.REFRESH_PLAYERS,
) )
SAVED = ( SAVED = (
ContextMenu.CONNECT, ContextMenuItem.CONNECT,
ContextMenu.SET_FAV, ContextMenuItem.SET_FAV,
ContextMenu.REMOVE_SERVER, ContextMenuItem.REMOVE_SERVER,
ContextMenu.COPY_SERVER_NAME, ContextMenuItem.COPY_SERVER_NAME,
ContextMenu.COPY_SERVER_IP, ContextMenuItem.COPY_SERVER_IP,
ContextMenu.ADD_NOTE, ContextMenuItem.ADD_NOTE,
ContextMenu.SHOW_MODS, ContextMenuItem.SHOW_MODS,
ContextMenu.SHOW_DETAILS, ContextMenuItem.SHOW_DETAILS,
ContextMenu.REFRESH_PLAYERS, ContextMenuItem.REFRESH_PLAYERS,
) )
RECENT = ( RECENT = (
ContextMenu.CONNECT, ContextMenuItem.CONNECT,
ContextMenu.ADD_SERVER, ContextMenuItem.ADD_SERVER,
ContextMenu.SET_FAV, ContextMenuItem.SET_FAV,
ContextMenu.REMOVE_HISTORY, ContextMenuItem.REMOVE_HISTORY,
ContextMenu.COPY_SERVER_NAME, ContextMenuItem.COPY_SERVER_NAME,
ContextMenu.COPY_SERVER_IP, ContextMenuItem.COPY_SERVER_IP,
ContextMenu.ADD_NOTE, ContextMenuItem.ADD_NOTE,
ContextMenu.SHOW_MODS, ContextMenuItem.SHOW_MODS,
ContextMenu.SHOW_DETAILS, ContextMenuItem.SHOW_DETAILS,
ContextMenu.REFRESH_PLAYERS, ContextMenuItem.REFRESH_PLAYERS,
) )
class ModButton(EnumWithAttrs): class Preferences(Enum):
SELECT_ALL = { STEAM = ConfigKey("steam_api")
"label": strings.mod_panel.select_all, CLIENT = ConfigKey("client")
"tooltip": strings.mod_panel.select_all_tooltip, WINDOW = ConfigKey("fullscreen")
} DIST = ConfigKey("use_miles")
UNSELECT_ALL = { NAME = ConfigKey("name")
"label": strings.mod_panel.unselect_all, DEFAULT = ConfigKey("default_steam_path")
"tooltip": strings.mod_panel.unselect_all_tooltip, FAV_LBL = ConfigKey("fav_label")
} FAV_SRV = ConfigKey("fav_server")
HIGHLIGHT_STALE = { IP_LIST = ConfigKey("ip_list")
"label": strings.mod_panel.highlight_stale, START_TAB = ConfigKey("start_tab")
"tooltip": strings.mod_panel.highlight_stale_tooltip,
} @property
UNHIGHLIGHT_STALE = { def key(self) -> str:
"label": strings.mod_panel.unhighlight_stale, return self.value.key
"tooltip": strings.mod_panel.unhighlight_stale_tooltip,
}
UNSUB_SELECTED = {
"label": strings.mod_panel.unsub_selected,
"tooltip": strings.mod_panel.unsub_selected_tooltip,
}
SELECT_STALE = {
"label": strings.mod_panel.select_stale,
"tooltip": strings.mod_panel.select_stale_tooltip,
}
VALIDATE = {
"label": strings.mod_panel.validate,
"tooltip": strings.mod_panel.validate_tooltip,
}
class ButtonType(EnumWithAttrs): class NotebookPage(Enum):
SERVERS = { OFFLINE = NotebookMeta(crumbs.offline, True)
"label": strings.buttons.servers_label, CHANGELOG = NotebookMeta(crumbs.changelog, True)
"tooltip": strings.buttons.servers_tooltip, DEVELOPERS = NotebookMeta(crumbs.developers, False)
"opens": NotebookPage.SERVERS, HELP = NotebookMeta(crumbs._help, True)
} KEYS = NotebookMeta(crumbs.keys, True)
MODS = { LOG = NotebookMeta(crumbs.log, True)
"label": strings.buttons.mods_label, MODS = NotebookMeta(crumbs.mods, True)
"tooltip": strings.buttons.mods_tooltip, OPTIONS = NotebookMeta(crumbs.options, False)
"opens": NotebookPage.MODS, SERVERS = NotebookMeta(crumbs.servers, True)
} THANKS = NotebookMeta(crumbs.thanks, True)
OPTIONS = { CONNECTION = NotebookMeta(crumbs.connect, True)
"label": strings.buttons.options_label,
"tooltip": strings.buttons.options_tooltip, @property
"opens": NotebookPage.OPTIONS, def crumbs(self) -> str:
} return self.value.crumbs
HELP = {
"label": strings.buttons.help_label, @property
"tooltip": strings.buttons.help_tooltip, def has_statusbar(self) -> bool:
"opens": NotebookPage.HELP, return self.value.has_statusbar
}
EXIT = {
"label": strings.buttons.exit_label, class RowType(Enum):
"tooltip": strings.buttons.exit_tooltip, CHANGELOG = RowMeta(rows.changelog_label, rows.changelog_status)
"opens": None, SHOW_LOG = RowMeta(rows.log_label, rows.log_status)
} SEPARATOR = RowMeta(rows.separator_label, rows.separator_status)
DUMP_DIAGNOSTIC = RowMeta(rows.system_log_label, rows.system_log_status)
DUMP_DEBUG = RowMeta(rows.debug_log_label, rows.debug_log_status)
DOCS = RowMeta(rows.docs_label, rows.docs_status)
DOCS_FALLBACK = RowMeta(rows.docs_fallback_label, rows.docs_fallback_status)
BUGS = RowMeta(rows.bugs_label, rows.bugs_status)
FORUM = RowMeta(rows.forum_label, rows.forum_status)
SPONSOR = RowMeta(rows.sponsor_label, rows.sponsor_status)
THANKS = RowMeta(rows.thanks_label, rows.thanks_status)
@property
def label(self) -> str:
return self.value.label
@property
def tooltip(self) -> str:
return self.value.tooltip
class ModButton(Enum):
SELECT_ALL = ModButtonMeta(mod_panel.select_all, mod_panel.select_all_tooltip)
UNSELECT_ALL = ModButtonMeta(mod_panel.unselect_all, mod_panel.unselect_all_tooltip)
HIGHLIGHT_STALE = ModButtonMeta(
mod_panel.highlight_stale, mod_panel.highlight_stale_tooltip
)
UNHIGHLIGHT_STALE = ModButtonMeta(
mod_panel.unhighlight_stale, mod_panel.unhighlight_stale_tooltip
)
UNSUB_SELECTED = ModButtonMeta(
mod_panel.unsub_selected,
mod_panel.unsub_selected_tooltip,
)
SELECT_STALE = ModButtonMeta(
mod_panel.select_stale,
mod_panel.select_stale_tooltip,
)
VALIDATE = ModButtonMeta(
mod_panel.validate,
mod_panel.validate_tooltip,
)
@property
def label(self) -> str:
return self.value.label
@property
def tooltip(self) -> str:
return self.value.tooltip
class ButtonType(Enum):
SERVERS = ButtonTypeMeta(
side_buttons.servers_label,
side_buttons.servers_tooltip,
NotebookPage.SERVERS,
)
MODS = ButtonTypeMeta(
side_buttons.mods_label,
side_buttons.mods_tooltip,
NotebookPage.MODS,
)
OPTIONS = ButtonTypeMeta(
side_buttons.options_label,
side_buttons.options_tooltip,
NotebookPage.OPTIONS,
)
HELP = ButtonTypeMeta(
side_buttons.help_label,
side_buttons.help_tooltip,
NotebookPage.HELP,
)
EXIT = ButtonTypeMeta(
side_buttons.exit_label,
side_buttons.exit_tooltip,
None,
)
@property
def label(self) -> str:
return self.value.label
@property
def tooltip(self) -> str:
return self.value.tooltip
@property
def opens(self) -> NotebookPage | None:
return self.value.opens
HELP_MENU_ROWS = ( HELP_MENU_ROWS = (
RowType.CHANGELOG, RowType.CHANGELOG,
RowType.SHOW_LOG, RowType.SHOW_LOG,
RowType.DUMP_LOG, RowType.DUMP_DIAGNOSTIC,
RowType.DUMP_DEBUG,
RowType.SEPARATOR, RowType.SEPARATOR,
RowType.DOCS, RowType.DOCS,
RowType.DOCS_FALLBACK, RowType.DOCS_FALLBACK,
+20
View File
@@ -0,0 +1,20 @@
ICON_CALCULATOR = "accessories-calculator-symbolic"
ICON_CARET_DOWN = "go-down-symbolic"
ICON_CARET_UP = "go-up-symbolic"
ICON_CLIPBOARD = "edit-copy-symbolic"
ICON_CLOSE = "window-close-symbolic"
ICON_DAY = "weather-clear-symbolic"
ICON_EDIT_DELETE = "edit-delete-symbolic"
ICON_ERROR = "dialog-error-symbolic"
ICON_FOLDER = "folder-symbolic"
ICON_HELP_BUBBLE = "help-about-symbolic"
ICON_INPUT_KEYBOARD = "input-keyboard-symbolic"
ICON_LIST_ADD = "list-add-symbolic"
ICON_NIGHT = "weather-clear-night-symbolic"
ICON_REFRESH = "view-refresh-symbolic"
ICON_SEARCH = "system-search-symbolic"
ICON_STEAM = "steam-tray-symbolic"
ICON_VIEW_CONCEAL = "view-conceal-symbolic"
ICON_VIEW_REVEAL = "view-reveal-symbolic"
ICON_WARNING = "dialog-warning-symbolic"
ICON_WEB_BROWSER = "web-browser-symbolic"
+2 -2
View File
@@ -3,8 +3,8 @@ from typing import TYPE_CHECKING
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository.Gtk import ListStore # noqa E402 from gi.repository.Gtk import ListStore
from gi.repository import Gdk, GObject # noqa E402 from gi.repository import GObject
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.const.enum import NotebookPage, ServerTab from dzgui.const.enum import NotebookPage, ServerTab
+33 -23
View File
@@ -1,22 +1,20 @@
import gi
import logging import logging
import threading import threading
from pathlib import Path
from typing import Any, TYPE_CHECKING, Union from typing import Any, TYPE_CHECKING, Union
import dzgui.util._json as JSON # noqa from dzgui.config.userprefs import UserPrefs
from dzgui.const.constants import APP_NAME
from dzgui.const.enum import ( from dzgui.const.enum import (
ButtonType, ButtonType,
ContextMenu, ContextMenuItem,
FilterMode, FilterMode,
NotebookPage, NotebookPage,
Preferences, Preferences,
ServerTab, ServerTab,
) )
from dzgui.config.userprefs import UserPrefs
from dzgui.const.constants import APP_NAME
from dzgui.controllers.emitter import Emitter from dzgui.controllers.emitter import Emitter
from dzgui.managers.config import ConfigManager from dzgui.managers.config import ConfigManager
from dzgui.managers.connection import ConnectionManager from dzgui.managers.connection import ConnectionManager
@@ -26,13 +24,11 @@ from dzgui.model.servers import ServerModelManager
from dzgui.util.diag import write_diagnostic from dzgui.util.diag import write_diagnostic
from dzgui.util.format import format_exception, format_player_count from dzgui.util.format import format_exception, format_player_count
from dzgui.util.open_links import open_user_workshop, open_workshop_page from dzgui.util.open_links import open_user_workshop, open_workshop_page
from dzgui.views.dialogs.filepicker import FilePicker from dzgui.views.dialogs.filepicker import DebugLogPicker, DiagnosticLogPicker
from dzgui.views.dialogs.generic import ExceptionDialog from dzgui.views.dialogs.generic import ExceptionDialog
import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib, GObject # noqa E402 from gi.repository import Gtk, Gdk, GLib, GObject
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -77,7 +73,7 @@ class AppNavigation:
class Controller(GObject.GObject): class Controller(GObject.GObject):
def __init__(self) -> None: def __init__(self) -> None:
self.dist_cache: dict[str, "Haversine"] = {} self.dist_cache: dict[str, "Haversine" | None] = {}
self.mediator = AppNavigation() self.mediator = AppNavigation()
self.prefs: UserPrefs self.prefs: UserPrefs
@@ -196,7 +192,9 @@ class Controller(GObject.GObject):
def show_developers_page(self) -> None: def show_developers_page(self) -> None:
self.open_page(NotebookPage.DEVELOPERS) self.open_page(NotebookPage.DEVELOPERS)
def open_page(self, page: NotebookPage) -> None: def open_page(self, page: NotebookPage | None) -> None:
if page is None:
return
self.mediator.grid.notebook.set_page_by_enum(page) self.mediator.grid.notebook.set_page_by_enum(page)
def open_page_by_button(self, button: "ContextualButton") -> None: def open_page_by_button(self, button: "ContextualButton") -> None:
@@ -262,7 +260,7 @@ class Controller(GObject.GObject):
logger.critical(e) logger.critical(e)
return return
def menu_action(self, action: ContextMenu, tree: "ServerTreeView") -> None: def menu_action(self, action: ContextMenuItem, tree: "ServerTreeView") -> None:
context_man = ContextMenuManager(tree, self) context_man = ContextMenuManager(tree, self)
context_man.process(action) context_man.process(action)
@@ -274,7 +272,7 @@ class Controller(GObject.GObject):
except Exception as e: except Exception as e:
dialog = ExceptionDialog(self, str(e)) dialog = ExceptionDialog(self, str(e))
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def select_colorized(self) -> None: def select_colorized(self) -> None:
mod_man = self.mediator.modtreeview.get_mod_man() mod_man = self.mediator.modtreeview.get_mod_man()
@@ -300,15 +298,29 @@ class Controller(GObject.GObject):
return self.get_active_treeview().get_filter_man() return self.get_active_treeview().get_filter_man()
def dump_diagnostics(self) -> None: def dump_diagnostics(self) -> None:
picker = FilePicker(self.mediator.window) picker = DiagnosticLogPicker(self.mediator.window)
file = picker.pick_file() file = picker.pick_file()
if file is not None: if file is None:
return
try: try:
write_diagnostic(self.prefs.paths.config, file) write_diagnostic(self.prefs.paths.config, file)
except Exception as e: except Exception as e:
dialog = ExceptionDialog(self, str(e)) dialog = ExceptionDialog(self, str(e))
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def dump_log(self) -> None:
picker = DebugLogPicker(self.mediator.window)
file = picker.pick_file()
if file is None:
return
try:
log = self.prefs.paths.debug.read_text()
Path(file).write_text(log)
except Exception as e:
dialog = ExceptionDialog(self, str(e))
dialog.show_all()
dialog.run() # type: ignore[no-untyped-call]
def update_steam_api_key(self, text: str) -> None: def update_steam_api_key(self, text: str) -> None:
self.config_man.update_steam_api_key(text) self.config_man.update_steam_api_key(text)
@@ -355,22 +367,20 @@ class Controller(GObject.GObject):
filter_man.set_filter(filt, state) filter_man.set_filter(filt, state)
self.mediator.filters.set_filters(filters) self.mediator.filters.set_filters(filters)
def get_dist_cache(self) -> dict[str, "Haversine"]: def get_dist_cache(self) -> dict[str, Union["Haversine", None]]:
return self.dist_cache return self.dist_cache
def set_dist_cache(self, addr: str, haversine: "Haversine") -> None: def set_dist_cache(self, addr: str, haversine: Union["Haversine", None]) -> None:
self.dist_cache[addr] = haversine self.dist_cache[addr] = haversine
def get_map_store(self) -> Gtk.ListStore: def get_map_store(self) -> Gtk.ListStore:
filter_man = self.get_filter_man() filter_man = self.get_filter_man()
return filter_man.get_map_store() return filter_man.get_map_store()
def get_enabled_filters(self) -> dict: def get_enabled_filters(self) -> dict[str, bool]:
filter_man = self.get_filter_man() filter_man = self.get_filter_man()
return filter_man.get_filters() return filter_man.get_filters()
# FIXME: wipe maps store when changing tabs if model is none
def has_server_model(self) -> bool: def has_server_model(self) -> bool:
treeview = self.get_active_treeview() treeview = self.get_active_treeview()
proxy_man = treeview.get_proxy_man() proxy_man = treeview.get_proxy_man()
+10 -7
View File
@@ -53,6 +53,11 @@
- Expand/collapse changelog versions - Expand/collapse changelog versions
- Support local light/dark mode changes on system theme - Support local light/dark mode changes on system theme
- Server time calculator - Server time calculator
- Add "Unmodded" filter to servers
- List timestamp of last DayZ client update
- Validate mods via Mod page to pull in updates
- Support for Nasdara (Badlands) DLC
- Load offline mods
### Changed ### Changed
- Conform to PEP 440 versioning for beta versions - Conform to PEP 440 versioning for beta versions
@@ -74,6 +79,7 @@
- Enable LAN page Empty/Full filters on first run of app - Enable LAN page Empty/Full filters on first run of app
- Propagate subscribed mods to Steam client - Propagate subscribed mods to Steam client
- Make j/k keys in context menus follow same wraparound logic as down arrow/up arrow - Make j/k keys in context menus follow same wraparound logic as down arrow/up arrow
- Use SQLite DB for geolocation records
### Dropped ### Dropped
- Battlemetrics API support - Battlemetrics API support
@@ -92,16 +98,13 @@
- Moved dialogs out of threads - Moved dialogs out of threads
- History table not being in lock-step with state file - History table not being in lock-step with state file
- Current keyword filter not being applied when refreshing table - Current keyword filter not being applied when refreshing table
- Steam Flatpak cannot run DZGUI as a non-Steam game
### Unreleased - Collisions between native Steam and Steam Flatpak clients
- Load offline mods - Sticky toggle signal on radio buttons when reloading Options
- Local documentation
- Raw debug command in context menu
### Developer-facing ### Developer-facing
- Add pyproject.toml file
- Show deprecation warnings
- Options -> Dev page - Options -> Dev page
- Raw debug command in preconnect menu
## [6.0.5] 2026-05-17 ## [6.0.5] 2026-05-17
### Changed ### Changed
+2 -2
View File
@@ -6,7 +6,7 @@ from pathlib import Path
from typing import TextIO from typing import TextIO
from dzgui.const.constants import LOCK_FILE from dzgui.const.constants import LOCK_FILE
from dzgui.util.strings import cannot_acquire_lock from dzgui.strings import errors
from dzgui.views.dialogs.early_alert import EarlyAlertDialog from dzgui.views.dialogs.early_alert import EarlyAlertDialog
@@ -21,6 +21,6 @@ def lock_acquire() -> TextIO:
try: try:
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB) fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
except OSError: except OSError:
EarlyAlertDialog(cannot_acquire_lock) EarlyAlertDialog(errors.cannot_acquire_lock)
sys.exit(1) sys.exit(1)
return lock return lock
+30 -6
View File
@@ -1,15 +1,26 @@
import json import json
import logging
import re
import shutil import shutil
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
from dzgui.const.constants import LEGACY_CONFIG_PATH, LEGACY_COLS_PATH, LEGACY_IPS_PATH from dzgui.const.constants import (
APP_NAME,
LEGACY_CONFIG_PATH,
LEGACY_COLS_PATH,
LEGACY_IPS_PATH,
)
from dzgui.config.convert import rc2json from dzgui.config.convert import rc2json
from dzgui.config.xdg import get_real_home
from dzgui.util._json import read_json, write_json from dzgui.util._json import read_json, write_json
logger = logging.getLogger(APP_NAME)
def migrate_legacy_conf(config: Path) -> Any: def migrate_legacy_conf(config: Path) -> Any:
old_conf = Path.home() / LEGACY_CONFIG_PATH home = get_real_home()
old_conf = home / LEGACY_CONFIG_PATH
j = rc2json(old_conf) j = rc2json(old_conf)
return json.loads(j) return json.loads(j)
@@ -35,7 +46,8 @@ def convert_cols_file(res: Path) -> Any | None:
def migrate_cols_file(res: Path) -> None: def migrate_cols_file(res: Path) -> None:
# NOTE: filename "dzg.columns.json" is API 7 spec # NOTE: filename "dzg.columns.json" is API 7 spec
old_res = Path.home() / LEGACY_COLS_PATH home = get_real_home()
old_res = home / LEGACY_COLS_PATH
if old_res.is_file(): if old_res.is_file():
j = convert_cols_file(old_res) j = convert_cols_file(old_res)
if j is not None: if j is not None:
@@ -43,7 +55,7 @@ def migrate_cols_file(res: Path) -> None:
def copy_state_files(state_path: Path) -> None: def copy_state_files(state_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / ".local/state/dzgui" legacy = home / ".local/state/dzgui"
to_copy = [ to_copy = [
"dzg.res.json", "dzg.res.json",
@@ -54,7 +66,7 @@ def copy_state_files(state_path: Path) -> None:
".month", ".month",
] ]
if state_path == legacy: if state_path == legacy:
# TODO: log this logger.debug(f"Legacy state path '{legacy}' is identical to current")
return return
for file in legacy.iterdir(): for file in legacy.iterdir():
if file.name in to_copy: if file.name in to_copy:
@@ -62,7 +74,7 @@ def copy_state_files(state_path: Path) -> None:
def copy_ipdb(ips_path: Path) -> None: def copy_ipdb(ips_path: Path) -> None:
home = Path.home() home = get_real_home()
legacy = home / LEGACY_IPS_PATH legacy = home / LEGACY_IPS_PATH
if ips_path == legacy: if ips_path == legacy:
return return
@@ -70,3 +82,15 @@ def copy_ipdb(ips_path: Path) -> None:
return return
# TODO: ensure that month file is copied # TODO: ensure that month file is copied
shutil.copy(legacy, ips_path) shutil.copy(legacy, ips_path)
def clean_legacy_versions_file(versions: Path) -> None:
# NOTE: handling for #523
try:
pat = r"^(\d+),(\d+)$"
lines = versions.read_text().splitlines()
clean = [line for line in lines if re.match(pat, line)]
concat = "\n".join(clean)
versions.write_text(concat)
except Exception as e:
logger.warning(e)
+3 -3
View File
@@ -3,13 +3,13 @@ import shutil
import subprocess import subprocess
from dzgui.const.constants import APP_NAME, FLATPAK_APPID, FLATPAK_CMD, STEAM_CMD from dzgui.const.constants import APP_NAME, FLATPAK_APPID, FLATPAK_CMD, STEAM_CMD
from dzgui.init.proc import is_sandboxed from dzgui.init.proc import is_flatpak_sandbox
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def has_flatpak_client() -> bool: def has_flatpak_client() -> bool:
if is_sandboxed(): if is_flatpak_sandbox():
return True return True
try: try:
res = subprocess.run( res = subprocess.run(
@@ -23,7 +23,7 @@ def has_flatpak_client() -> bool:
else: else:
return False return False
except Exception as e: except Exception as e:
logger.critical(e) logger.debug(e)
return False return False
+25 -4
View File
@@ -27,19 +27,40 @@ def is_steam_running(cmd: str) -> bool:
raise TypeError("Not a valid Steam client selection") raise TypeError("Not a valid Steam client selection")
def is_sandboxed() -> bool: def is_snap_sandbox() -> bool:
return bool(os.environ.get("SNAP"))
def is_flatpak_sandbox() -> bool:
return bool(os.environ.get("FLATPAK_ID")) return bool(os.environ.get("FLATPAK_ID"))
def is_flatpak_steam_running() -> bool: def is_sandboxed() -> bool:
if is_sandboxed(): if is_snap_sandbox() or is_flatpak_sandbox():
return True return True
if has_cmd(FLATPAK_CMD) is False:
return False return False
def get_flatpak_output() -> list[str] | None:
try:
proc = subprocess.check_output( proc = subprocess.check_output(
[FLATPAK_CMD, "ps", "--columns=application"], text=True [FLATPAK_CMD, "ps", "--columns=application"], text=True
) )
lines = proc.splitlines() lines = proc.splitlines()
return lines
except Exception as e:
logger.debug(e)
return None
def is_flatpak_steam_running() -> bool:
if is_flatpak_sandbox():
return True
if has_cmd(FLATPAK_CMD) is False:
return False
lines = get_flatpak_output()
if lines is None:
return False
if FLATPAK_APPID in lines: if FLATPAK_APPID in lines:
return True return True
return False return False
+4 -1
View File
@@ -7,7 +7,7 @@ from dzgui.init.libgi import test_libgi_missing
from dzgui.init.prefix import get_version from dzgui.init.prefix import get_version
from dzgui.util.deck import is_steam_deck from dzgui.util.deck import is_steam_deck
from dzgui.util.map_count import set_map_count from dzgui.util.map_count import set_map_count
from dzgui.util.strings import flags from dzgui.strings import flags
from dzgui.views.dialogs.uninstall import UninstallWizard from dzgui.views.dialogs.uninstall import UninstallWizard
from dzgui.config.xdg import get_xdg_paths from dzgui.config.xdg import get_xdg_paths
@@ -43,6 +43,9 @@ def main() -> None:
# NOTE: only import ligbirepository modules after the above check # NOTE: only import ligbirepository modules after the above check
from dzgui.app_init import build_gui from dzgui.app_init import build_gui
from dzgui.init.flock import lock_acquire
lock = lock_acquire() # noqa
app = build_gui(version, args.debug) app = build_gui(version, args.debug)
if app is None: if app is None:
+12 -4
View File
@@ -13,7 +13,6 @@ from dzgui.api.probe import test_steam_api
from dzgui.const.enum import Preferences from dzgui.const.enum import Preferences
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.views.dialogs.generic import ExceptionDialog from dzgui.views.dialogs.generic import ExceptionDialog
from dzgui.strings import dialogs
from dzgui.util._json import read_json, write_json from dzgui.util._json import read_json, write_json
if TYPE_CHECKING: if TYPE_CHECKING:
@@ -46,6 +45,15 @@ class ConfigManager:
ips.append(record) ips.append(record)
self.update_config(Preferences.IP_LIST, ips) self.update_config(Preferences.IP_LIST, ips)
def remove_from_history_file(self, fqip: str) -> None:
try:
history = self.prefs.paths.history
ips = [line.rstrip() for line in history.read_text().splitlines()]
ips.remove(fqip)
history.write_text("\n".join(ips))
except Exception as e:
logger.critical(e)
def update_history_file(self, fqip: str) -> None: def update_history_file(self, fqip: str) -> None:
try: try:
with open(self.prefs.paths.history, "r") as f: with open(self.prefs.paths.history, "r") as f:
@@ -90,7 +98,7 @@ class ConfigManager:
logger.critical(e) logger.critical(e)
raise e raise e
@call_on_thread(dialogs.checking_api, show_dialog=False) @call_on_thread("", show_dialog=False)
def update_steam_api_key(self, text: str) -> None: def update_steam_api_key(self, text: str) -> None:
res = test_steam_api(text) res = test_steam_api(text)
if res is True: if res is True:
@@ -124,7 +132,7 @@ class ConfigManager:
return False return False
def enum_to_key(self, enum: Preferences) -> str: def enum_to_key(self, enum: Preferences) -> str:
return str(enum.dict["key"]) return str(enum.key)
def toggle_config(self, key: Preferences) -> None: def toggle_config(self, key: Preferences) -> None:
try: try:
@@ -162,7 +170,7 @@ class ConfigManager:
trace = traceback.format_exc() trace = traceback.format_exc()
dialog = ExceptionDialog(self.controller, trace) dialog = ExceptionDialog(self.controller, trace)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def save_res_and_quit(self, tv: "ServerTreeView", window: "OuterWindow") -> None: def save_res_and_quit(self, tv: "ServerTreeView", window: "OuterWindow") -> None:
columns = tv.get_columns() columns = tv.get_columns()
+17 -31
View File
@@ -42,24 +42,13 @@ from dzgui.api.steam import is_dayz_running
from dzgui.const.enum import NotebookPage, Preferences from dzgui.const.enum import NotebookPage, Preferences
from dzgui.init.proc import is_steam_running from dzgui.init.proc import is_steam_running
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.strings.dialogs import ( from dzgui.strings import dialogs, errors, kb
waiting_for_launch, from dzgui.strings.server_mods import checkmark, resync, invalid_mod
waiting_for_mods,
waiting_for_directories,
)
from dzgui.strings import kb
from dzgui.strings.server_mods import checkmark, resync
from dzgui.util.format import format_exception, format_mib from dzgui.util.format import format_exception, format_mib
from dzgui.util.strings import dialog, server_timeout
from dzgui.util.symlink import rebuild_symlinks from dzgui.util.symlink import rebuild_symlinks
from dzgui.views.dialogs.generic import ExceptionDialog from dzgui.views.dialogs.generic import ExceptionDialog
from dzgui.views.dialogs.servers import ServerDetailsDialog, ServerModDialog from dzgui.views.dialogs.servers import ServerDetailsDialog, ServerModDialog
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib # noqa E402
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.api.servers import A2SInfo, Record from dzgui.api.servers import A2SInfo, Record
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -108,12 +97,12 @@ class ConnectionManager:
self.remote_mod_ids: list[str] = [] self.remote_mod_ids: list[str] = []
self.missing_mods: list[tuple[str, str, int, int]] = [] self.missing_mods: list[tuple[str, str, int, int]] = []
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def connect_by_ip(self, addr: str) -> None: def connect_by_ip(self, addr: str) -> None:
res = Servers.query_by_ip(addr) res = Servers.query_by_ip(addr)
self._prepare_connection(res) self._prepare_connection(res)
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def connect_by_record(self, record: Servers.Record) -> None: def connect_by_record(self, record: Servers.Record) -> None:
res = Servers.query_by_record(record) res = Servers.query_by_record(record)
self._prepare_connection(res) self._prepare_connection(res)
@@ -158,7 +147,7 @@ class ConnectionManager:
self.missing_mods = missing_mods self.missing_mods = missing_mods
self.remote_mod_ids = [mod[1] for mod in remote_mods] self.remote_mod_ids = [mod[1] for mod in remote_mods]
except Exception as e: except Exception as e:
logger.warning(e) logger.critical(e)
self.thread_man.set_cleanup_func(failure_func, destroy_first=True) self.thread_man.set_cleanup_func(failure_func, destroy_first=True)
return return
@@ -197,9 +186,8 @@ class ConnectionManager:
is_last = self.is_last_server() is_last = self.is_last_server()
# TODO: strings
invalid_mods = [ invalid_mods = [
(mod[0], mod[1]) for mod in remote_mods if mod[2] == "Invalid mod" (mod[0], mod[1]) for mod in remote_mods if mod[2] == invalid_mod
] ]
prereqs = Prerequisites( prereqs = Prerequisites(
@@ -236,7 +224,7 @@ class ConnectionManager:
except Exception: except Exception:
return False return False
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def query_details(self, record: Servers.Record) -> None: def query_details(self, record: Servers.Record) -> None:
details = Servers.get_details(record) details = Servers.get_details(record)
if details is None: if details is None:
@@ -277,12 +265,11 @@ class ConnectionManager:
for mod in alpha_mods: for mod in alpha_mods:
# NOTE: if the mod is neither synched or out of date, it is a malformed mod # NOTE: if the mod is neither synched or out of date, it is a malformed mod
if mod[2] == "": if mod[2] == "":
# TODO: strings mod[2] = invalid_mod
mod[2] = "Invalid mod"
return alpha_mods, missing_mods return alpha_mods, missing_mods
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def query_modlist_and_present(self, record: Servers.Record) -> None: def query_modlist_and_present(self, record: Servers.Record) -> None:
try: try:
mods, missing_mods = self._query_modlist(record) mods, missing_mods = self._query_modlist(record)
@@ -298,22 +285,22 @@ class ConnectionManager:
def _present_modlist_dialog(self, mods: list[list[str]]) -> None: def _present_modlist_dialog(self, mods: list[list[str]]) -> None:
dialog = ServerModDialog(self.controller, mods) dialog = ServerModDialog(self.controller, mods)
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _present_details_dialog(self, details: Servers.Details) -> None: def _present_details_dialog(self, details: Servers.Details) -> None:
dialog = ServerDetailsDialog(self.controller, details) dialog = ServerDetailsDialog(self.controller, details)
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _workshop_timeout(self, msg: str) -> None: def _workshop_timeout(self, msg: str) -> None:
dialog = ExceptionDialog(self.controller, msg) dialog = ExceptionDialog(self.controller, msg)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _server_timeout(self) -> None: def _server_timeout(self) -> None:
dialog = ExceptionDialog(self.controller, server_timeout) dialog = ExceptionDialog(self.controller, errors.server_timeout)
dialog.set_details_buffer(kb.DZG_006) dialog.set_details_buffer(kb.DZG_006)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def get_debug_args(self) -> str: def get_debug_args(self) -> str:
addr = f"{self.record.ip}:{self.record.gameport}" addr = f"{self.record.ip}:{self.record.gameport}"
@@ -335,9 +322,8 @@ class ConnectionManager:
self.thread_man.set_cleanup_func(func) self.thread_man.set_cleanup_func(func)
return return
self.thread_man.update_dialog(waiting_for_launch) self.thread_man.update_dialog(dialogs.waiting_for_launch)
while True: while True:
# FIXME: cancel should not be visible here per setting above
if self.controller.is_cancel_pending(): if self.controller.is_cancel_pending():
# TODO: some facility to also close spawned steam process # TODO: some facility to also close spawned steam process
return return
@@ -369,7 +355,7 @@ class ConnectionManager:
self.thread_man.set_cleanup_func(func, destroy_first=True) self.thread_man.set_cleanup_func(func, destroy_first=True)
return return
self.thread_man.update_dialog(waiting_for_directories) self.thread_man.update_dialog(dialogs.waiting_for_directories)
for title, mod, stamp, size in self.missing_mods: for title, mod, stamp, size in self.missing_mods:
mod_path = self.workshop / mod mod_path = self.workshop / mod
@@ -395,7 +381,7 @@ class ConnectionManager:
# TODO: just push steam path directly # TODO: just push steam path directly
self._connect_steam(menu_only) self._connect_steam(menu_only)
@call_on_thread(waiting_for_mods, show_cancel=True) @call_on_thread(dialogs.waiting_for_mods, show_cancel=True)
def update_and_connect(self, menu_only: bool = False) -> None: def update_and_connect(self, menu_only: bool = False) -> None:
if len(self.missing_mods) > 0: if len(self.missing_mods) > 0:
self._update_mods(menu_only) self._update_mods(menu_only)
+19 -19
View File
@@ -2,7 +2,7 @@ import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.const.constants import APP_NAME from dzgui.const.constants import APP_NAME
from dzgui.const.enum import ContextMenu, Preferences from dzgui.const.enum import ContextMenuItem, Preferences
from dzgui.util.clip import copy_clipboard from dzgui.util.clip import copy_clipboard
from dzgui.util.open_links import open_workshop_page from dzgui.util.open_links import open_workshop_page
@@ -34,7 +34,7 @@ class ContextMenuManager:
self.controller = controller self.controller = controller
self.treeview = treeview self.treeview = treeview
def process(self, action: ContextMenu) -> None: def process(self, action: ContextMenuItem) -> None:
if isinstance(self.treeview, ServerTreeView): if isinstance(self.treeview, ServerTreeView):
record = self.treeview.get_record() record = self.treeview.get_record()
if record is None: if record is None:
@@ -42,14 +42,14 @@ class ContextMenuManager:
match action: match action:
# UNTHREADED # UNTHREADED
case ContextMenu.ADD_NOTE: case ContextMenuItem.ADD_NOTE:
dialog = NoteDialog(self.controller) dialog = NoteDialog(self.controller)
dialog.run() dialog.run() # type: ignore[no-untyped-call]
case ContextMenu.COPY_SERVER_IP: case ContextMenuItem.COPY_SERVER_IP:
self.copy_server_ip() self.copy_server_ip()
case ContextMenu.COPY_SERVER_NAME: case ContextMenuItem.COPY_SERVER_NAME:
self.copy_server_name() self.copy_server_name()
case ContextMenu.SET_FAV: case ContextMenuItem.SET_FAV:
name = self.treeview.get_value_at_index(0) name = self.treeview.get_value_at_index(0)
# NOTE: fully qualified ip # NOTE: fully qualified ip
fqip = self.treeview.get_record_string() fqip = self.treeview.get_record_string()
@@ -58,40 +58,40 @@ class ContextMenuManager:
self.controller.set_fav(name, fqip, simple) self.controller.set_fav(name, fqip, simple)
# THREADED # THREADED
case ContextMenu.ADD_SERVER: case ContextMenuItem.ADD_SERVER:
self.controller.add_by_record(record) self.controller.add_by_record(record)
case ContextMenu.CONNECT: case ContextMenuItem.CONNECT:
self.controller.connect_by_record(record) self.controller.connect_by_record(record)
case ContextMenu.REFRESH_PLAYERS: case ContextMenuItem.REFRESH_PLAYERS:
self.controller.refresh_players(record) self.controller.refresh_players(record)
case ContextMenu.REMOVE_HISTORY: case ContextMenuItem.REMOVE_HISTORY:
self.controller.remove_from_history(record) self.controller.remove_from_history(record)
case ContextMenu.REMOVE_SERVER: case ContextMenuItem.REMOVE_SERVER:
self.controller.remove_by_record(record) self.controller.remove_by_record(record)
case ContextMenu.SHOW_DETAILS: case ContextMenuItem.SHOW_DETAILS:
self.controller.get_details(record) self.controller.get_details(record)
case ContextMenu.SHOW_MODS: case ContextMenuItem.SHOW_MODS:
self.controller.get_modlist(record) self.controller.get_modlist(record)
if isinstance(self.treeview, (ModTreeView, OfflineModTreeView)): if isinstance(self.treeview, (ModTreeView, OfflineModTreeView)):
match action: match action:
case ContextMenu.OPEN_WORKSHOP: case ContextMenuItem.OPEN_WORKSHOP:
self.open_mod_page() self.open_mod_page()
case ContextMenu.UNSUB_MOD: case ContextMenuItem.UNSUB_MOD:
self.controller.unsub_mods(self.treeview) self.controller.unsub_mods(self.treeview)
case ContextMenu.VALIDATE_MOD: case ContextMenuItem.VALIDATE_MOD:
self.controller.validate_mods(self.treeview) self.controller.validate_mods(self.treeview)
case _: case _:
pass pass
if isinstance(self.treeview, LogTreeView): if isinstance(self.treeview, LogTreeView):
match action: match action:
case ContextMenu.COPY_LOG_CLIPBOARD: case ContextMenuItem.COPY_LOG_CLIPBOARD:
self.copy_log() self.copy_log()
if isinstance(self.treeview, ServerModTreeView): if isinstance(self.treeview, ServerModTreeView):
match action: match action:
case ContextMenu.OPEN_WORKSHOP: case ContextMenuItem.OPEN_WORKSHOP:
self.open_mod_page() self.open_mod_page()
def copy_server_ip(self) -> None: def copy_server_ip(self) -> None:
+37 -45
View File
@@ -1,8 +1,7 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.model.model_factory import ModelFactory from dzgui.model.model_factory import ModelFactory
from dzgui.util import strings from dzgui.strings import metadata
from dzgui.util.strings import all_maps
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.model.model_factory import FastInsertListStore from dzgui.model.model_factory import FastInsertListStore
@@ -13,45 +12,44 @@ class FilterManager:
self.map_store = ModelFactory().make_map_store() self.map_store = ModelFactory().make_map_store()
# TODO: namespace under own file: strings.filters # TODO: namespace under own file: metadata.filters
self.default_filters = { self.default_filters = {
strings.filter_1pp: True, metadata.filter_1pp: True,
strings.filter_day: True, metadata.filter_day: True,
strings.filter_empty: show_empty, metadata.filter_empty: show_empty,
strings.filter_3pp: True, metadata.filter_3pp: True,
strings.filter_night: True, metadata.filter_night: True,
strings.filter_full: show_full, metadata.filter_full: show_full,
strings.filter_official: True, metadata.filter_official: True,
strings.filter_modded: True, metadata.filter_modded: True,
strings.filter_lowpop: True, metadata.filter_lowpop: True,
strings.filter_unofficial: True, metadata.filter_unofficial: True,
strings.filter_unmodded: True, metadata.filter_unmodded: True,
strings.filter_duplicate: False, metadata.filter_duplicate: False,
strings.filter_nonascii: False, metadata.filter_nonascii: False,
} }
# TODO: strings # TODO: strings
self.tooltips = { self.tooltips = {
strings.filter_1pp: "First-person perspective", metadata.filter_1pp: "First-person perspective",
strings.filter_day: "In-game time between 0600 and 1759", metadata.filter_day: "In-game time between 0600 and 1759",
strings.filter_empty: "Servers with no players", metadata.filter_empty: "Servers with no players",
strings.filter_3pp: "Third-person perspective", metadata.filter_3pp: "Third-person perspective",
strings.filter_night: "In-game time between 1800 and 0559", metadata.filter_night: "In-game time between 1800 and 0559",
strings.filter_full: "Servers with no open slots", metadata.filter_full: "Servers with no open slots",
strings.filter_official: "Bohemia official servers", metadata.filter_official: "Bohemia official servers",
strings.filter_nonascii: "Server names using non-standard, complex glyphs", metadata.filter_nonascii: "Server names using non-standard, complex glyphs",
strings.filter_lowpop: "Current population is under 30% of total", metadata.filter_lowpop: "Current population is under 30% of total",
strings.filter_unofficial: "Third-party servers", metadata.filter_unofficial: "Third-party servers",
strings.filter_duplicate: "Duplicates of existing servers (usually spoofed)", metadata.filter_duplicate: "Duplicates of existing servers (usually spoofed)",
strings.filter_modded: "Servers with one or more mods", metadata.filter_modded: "Servers with one or more mods",
strings.filter_unmodded: "Servers with no mods", metadata.filter_unmodded: "Servers with no mods",
} }
self.active_keyword = "" self.active_keyword = ""
self.active_map = (0, all_maps) self.active_map = (0, metadata.all_maps)
self.prior_map = all_maps self.prior_map = metadata.all_maps
self.filters: list
self.enabled_filters = dict(self.default_filters) self.enabled_filters = dict(self.default_filters)
def get_tooltips(self) -> dict[str, str]: def get_tooltips(self) -> dict[str, str]:
@@ -75,11 +73,11 @@ class FilterManager:
def set_active_keyword(self, word: str) -> None: def set_active_keyword(self, word: str) -> None:
self.active_keyword = word self.active_keyword = word
def get_default_filters(self) -> dict: def get_default_filters(self) -> dict[str, bool]:
"""Deep copy of defaults""" """Deep copy of defaults"""
return dict(self.default_filters) return dict(self.default_filters)
def get_filters(self) -> dict: def get_filters(self) -> dict[str, bool]:
return self.enabled_filters return self.enabled_filters
def set_filter(self, label: str, state: bool) -> None: def set_filter(self, label: str, state: bool) -> None:
@@ -90,9 +88,9 @@ class FilterManager:
def reinit_map_store(self) -> None: def reinit_map_store(self) -> None:
model = ModelFactory().make_map_store() model = ModelFactory().make_map_store()
model.append([all_maps]) model.append([metadata.all_maps])
self.map_store = model self.map_store = model
self.active_map = (0, all_maps) self.active_map = (0, metadata.all_maps)
def append_map(self, row: list[str]) -> None: def append_map(self, row: list[str]) -> None:
self.map_store.append(row) self.map_store.append(row)
@@ -106,17 +104,11 @@ class FilterManager:
self.reinit_map_store() self.reinit_map_store()
maps.sort() maps.sort()
for m in maps: clean = [m for m in maps if m != metadata.all_maps]
# TODO: strings for m in clean:
if m == "All maps":
continue
self.append_map([m]) self.append_map([m])
# TODO: currently unused def get_all_filters(self) -> tuple[str, ...]:
def get_unique_maps(self) -> list[str]:
return [row[0] for row in self.map_store if row[0] != "All maps"]
def get_all_filters(self) -> tuple:
map_name = self.get_active_map_name() map_name = self.get_active_map_name()
enabled = self.get_filters() enabled = self.get_filters()
kw = self.get_active_keyword() kw = self.get_active_keyword()
+2 -2
View File
@@ -30,7 +30,7 @@ import dzgui.api.pefile as PeFile
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402 from gi.repository import Gtk
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -221,7 +221,7 @@ class ModManager:
total_size += mod[3] total_size += mod[3]
return total_mods, total_size return total_mods, total_size
def _on_stale_mods_found(self, stale_mods: list) -> None: def _on_stale_mods_found(self, stale_mods: list[int]) -> None:
"""Manipulates attached ListStore in the main event loop""" """Manipulates attached ListStore in the main event loop"""
model = self.treeview.get_model() model = self.treeview.get_model()
if model is None: if model is None:
+1 -1
View File
@@ -52,7 +52,7 @@ class OfflineManager:
is_valid = is_mission(folder) is_valid = is_mission(folder)
self.emitter.emit("custom_mission_loaded", str(folder), is_valid) self.emitter.emit("custom_mission_loaded", str(folder), is_valid)
def find_custom_mods(self, callback: Callable) -> None: def find_custom_mods(self, callback: Callable[[], None]) -> None:
folder = self.open_folderpicker(dialogs.custom_mod_dialog) folder = self.open_folderpicker(dialogs.custom_mod_dialog)
window = self.controller.get_window() window = self.controller.get_window()
window.set_sensitive(False) window.set_sensitive(False)
+4 -4
View File
@@ -15,15 +15,15 @@ if TYPE_CHECKING:
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib # noqa E402 from gi.repository import GLib
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def call_on_thread( def call_on_thread(
dialog_str: str, show_dialog: bool = True, show_cancel: bool = False dialog_str: str, show_dialog: bool = True, show_cancel: bool = False
) -> Callable: ) -> Callable[..., Any]:
def decorator(func: Callable) -> Callable: def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
@wraps(func) @wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> None: def wrapper(*args: Any, **kwargs: Any) -> None:
self = args[0] self = args[0]
@@ -42,7 +42,7 @@ def call_on_thread(
class StoredFunc: class StoredFunc:
def __init__(self, func: Callable, *args: Any, **kwargs: Any) -> None: def __init__(self, func: Callable[..., Any], *args: Any, **kwargs: Any) -> None:
sig = inspect.signature(func) sig = inspect.signature(func)
self.func = func self.func = func
self.bindings = sig.bind(*args, **kwargs) self.bindings = sig.bind(*args, **kwargs)
+3 -8
View File
@@ -15,11 +15,6 @@ from dzgui.strings import dialogs
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.views.dialogs.generic import ExceptionDialog, QuitDialog from dzgui.views.dialogs.generic import ExceptionDialog, QuitDialog
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib # noqa E402
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -55,14 +50,14 @@ class UpdateManager:
except Exception as e: except Exception as e:
func = StoredFunc(self._on_update_failure, str(e)) func = StoredFunc(self._on_update_failure, str(e))
self.thread_man.set_cleanup_func(func, destroy_first=True) self.thread_man.set_cleanup_func(func, destroy_first=True)
logger.warning(e) logger.critical(e)
def _on_update_success(self) -> None: def _on_update_success(self) -> None:
msg = dialogs.update_success msg = dialogs.update_success
dialog = QuitDialog(self.controller, msg) dialog = QuitDialog(self.controller, msg)
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _on_update_failure(self, msg: str) -> None: def _on_update_failure(self, msg: str) -> None:
dialog = ExceptionDialog(self.controller, msg) dialog = ExceptionDialog(self.controller, msg)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
+6 -6
View File
@@ -1,17 +1,17 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, Sequence, TYPE_CHECKING from typing import Any, Sequence, TYPE_CHECKING
from dzgui.const.constants import LOG_DELIMITER
from dzgui.const.enum import HELP_MENU_ROWS from dzgui.const.enum import HELP_MENU_ROWS
from dzgui.util.strings import delimiter
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository.Gtk import ListStore, TreeIter # noqa E402 from gi.repository.Gtk import ListStore, TreeIter
from gi.repository import GObject # noqa E402 from gi.repository import GObject
GTYPE_TO_PYTHON = { GTYPE_TO_PYTHON = {
GObject.type_from_name(GObject.type_name(ptype)): ptype GObject.type_from_name(GObject.type_name(ptype)): ptype # type: ignore[no-untyped-call]
for ptype in (int, float, str, bool, object) for ptype in (int, float, str, bool, object)
} }
@@ -131,7 +131,7 @@ class ModelFactory:
def new_model_from_logfile(self, path: "Path") -> FastInsertListStore: def new_model_from_logfile(self, path: "Path") -> FastInsertListStore:
store = self.make_log_store() store = self.make_log_store()
with open(path, "r") as f: with open(path, "r") as f:
lines = [line.split(delimiter) for line in f.read().splitlines()] lines = [line.split(LOG_DELIMITER) for line in f.read().splitlines()]
for record in lines: for record in lines:
store.append(record) store.append(record)
return store return store
@@ -147,7 +147,7 @@ class ModelFactory:
def make_help_store(self) -> FastInsertListStore: def make_help_store(self) -> FastInsertListStore:
store = self.new_model_from_class(MenuCols) store = self.new_model_from_class(MenuCols)
rows = [[row.dict["label"], row] for row in HELP_MENU_ROWS] rows = [[row.label, row] for row in HELP_MENU_ROWS]
store.extend(rows) store.extend(rows)
return store return store
+175 -84
View File
@@ -1,10 +1,12 @@
import re import re
from typing import Any, TYPE_CHECKING, Union from dataclasses import dataclass, fields
from operator import attrgetter
from typing import TYPE_CHECKING
from dzgui.const.enum import FilterMode from dzgui.const.enum import FilterMode
from dzgui.model.model_factory import ModelFactory from dzgui.model.model_factory import ModelFactory
from dzgui.util import strings from dzgui.strings import metadata
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.managers.filter import FilterManager from dzgui.managers.filter import FilterManager
@@ -16,6 +18,121 @@ DAY_REG = r"([0][6-9]|[1][0-7])"
NIGHT_REG = r"([0][0-5]|[1][8-9]|[2][0-3])" NIGHT_REG = r"([0][0-5]|[1][8-9]|[2][0-3])"
@dataclass(slots=True, frozen=True)
class ServerRow:
name: str
mapname: str
view: str
time: str
players: int
max_players: int
queue: int
ip: str
qport: int
ping: str
provider: str
modded: bool
# NOTE: construct getter once for fast lookup in lieu of field introspection
_to_tuple = attrgetter(
"name",
"mapname",
"view",
"time",
"players",
"max_players",
"queue",
"ip",
"qport",
"ping",
"provider",
"modded",
)
@classmethod
def marshal_rows(
cls, rows: list["ServerRow"]
) -> list[tuple[str, str, str, str, int, int, int, str, int, str, str, bool]]:
"""Marshals data before passing into FastInsertListStore's extend() method"""
getter = cls._to_tuple
return [getter(row) for row in rows]
@classmethod
def get_index(cls, field: str) -> int:
_fields = [f.name for f in fields(cls)]
return _fields.index(field)
class FiltrationManager:
def __init__(self) -> None:
self.filter_map = {
metadata.filter_3pp: self.filter_3pp,
metadata.filter_1pp: self.filter_1pp,
metadata.filter_official: self.filter_official,
metadata.filter_unofficial: self.filter_unofficial,
metadata.filter_empty: self.filter_empty,
metadata.filter_full: self.filter_full,
metadata.filter_duplicate: self.filter_duplicate,
metadata.filter_day: self.filter_day,
metadata.filter_night: self.filter_night,
metadata.filter_nonascii: self.filter_nonascii,
metadata.filter_lowpop: self.filter_lowpop,
metadata.filter_modded: self.filter_modded,
metadata.filter_unmodded: self.filter_unmodded,
}
def filter_3pp(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.view != metadata.filter_3pp]
def filter_1pp(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.view != metadata.filter_1pp]
def filter_official(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.provider != metadata.filter_official]
def filter_unofficial(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.provider != metadata.filter_unofficial]
def filter_empty(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.players != 0]
def filter_full(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.players != row.max_players]
def filter_duplicate(self, rows: list[ServerRow]) -> list[ServerRow]:
seen = set()
final = []
for row in rows:
if row.name not in seen:
seen.add(row.name)
final.append(row)
rows = final
return rows
def filter_day(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if not re.match(DAY_REG, row.time)]
def filter_night(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if not re.match(NIGHT_REG, row.time)]
def filter_nonascii(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.name.isascii()]
def filter_lowpop(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if (row.players / row.max_players * 100) > 30]
def filter_modded(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if not row.modded]
def filter_unmodded(self, rows: list[ServerRow]) -> list[ServerRow]:
return [row for row in rows if row.modded]
def filter(self, filter_type: str, rows: list[ServerRow]) -> list[ServerRow]:
func = self.filter_map[filter_type]
return func(rows)
class ProxyModelManager: class ProxyModelManager:
""" """
Manages access to cached FastInsertListStore resources and Manages access to cached FastInsertListStore resources and
@@ -30,20 +147,16 @@ class ProxyModelManager:
def __init__(self, filter_man: "FilterManager") -> None: def __init__(self, filter_man: "FilterManager") -> None:
self.filter_cache: dict[ self.filter_cache: dict[
tuple[str], tuple[str, ...],
list[tuple[str, str, str, str, int, int, int, str, int, int, str, bool]], list[ServerRow],
] = {} ] = {}
self.proxy_model: "FastInsertListStore" self.proxy_model: "FastInsertListStore"
self.filter_man = filter_man self.filter_man = filter_man
self.filtration_manager = FiltrationManager()
self.control_model: ( self.control_model: list[ServerRow] | None = None
list[tuple[str, str, str, str, int, int, int, str, int, int, str, bool]] self.filtered: list[ServerRow] = []
| None
) = None
self.filtered: list[
tuple[str, str, str, str, int, int, int, str, int, int, str, bool]
] = []
self.success = True self.success = True
def has_control_model(self) -> bool: def has_control_model(self) -> bool:
@@ -51,12 +164,7 @@ class ProxyModelManager:
return False return False
return True return True
def append_row(self, row: list) -> None: def append_row_to_control(self, row: ServerRow) -> None:
self.proxy_model.append(row)
def append_row_to_control(
self, row: tuple[str, str, str, str, int, int, int, str, int, int, str, bool]
) -> None:
if self.control_model is None: if self.control_model is None:
raise AttributeError("Trying to add rows to a non-existent model") raise AttributeError("Trying to add rows to a non-existent model")
self.control_model.append(row) self.control_model.append(row)
@@ -64,22 +172,24 @@ class ProxyModelManager:
def update_playercount(self, playercount: "NewPlayerCount") -> None: def update_playercount(self, playercount: "NewPlayerCount") -> None:
treeiter = playercount.treeiter treeiter = playercount.treeiter
self.proxy_model[treeiter][4] = playercount.players field = [f.name for f in fields(ServerRow)]
self.proxy_model[treeiter][6] = playercount.queue index_players = field.index("players")
index_queue = field.index("queue")
self.proxy_model[treeiter][index_players] = playercount.players
self.proxy_model[treeiter][index_queue] = playercount.queue
# TODO: use dataclass for record rows
def append_row_to_history( def append_row_to_history(
self, self,
history: tuple[str, str, str, str, int, int, int, str, int, int, str, bool], history: ServerRow,
) -> None: ) -> None:
addr = history[7] addr = history.ip
qport = history[8] qport = history.qport
if self.control_model is None: if self.control_model is None:
raise AttributeError("Trying to append row to empty model") raise AttributeError("Trying to append row to empty model")
found = False found = False
for i, row in enumerate(self.control_model): for i, row in enumerate(self.control_model):
if addr == row[7] and qport == row[8]: if addr == row.ip and qport == row.qport:
item = self.control_model.pop(i) item = self.control_model.pop(i)
self.control_model.append(item) self.control_model.append(item)
found = True found = True
@@ -88,6 +198,7 @@ class ProxyModelManager:
if found is False: if found is False:
self.control_model.append(history) self.control_model.append(history)
# NOTE: truncate history to 10 records max
if len(self.control_model) == 11: if len(self.control_model) == 11:
del self.control_model[0] del self.control_model[0]
@@ -99,7 +210,7 @@ class ProxyModelManager:
addr = f"{record.ip}:{record.gameport}" addr = f"{record.ip}:{record.gameport}"
qport = record.qport qport = record.qport
for row in self.control_model: for row in self.control_model:
if addr == row[7] and qport == row[8]: if addr == row.ip and qport == row.qport:
self.control_model.remove(row) self.control_model.remove(row)
break break
self.wipe_cache() self.wipe_cache()
@@ -108,19 +219,22 @@ class ProxyModelManager:
def clear_proxy_model(self) -> None: def clear_proxy_model(self) -> None:
self.proxy_model.clear() self.proxy_model.clear()
def get_proxy_model(self) -> Union["FastInsertListStore", None]: def get_proxy_model(self) -> "FastInsertListStore | None":
if hasattr(self, "proxy_model"): if hasattr(self, "proxy_model"):
return self.proxy_model return self.proxy_model
return None return None
def filter( def filter(
self, mode: FilterMode, skip_cache: bool = False self, mode: FilterMode, skip_cache: bool = False
) -> Union["FastInsertListStore", None]: ) -> "FastInsertListStore | None":
""" """
Native Gtk.TreeView.refilter() method was not performant enough Native Gtk.TreeView.refilter() method was not performant enough
when running in the main loop with 40k+ records when running in the main loop with 40k+ records
skip_cache: used when updating a record on Saved Servers/History and forcing a refilter skip_cache: used when updating a record on Saved Servers/History and forcing a refilter
NOTE: data must be marshalled from ServerRow format before constructing list stores
The "clone" is the proxy model (list of tuples) actually fed into Gtk.TreeView
""" """
# TODO: filter cache: return a dataclass object with clearly enumerated map, keyword, and filter values # TODO: filter cache: return a dataclass object with clearly enumerated map, keyword, and filter values
# instead of just a serial list of strings # instead of just a serial list of strings
@@ -129,8 +243,9 @@ class ProxyModelManager:
if skip_cache is False: if skip_cache is False:
if filters in self.filter_cache: if filters in self.filter_cache:
cached_rows = self.filter_cache[filters] cached_rows = self.filter_cache[filters]
marshalled_rows = ServerRow.marshal_rows(cached_rows)
clone = ModelFactory().make_server_store() clone = ModelFactory().make_server_store()
clone.extend(cached_rows) clone.extend(marshalled_rows)
self.set_proxy_model(clone) self.set_proxy_model(clone)
self.set_filtered(cached_rows) self.set_filtered(cached_rows)
return None return None
@@ -149,17 +264,18 @@ class ProxyModelManager:
clone = ModelFactory().make_server_store() clone = ModelFactory().make_server_store()
if len(rows) > 0: if len(rows) > 0:
rows = self.sort_rows(rows) rows = self.sort_rows(rows)
clone.extend(rows) marshalled_rows = ServerRow.marshal_rows(rows)
clone.extend(marshalled_rows)
self.set_cache(filters, rows) self.set_cache(filters, rows)
self.set_proxy_model(clone) self.set_proxy_model(clone)
return clone return clone
def sort_rows(self, rows: list) -> list: def sort_rows(self, rows: list[ServerRow]) -> list[ServerRow]:
rows.sort(key=lambda x: re.sub(r"[^A-Za-z0-9]+", "", x[0].lower())) rows.sort(key=lambda x: re.sub(r"[^A-Za-z0-9]+", "", x.name.lower()))
return rows return rows
def filter_initial(self, filters: tuple) -> list: def filter_initial(self, filters: tuple[str, ...]) -> list[ServerRow]:
""" """
Simply culls the control model of any disabled filters Simply culls the control model of any disabled filters
""" """
@@ -168,20 +284,20 @@ class ProxyModelManager:
self.set_filtered(self.filter_toggle_off(filters, f)) self.set_filtered(self.filter_toggle_off(filters, f))
return self.filtered return self.filtered
def filter_map(self, filters: tuple) -> list: def filter_map(self, filters: tuple[str, ...]) -> list[ServerRow]:
""" """
Multi-filtration for any context starts by narrowing by map Multi-filtration for any context starts by narrowing by map
""" """
rows = self.filtered rows = self.filtered
sel_map = self.filter_man.get_active_map_name() sel_map = self.filter_man.get_active_map_name()
if sel_map == strings.all_maps: if sel_map == metadata.all_maps:
return rows return rows
rows = [row for row in rows if row[1] == sel_map] rows = [row for row in rows if row.mapname == sel_map]
return rows return rows
def filter_keyword(self, filters: tuple) -> list: def filter_keyword(self, filters: tuple[str, ...]) -> list[ServerRow]:
keyword = self.filter_man.get_active_keyword() keyword = self.filter_man.get_active_keyword()
rows = self.filtered rows = self.filtered
@@ -191,63 +307,33 @@ class ProxyModelManager:
filtered = [ filtered = [
row row
for row in rows for row in rows
if keyword in row[0].lower() if keyword in row.name.lower()
or keyword in row[1].lower() or keyword in row.mapname.lower()
or keyword in row[7].lower() or keyword in row.ip.lower()
] ]
return filtered return filtered
def filter_toggle_off(self, filters: tuple, filter_type: str) -> list: def filter_toggle_off(
self, filters: tuple[str, ...], filter_type: str
) -> list[ServerRow]:
""" """
Sub-filtration of the current model Sub-filtration of the current model
""" """
pairs = { pairs = {
strings.filter_3pp: strings.filter_1pp, metadata.filter_3pp: metadata.filter_1pp,
strings.filter_day: strings.filter_night, metadata.filter_day: metadata.filter_night,
strings.filter_official: strings.filter_unofficial, metadata.filter_official: metadata.filter_unofficial,
} }
for k, v in pairs.items(): for k, v in pairs.items():
if k in filters and v in filters: if k in filters and v in filters:
self.set_filtered(None) self.set_filtered(None)
return [] return []
rows = self.filtered # TODO: pack filter type enum in filter checkbox, rather than stringwise comparison
match filter_type: rows = self.filtration_manager.filter(filter_type, self.filtered)
case strings.filter_3pp:
rows = [row for row in rows if row[2] != strings.filter_3pp]
case strings.filter_1pp:
rows = [row for row in rows if row[2] != strings.filter_1pp]
case strings.filter_official:
rows = [row for row in rows if row[10] != strings.filter_official]
case strings.filter_unofficial:
rows = [row for row in rows if row[10] != strings.filter_unofficial]
case strings.filter_empty:
rows = [row for row in rows if row[4] != 0]
case strings.filter_full:
rows = [row for row in rows if row[4] != row[5]]
case strings.filter_duplicate:
seen = set()
final = []
for row in rows:
if row[0] not in seen:
seen.add(row[0])
final.append(row)
rows = final
case strings.filter_day:
rows = [row for row in rows if not re.match(DAY_REG, row[3])]
case strings.filter_night:
rows = [row for row in rows if not re.match(NIGHT_REG, row[3])]
case strings.filter_nonascii:
rows = [row for row in rows if row[0].isascii()]
case strings.filter_lowpop:
rows = [row for row in rows if (row[4] / row[5] * 100) > 30]
case strings.filter_modded:
rows = [row for row in rows if not row[11]]
case strings.filter_unmodded:
rows = [row for row in rows if row[11]]
return rows return rows
def filter_toggle_on(self, filters: tuple[str]) -> list: def filter_toggle_on(self, filters: tuple[str, ...]) -> list[ServerRow]:
"""Effectively applies all filters""" """Effectively applies all filters"""
self.set_filtered(self.control_model) self.set_filtered(self.control_model)
self.set_filtered(self.filter_map(filters)) self.set_filtered(self.filter_map(filters))
@@ -258,31 +344,36 @@ class ProxyModelManager:
self.set_filtered(self.filter_toggle_off(filters, f)) self.set_filtered(self.filter_toggle_off(filters, f))
return self.filtered return self.filtered
def set_cache(self, filters: tuple[str], filtered_rows: list[tuple]) -> None: def set_cache(
self, filters: tuple[str, ...], filtered_rows: list[ServerRow]
) -> None:
self.filter_cache[filters] = filtered_rows self.filter_cache[filters] = filtered_rows
def set_filtered(self, rows: list | None) -> None: def set_filtered(self, rows: list[ServerRow] | None) -> None:
if rows is None: if rows is None:
self.filtered = [] self.filtered = []
else: else:
self.filtered = rows self.filtered = rows
def get_filtered(self) -> list: def get_filtered(self) -> list[ServerRow]:
return self.filtered return self.filtered
def set_proxy_model(self, model: "FastInsertListStore") -> None: def set_proxy_model(self, model: "FastInsertListStore") -> None:
""" """
FastInsertListStore representation of the raw model after filtration FastInsertListStore representation of the raw model after filtration
This attribute is saved from within a thread so that it later be retrieved
and safely packed into the TreeView in the main loop, cf. get_proxy_model()
""" """
self.proxy_model = model self.proxy_model = model
def set_control(self, rows: list) -> None: def set_control(self, rows: list[ServerRow]) -> None:
""" """
Raw data model prior to filtration Raw data model prior to filtration
""" """
self.control_model = rows self.control_model = rows
def get_control(self) -> list[Any]: def get_control(self) -> list[ServerRow]:
if self.control_model is None: if self.control_model is None:
raise AttributeError( raise AttributeError(
"Expected a populated control model, but it is Nonetype" "Expected a populated control model, but it is Nonetype"
@@ -293,7 +384,7 @@ class ProxyModelManager:
self.filtered = [] self.filtered = []
self.filter_cache = {} self.filter_cache = {}
def push(self, data: list[Any]) -> None: def push(self, data: list[ServerRow]) -> None:
self.wipe_cache() self.wipe_cache()
self.set_control(data) self.set_control(data)
cur_keyword = self.filter_man.get_active_keyword() cur_keyword = self.filter_man.get_active_keyword()
+28 -30
View File
@@ -14,19 +14,18 @@ from dzgui.const.constants import (
) )
from dzgui.const.enum import FilterMode, Preferences, ServerTab from dzgui.const.enum import FilterMode, Preferences, ServerTab
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.strings import dialogs, kb from dzgui.strings import dialogs, errors, kb
from dzgui.util.strings import server_timeout, dialog
from dzgui.views.dialogs.generic import ExceptionDialog from dzgui.views.dialogs.generic import ExceptionDialog
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib # noqa E402 from gi.repository import Gtk, GLib
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.api.servers import A2SInfo, Record from dzgui.api.servers import A2SInfo, Record
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
from dzgui.model.proxy_model import ProxyModelManager from dzgui.model.proxy_model import ProxyModelManager, ServerRow
from dzgui.views.trees.tree_servers import ServerTreeView from dzgui.views.trees.tree_servers import ServerTreeView
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -34,7 +33,7 @@ LAN_TIMEOUT = 0.5
API_TIMEOUT = 3 API_TIMEOUT = 3
@dataclass @dataclass(slots=True, frozen=True)
class NewPlayerCount: class NewPlayerCount:
treeiter: Gtk.TreeIter treeiter: Gtk.TreeIter
players: int players: int
@@ -83,7 +82,7 @@ class ServerModelManager:
self.preserve_on_fail = True self.preserve_on_fail = True
self.load() self.load()
@call_on_thread(dialog.fetching) @call_on_thread(dialogs.fetching_server)
def _dump_api(self) -> None: def _dump_api(self) -> None:
# TODO: pass api key a priori in .load() call? # TODO: pass api key a priori in .load() call?
failure_func = StoredFunc(self._cleanup_on_failure) failure_func = StoredFunc(self._cleanup_on_failure)
@@ -126,7 +125,7 @@ class ServerModelManager:
parsed = Servers.parse_json(servers) parsed = Servers.parse_json(servers)
self._push_data(parsed) self._push_data(parsed)
@call_on_thread(dialog.scanning, show_cancel=True) @call_on_thread(dialogs.scanning_lan, show_cancel=True)
def dump_lan(self, port: int, early_abort: bool) -> None: def dump_lan(self, port: int, early_abort: bool) -> None:
self.first_iteration = True self.first_iteration = True
@@ -159,7 +158,7 @@ class ServerModelManager:
parsed = Servers.parse_json(servers) parsed = Servers.parse_json(servers)
self._push_data(parsed) self._push_data(parsed)
@call_on_thread(dialog.fetching) @call_on_thread(dialogs.fetching_server)
def _dump_ips(self, ips: list[str]) -> None: def _dump_ips(self, ips: list[str]) -> None:
job = Servers.query_direct job = Servers.query_direct
servers = [] servers = []
@@ -199,20 +198,20 @@ class ServerModelManager:
parsed = Servers.parse_json(servers) parsed = Servers.parse_json(servers)
self._push_data(parsed) self._push_data(parsed)
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def add_by_ip(self, addr: str) -> None: def add_by_ip(self, addr: str) -> None:
self.preserve_on_fail = True self.preserve_on_fail = True
try: try:
res = Servers.query_by_ip(addr) res = Servers.query_by_ip(addr)
self._parse_single_record(res) self._parse_single_record(res)
except Exception as e: except Exception as e:
logger.warning(e) logger.critical(e)
self.thread_man.set_cleanup_func( self.thread_man.set_cleanup_func(
StoredFunc(self._cleanup_on_failure), destroy_first=True StoredFunc(self._cleanup_on_failure), destroy_first=True
) )
return return
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def add_by_record(self, record: Servers.Record) -> None: def add_by_record(self, record: Servers.Record) -> None:
self.preserve_on_fail = True self.preserve_on_fail = True
# NOTE: rationale: a raw Record as shown in server browser may resolve to a different IP # NOTE: rationale: a raw Record as shown in server browser may resolve to a different IP
@@ -220,20 +219,20 @@ class ServerModelManager:
res = Servers.query_by_record(record) res = Servers.query_by_record(record)
self._parse_single_record(res) self._parse_single_record(res)
except Exception as e: except Exception as e:
logger.warning(e) logger.critical(e)
self.thread_man.set_cleanup_func( self.thread_man.set_cleanup_func(
StoredFunc(self._cleanup_on_failure), destroy_first=True StoredFunc(self._cleanup_on_failure), destroy_first=True
) )
return return
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def remove_by_record(self, record: Servers.Record) -> None: def remove_by_record(self, record: Servers.Record) -> None:
self.preserve_on_fail = True self.preserve_on_fail = True
try: try:
res = Servers.query_by_record(record) res = Servers.query_by_record(record)
self._parse_single_record(res, delete=True) self._parse_single_record(res, delete=True)
except Exception as e: except Exception as e:
logger.warning(e) logger.critical(e)
self.thread_man.set_cleanup_func( self.thread_man.set_cleanup_func(
StoredFunc(self._cleanup_on_failure), destroy_first=True StoredFunc(self._cleanup_on_failure), destroy_first=True
) )
@@ -241,10 +240,7 @@ class ServerModelManager:
def update_history( def update_history(
self, self,
rows: ( rows: list["ServerRow"] | None = None,
list[tuple[str, str, str, str, int, int, int, str, int, int, str, bool]]
| None
) = None,
) -> None: ) -> None:
proxy_man = self._get_proxy_man() proxy_man = self._get_proxy_man()
if rows is not None: if rows is not None:
@@ -267,7 +263,6 @@ class ServerModelManager:
self.first_iteration = False self.first_iteration = False
self.emitter.emit("load_maps", store) self.emitter.emit("load_maps", store)
# TODO: dataclass for record rows; check for other dict annotations
def add_to_history(self, data: tuple[dict[str, Any], "Record"]) -> None: def add_to_history(self, data: tuple[dict[str, Any], "Record"]) -> None:
row, record = data row, record = data
proxy_man = self._get_proxy_man() proxy_man = self._get_proxy_man()
@@ -285,9 +280,13 @@ class ServerModelManager:
def remove_from_history(self, record: Servers.Record) -> None: def remove_from_history(self, record: Servers.Record) -> None:
proxy_man = self._get_proxy_man() proxy_man = self._get_proxy_man()
proxy_man.remove_row_from_control(record) proxy_man.remove_row_from_control(record)
fqip = Servers.record_to_fqip(record)
config_man = self.controller.get_config_man()
config_man.remove_from_history_file(fqip)
self.update_history() self.update_history()
@call_on_thread(dialog.querying) @call_on_thread(dialogs.querying)
def update_playercount( def update_playercount(
self, treeiter: Gtk.TreeIter, record: Servers.Record self, treeiter: Gtk.TreeIter, record: Servers.Record
) -> None: ) -> None:
@@ -341,8 +340,8 @@ class ServerModelManager:
return return
config_man.add_saved_server(fqip) config_man.add_saved_server(fqip)
# FIXME: this is valid if saved servers tab is already open, # TODO: this is valid if saved servers tab is already open,
# but not if app was just booted; causes single row to appear prematurely # but not if tab is unloaded; causes single row to appear prematurely
if proxy_man.has_control_model() is False: if proxy_man.has_control_model() is False:
proxy_man.push(records) proxy_man.push(records)
else: else:
@@ -432,7 +431,7 @@ class ServerModelManager:
if show_dialog: if show_dialog:
dialog = ExceptionDialog(self.controller, dialogs.load_error_lan) dialog = ExceptionDialog(self.controller, dialogs.load_error_lan)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _cleanup_on_failure(self, show_dialog: bool = True) -> None: def _cleanup_on_failure(self, show_dialog: bool = True) -> None:
# TODO: disable map, keyword, and filter widgets if model is None # TODO: disable map, keyword, and filter widgets if model is None
@@ -448,18 +447,18 @@ class ServerModelManager:
# TODO: distinguish signals, e.g. "servers_failed_to_load", "servers_loaded_empty" # TODO: distinguish signals, e.g. "servers_failed_to_load", "servers_loaded_empty"
# customize statusbar and dialog accordingly # customize statusbar and dialog accordingly
if show_dialog: if show_dialog:
dialog = ExceptionDialog(self.controller, server_timeout) dialog = ExceptionDialog(self.controller, errors.server_timeout)
dialog.set_details_buffer(kb.DZG_006) dialog.set_details_buffer(kb.DZG_006)
dialog.show_all() dialog.show_all()
dialog.run() dialog.run() # type: ignore[no-untyped-call]
def _push_data(self, data: list[Any]) -> None: def _push_data(self, data: list["ServerRow"]) -> None:
self._get_proxy_man().push(data) self._get_proxy_man().push(data)
self._sort_unique_maps(data) self._sort_unique_maps(data)
self.thread_man.set_cleanup_func(StoredFunc(self._cleanup_on_success)) self.thread_man.set_cleanup_func(StoredFunc(self._cleanup_on_success))
def _sort_unique_maps(self, data: list) -> None: def _sort_unique_maps(self, data: list[Any]) -> None:
u_maps = set([row[1] for row in data]) u_maps = set([row.mapname for row in data])
self._set_new_maps(sorted(u_maps)) self._set_new_maps(sorted(u_maps))
def _set_new_maps(self, maps: list[str]) -> None: def _set_new_maps(self, maps: list[str]) -> None:
@@ -471,9 +470,8 @@ class ServerModelManager:
def _get_proxy_man(self) -> "ProxyModelManager": def _get_proxy_man(self) -> "ProxyModelManager":
return self.proxy_man return self.proxy_man
@call_on_thread(dialog.filtering) @call_on_thread(dialogs.filtering)
def refilter(self, mode: FilterMode) -> None: def refilter(self, mode: FilterMode) -> None:
# FIXME: causes two wait dialogs when map selection change signal emits after loading servers
self.first_iteration = False self.first_iteration = False
proxy_man = self._get_proxy_man() proxy_man = self._get_proxy_man()
proxy_man.filter(mode) proxy_man.filter(mode)
+14
View File
@@ -1,2 +1,16 @@
clipboard_button = "Copy to clipboard"
clipboard_ip_button = "Copy IP to clipboard"
copy_button = "Copy"
dock_button_collapse = "Collapse the connection panel"
dock_button_expand = "Expand the connection panel"
keys_button = "Keys"
keys_button_tooltip = "Toggles the keybindings dialog"
refresh_button = "Refresh"
refresh_tooltip = "Refresh server data"
unset_button_label = "Unset"
unset_button_tooltip = "Unset this server as favorite"
update_button = "Updates available"
version_notifier = "Copied!"
version_tooltip = "Click to copy to clipboard"
workshop = "Steam Workshop" workshop = "Steam Workshop"
workshop_tooltip = "Open your Workshop subscriptions" workshop_tooltip = "Open your Workshop subscriptions"
+1
View File
@@ -1,2 +1,3 @@
collapse_all = "Collapse all" collapse_all = "Collapse all"
expand_all = "Expand all" expand_all = "Expand all"
missing_changelog = "Error: failed to read changelog"
+16
View File
@@ -0,0 +1,16 @@
add = "Add to Saved Servers"
add_note = "Add note"
connect = "Connect"
copy_ip = "Copy IP to clipboard"
copy_log = "Copy record(s) to clipboard"
copy_name = "Copy name to clipboard"
edit_note = "Edit note"
open_workshop = "Open in Steam Workshop"
refresh_players = "Refresh player count"
remove = "Remove from Saved Servers"
remove_history = "Remove from history"
set_fav = "Set as favorite"
show_details = "Show server details"
show_mods = "Show server-side mods"
unsub_mod = "Unsubscribe mod"
validate_mod = "Validate mod"
+15
View File
@@ -0,0 +1,15 @@
_help = "Help"
changelog = "Help > Changelog"
connect = "Connect"
default = "Servers > "
developers = "Options > Developers"
keys = "Keybindings"
log = "Help > Debug log"
main_menu = "Main menu"
mods = "Mods"
offline = "Mods > Play offline"
options = "Options"
servers = "Servers > Server browser"
thanks = "Help > Special thanks"
something_wrong = "Something went wrong. See the detailed error below."
workshop = "Enter/double click a row to open in Steam Workshop."
+4
View File
@@ -0,0 +1,4 @@
page_header = "Developers"
paths_label = "Resolved XDG paths"
prefs_label = "Boot preferences"
columns = ["Key", "Value"]
+33 -27
View File
@@ -1,31 +1,37 @@
waiting_for_launch = "Waiting for DayZ to launch" caught_cancel_signal = "Caught cancel signal, cleaning up"
waiting_for_mods = "Queueing up mods (step 1/2)" confirm = "Confirmation"
waiting_for_directories = "Steam is staging mods (step 2/2)" custom_mod_dialog = "Set a custom mod location"
fetching_update = "Fetching update"
failed_to_update = "Failed to update DZGUI executable"
update_success = "Updated successfully. Please exit and relaunch."
load_error_lan = "Failed to find any servers on your network.\nCheck the server query port or your firewall settings."
fetching_mods = "Fetching mod metadata"
deleting_mods = "Unsubscribing mods"
validating_mods = "Validating mods"
scanning_mods = "Scanning mods"
parsing_mods = "Parsing mods"
checking_api = "Checking API key"
running = "Running"
failed = "FAILED"
ok = "OK"
mission_dialog = "Set a mission folder location"
custom_mod_dialog = "Set location to a custom mods folder"
debug_heading = "Debug" debug_heading = "Debug"
debug_secondary = "Launch arguments" debug_secondary = "Launch arguments"
default_header = "DZGUI - Dialog"
toggle_calc = "Toggle calculator" deleting_mods = "Unsubscribing mods"
error = "Error"
exit_app = "Exit"
failed = "FAILED"
failed_to_update = "Failed to update DZGUI executable"
fetching_server = "Fetching server metadata"
fetching_mods = "Fetching mod metadata"
fetching_update = "Fetching update"
filtering = "Filtering servers"
load_error_lan = "Failed to find any servers on your network.\nCheck the server query port or your firewall settings."
main_menu = "Return to main menu"
mission_dialog = "Set a mission folder location"
modlist = "Modlist"
notice = "Notice"
ok = "OK"
parsing_mods = "Parsing mods"
querying = "Querying server"
restart_required = "App relaunch required"
running = "Running"
scanning_lan = "Scanning LAN ports"
scanning_mods = "Scanning mods"
server_details = "Server details" server_details = "Server details"
server_message = "Server message" server_message = "Server message"
something_wrong = "Something went wrong. See the detailed error below."
toggle_calc = "Toggle calculator"
update_success = "Updated successfully. Please exit and relaunch."
validating_mods = "Validating mods"
wait = "Please wait"
waiting_for_directories = "Steam is staging mods (step 2/2)"
waiting_for_launch = "Waiting for DayZ to launch"
waiting_for_mods = "Queueing up mods (step 1/2)"
+8 -1
View File
@@ -1,7 +1,14 @@
api_validation_error = ( api_validation_error = (
"API key validation error. Key was typed incorrectly or is defunct." "API key validation error. Key was typed incorrectly or is defunct."
) )
api_popover = "API key validation failed." api_popover = "API key validation failed."
cannot_acquire_lock = "DZGUI is already open."
config_not_found = "DZGUI configuration file not found. Please exit and restart."
dayz_not_found = "Could not find a valid DayZ installation." dayz_not_found = "Could not find a valid DayZ installation."
no_mods = "No local mods found."
no_servers = "No server metadata to list."
requires_steam = (
"Your chosen client (Steam/Flatpak Steam) must be installed on the system."
)
server_timeout = "Timed out when querying server(s). Check IP or try again later."
workshop_endpoint_error = "Steam Workshop service unavailable, try again later." workshop_endpoint_error = "Steam Workshop service unavailable, try again later."
+2
View File
@@ -0,0 +1,2 @@
debug_picker_title = "Save the debug log to a file"
diagnostic_picker_title = "Save system diagnostics to a file"
+4
View File
@@ -0,0 +1,4 @@
all_maps = "All maps"
filters_heading = "Filters"
keyword_placeholder = "Filter by keyword"
map_placeholder = "Filter by map"
+5
View File
@@ -0,0 +1,5 @@
description = "DayZ server browser and mod manager"
version = "print version information"
uninstall = "clean up state/config files"
debug = "enable developer debugging features"
map_count = "check and update system map count value"
+1
View File
@@ -1 +1,2 @@
tab_changed_label = "*"
selectable_tree = "Ctrl-click to select multiple; Shift-click to select a range." selectable_tree = "Ctrl-click to select multiple; Shift-click to select a range."
+41
View File
@@ -0,0 +1,41 @@
navigation = {
"Enter/space/double click": "select row item",
"Down arrow": "move down a row/scroll down",
"Up arrow": "move up a row/scroll up",
"Right arrow": "jump to sidebar from main area",
"Left arrow": "jump to main area from sidebar",
"Tab": "cycle forward through elements",
"Shift-tab": "cycle backward through elements",
"ESC/Enter": "close dialogs",
"?": "show/hide this dialog",
"Ctrl-q": "Quit",
}
servers = {
"Enter/space/double-click": "connect to server",
"Right-click/Ctrl-l": "additional context menus",
"Ctrl-r": "refresh players",
"Ctrl-f": "jump to keyword search field",
"Ctrl-m": "jump to maps field",
"Ctrl-d": "select default LAN port",
"Ctrl-n": "select custom LAN port",
"Ctrl-u": "connect to server from preconnect dialog",
"Ctrl-i": "jump to IP insert field",
"n": "navigate to next tab",
"p": "navigate to previous tab",
"ESC": "return to table",
"1-9": "toggle filter 1-9 on/off",
"0": "toggle filter 10",
"Minus": "toggle filter 11",
"Backslash": "toggle filter 12",
"Apostrophe": "toggle filter 13",
}
vim = {
"j": "Move down a row/scroll up",
"k": "Move up a row/scroll down",
"h": "Jump to main area from sidebar",
"l": "Jump to sidebar from main area",
"g": "Jump to first row/top of page",
"G": "Jump to last row/bottom of page",
}
key_contexts = ["Servers", "Navigation", "Vim-style keys"]
key_header = "Keybindings"
+19
View File
@@ -0,0 +1,19 @@
# TODO: column order is deterministic, these should not be stored here
browser_cols = [
"Name",
"Map",
"View",
"Gametime",
"Players",
"Max",
"Queue",
"IP",
"Qport",
"Ping",
]
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
mod_cols = ["Mod", "Symlink", "ID", "Size (MiB)", "Color"]
servers_browser = "Server Browser"
servers_lan = "LAN"
servers_recent = "Recent"
servers_saved = "Saved Servers"
+28
View File
@@ -0,0 +1,28 @@
all_maps = "All maps"
disabled = "Disabled"
dlc_badlands = "Badlands"
dlc_frostline = "Frostline"
dlc_none = "None"
enabled = "Enabled"
filter_1pp = "1PP"
filter_3pp = "3PP"
filter_day = "Day"
filter_duplicate = "Duplicate"
filter_empty = "Empty"
filter_full = "Full"
filter_lowpop = "Low pop"
filter_modded = "Modded"
filter_night = "Night"
filter_nonascii = "Non-ASCII"
filter_official = "Official"
filter_unmodded = "Unmodded"
filter_unofficial = "Unofficial"
filters_heading = "Filters"
keyword_placeholder = "Filter by keyword"
linux = "Linux"
map_placeholder = "Filter by map"
none_provided = "None provided"
null = "-"
unknown = "Unknown"
unspecified = "not specified"
windows = "Windows"
+20
View File
@@ -0,0 +1,20 @@
bulk_select = "Bulk selects all currently highlighted mods"
clear_highlights = "Clears highlights and reverts the table to a default state"
header = "Mod actions"
highlight_stale = "Highlight stale"
highlight_stale_tooltip = (
"Shows locally-installed mods which are not \n"
"used by any server in your Saved Servers"
)
select_all = "Select all"
select_all_tooltip = "Bulk selects all mods"
select_stale = "Select stale"
select_stale_tooltip = "Only selects highlighted stale mods"
unhighlight_stale = "Unhighlight stale"
unhighlight_stale_tooltip = "Clears highlight from stale mods"
unselect_all = "Unselect all"
unselect_all_tooltip = "Bulk unselects all mods"
unsub_selected = "Unsubscribe selected"
unsub_selected_tooltip = "Unsubscribes from selected mods"
validate = "Validate selected"
validate_tooltip = "Validates selected mods and updates them if necessary"
+5
View File
@@ -0,0 +1,5 @@
dialog_title = "Add a short note/reminder"
dialog_subtitle = "Limit 30 chars"
delete_button = "Delete note"
ok_button = "Update note"
current_note = "Current note: '{0}'"
+29 -21
View File
@@ -1,26 +1,34 @@
developers = "Developers" always_fs = "Always fullscreen"
start_tab = "Start tab"
workshop_label = "Subscribed mods"
steam_combo = "Steam"
flatpak_combo = "Flatpak"
flatpak_container_combo = "Flatpak (container)"
steam_placeholder = "Enter your Steam API key"
name_placeholder = "Identifies you to other players"
server_combo = "Server browser"
saved_combo = "Saved servers"
recent_combo = "Recent"
lan_combo = "LAN"
fullscreen_eventbox = "This option is not available on Steam Deck."
save_button = "Save"
api_failed = "API validation failed" api_failed = "API validation failed"
api_key = "API Key"
flatpak_label = "Flatpak client" api_placeholder = "Enter API key"
flatpak_standard = "Standard" api_validate = "Validate"
developers = "Developers"
distance = "Distance display"
flatpak_combo = "Flatpak"
flatpak_container = "Containerized (flatpak-spawn --host)" flatpak_container = "Containerized (flatpak-spawn --host)"
flatpak_container_combo = "Flatpak (container)"
flatpak_info = ( flatpak_info = (
"Containerized mode is used on certain distributions. May have side effects." "Containerized mode is used on certain distributions. May have side effects."
) )
flatpak_label = "Flatpak client"
flatpak_standard = "Standard"
fullscreen_eventbox = "This option is not available on Steam Deck."
header = "Options"
km = "km (kilometers)"
lan_combo = "LAN"
last_used = "Last used dimensions"
mi = "mi (miles)"
name = "Player name"
name_placeholder = "Identifies you to other players"
prefs = "Preferences"
recent_combo = "Recent"
save_button = "Save"
saved_combo = "Saved servers"
server_combo = "Server browser"
start_tab = "Start tab"
steam_combo = "Steam"
steam_placeholder = "Enter your Steam API key"
steam_web = "Steam API page"
version = "Version"
window_size = "Window size at boot"
+32
View File
@@ -0,0 +1,32 @@
changelog_label = "View changelog"
changelog_status = "Opens the DZGUI changelog"
log_label = "Show debug log"
log_status = "Read the DZGUI log generated since startup"
separator_label = "SEPARATOR"
separator_status = ""
system_log_label = "Output system info to a file"
system_log_status = "Dump diagnostic data for troubleshooting"
debug_log_label = "Output debug log to a file"
debug_log_status = "Dump a summary of errors/events since DZGUI started"
docs_label = "Documentation/help files (GitHub) ⧉"
docs_status = "Open the DZGUI documentation in a browser"
docs_fallback_label = "Documentation/help files (Codeberg mirror) ⧉"
docs_fallback_status = "Open the DZGUI documentation in a browser"
bugs_label = "Report a bug (GitHub) ⧉"
bugs_status = "Open the DZGUI issue tracker in a browser"
forum_label = "DZGUI Subreddit ⧉"
forum_status = "Open the DZGUI discussion forum in a browser"
sponsor_label = "Sponsor (GitHub) ⧉"
sponsor_status = "Sponsor development of the DZGUI project"
thanks_label = "Special thanks"
thanks_status = "A list of contributors, testers, and sponsors"
+2 -1
View File
@@ -3,4 +3,5 @@ mod_id = "ID"
up_to_date = "Up to date" up_to_date = "Up to date"
modlist = "Modlist" modlist = "Modlist"
checkmark = "✓" checkmark = "✓"
resync="⟳" resync = "⟳"
invalid_mod = "Invalid mod"
+10
View File
@@ -0,0 +1,10 @@
exit_label = "Exit"
exit_tooltip = "Quits the application"
help_label = "Help"
help_tooltip = "Troubleshooting and documentation"
mods_label = "Mods"
mods_tooltip = "Manage local mods"
options_label = "Options"
options_tooltip = "Advanced options"
servers_label = "Servers"
servers_tooltip = "Search for and connect to servers"
+2
View File
@@ -0,0 +1,2 @@
esc_to_return = "Press ESC to return"
question_to_return = "Press ? to return"
+24
View File
@@ -0,0 +1,24 @@
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 = [
"bongjutsu",
"Deku",
"dj3hac",
"finntux",
"GaryBlackbourne",
"jiriks74",
"Johnofwrong",
"MatheusLasserr",
"nolan-perez",
"OnniSaarni",
"scandalouss",
"SnackSBR",
"StevelDusa",
"sylvaingirardbe",
"Thoughtduck216",
"u-alexandru",
]
+5 -5
View File
@@ -3,7 +3,7 @@ title_intro = "Welcome"
blurb_intro = """ blurb_intro = """
This wizard will help you set up some common config options before launching the application. This wizard will help you set up some common config options before launching the application.
""" """
error_sandbox = "Setup cannot be run from inside Flatpak sandbox.\nPlease launch the application directly." error_sandbox = "Setup cannot be run from inside a sandboxed version of Steam (Snap/Flatpak).\nPlease launch the application directly first."
welcome = "Welcome to {0}!" welcome = "Welcome to {0}!"
### SteamPathPage ### SteamPathPage
@@ -12,15 +12,15 @@ blurb_steam_path = """
DZGUI needs to find the location to your default Steam installation. DZGUI needs to find the location to your default Steam installation.
This will be used to determine whether (and where) DayZ is installed. This will be used to determine whether (and where) DayZ is installed.
""" """
desc_custom_path = "This is the expected Steam path <b>if you set a custom XDG_DATA_HOME directory.</b>"
desc_default_path = "This is the default Steam path on <b>most distributions</b>." desc_default_path = "This is the default Steam path on <b>most distributions</b>."
desc_flatpak_path = ( desc_flatpak_path = (
"This is the default Steam path if you are using <b>Flatpak Steam</b>." "This is the default Steam path if you are using <b>Flatpak Steam</b>."
) )
desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>." desc_ubuntu_path = "This is the default Steam path on <b>Ubuntu-based systems</b>."
desc_snap_path = "This is the default Steam path on <b>systems using Snap packages</b>."
desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>." desc_debian_path = "This is the default Steam path on <b>Debian-based systems</b>."
no_valid_paths = ( no_valid_paths = "No valid Steam path or Steam command found on system. Please install Steam to continue."
"No valid Steam path or Steam command found on system. Please install Steam to continue."
)
button_scan = "Scan for Steam" button_scan = "Scan for Steam"
### ConfigMigrationPage ### ConfigMigrationPage
@@ -73,7 +73,7 @@ checkbox_steam_shortcut = (
"This creates a standalone copy of DZGUI and adds it to Steam. " "This creates a standalone copy of DZGUI and adds it to Steam. "
"You <b>must restart Steam</b> for the shortcut to appear. This will not replace or update existing shortcuts. " "You <b>must restart Steam</b> for the shortcut to appear. This will not replace or update existing shortcuts. "
"If you update DZGUI when it is launched via Steam, updates will be applied to the Steam version. " "If you update DZGUI when it is launched via Steam, updates will be applied to the Steam version. "
"Not available if you selected the Flatpak client as your Steam default." "Not available if you selected the Snap client as your Steam default."
), ),
) )
checkbox_start_menu = ( checkbox_start_menu = (
+1 -2
View File
@@ -1,8 +1,7 @@
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0") from gi.repository import Gtk, Gdk
from gi.repository import Gtk, Gdk # noqa E402
def copy_clipboard(text: str) -> None: def copy_clipboard(text: str) -> None:
+1 -1
View File
@@ -5,7 +5,7 @@ from dzgui.const.constants import APP_NAME_LOWER, CSS_PATH
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk # noqa E402 from gi.repository import Gtk, Gdk
def add_class(widget: Gtk.Widget, label: str) -> None: def add_class(widget: Gtk.Widget, label: str) -> None:
+6 -11
View File
@@ -10,6 +10,7 @@ from dzgui.const.constants import APP_NAME
from dzgui.const.enum import Preferences from dzgui.const.enum import Preferences
from dzgui.config.query import lookup from dzgui.config.query import lookup
from dzgui.init.prefix import get_version from dzgui.init.prefix import get_version
from dzgui.strings import metadata
from dzgui.util.redact import redact_home from dzgui.util.redact import redact_home
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -27,28 +28,22 @@ def get_cpu_model() -> str:
def print_servers(servers: list[str]) -> str: def print_servers(servers: list[str]) -> str:
s = "" return "\n".join(servers)
for server in servers:
s += server + "\n"
return s
def print_mods(mods: list[int]) -> str: def print_mods(mods: list[int]) -> str:
s = "" return "\n".join(map(str, mods))
for mod in mods:
s += str(mod) + "\n"
return s
def write_diagnostic(config: Path, outfile: Path) -> None: def write_diagnostic(config: Path, outfile: Path) -> None:
date = datetime.now().isoformat() date = datetime.now().isoformat()
try: try:
# FIXME: ID_LIKE not available on CachyOS # NOTE: ID_LIKE not available on CachyOS
distro = platform.freedesktop_os_release()["ID_LIKE"] distro = platform.freedesktop_os_release()["ID_LIKE"]
except Exception as e: except Exception as e:
logger.warn(e) logger.warn(e)
distro = "Unknown" distro = metadata.unknown
kernel = os.uname().release kernel = os.uname().release
cpu = get_cpu_model() cpu = get_cpu_model()
@@ -68,7 +63,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
servers = lookup(config, Preferences.IP_LIST) servers = lookup(config, Preferences.IP_LIST)
servers_pretty = print_servers(servers) servers_pretty = print_servers(servers)
# FIXME: extraneous newlines in lists of mods
template = f"""\ template = f"""\
{APP_NAME} version {version} {APP_NAME} version {version}
Date: {date} Date: {date}
@@ -82,6 +76,7 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
Mods: Mods:
{mods_pretty} {mods_pretty}
Servers: Servers:
{servers_pretty} {servers_pretty}
""" """
+3 -2
View File
@@ -10,8 +10,9 @@ from dzgui.const.constants import APP_NAME, APP_NAME_LOWER, IMAGES_PATH
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
def make_parents(path: "Path") -> None: def make_parents(path: "Path", descend: bool = False) -> None:
path.parent.mkdir(parents=True, exist_ok=True) p = path if descend else path.parent
p.mkdir(parents=True, exist_ok=True)
def copy_dzgui_to_xdg_data(exe_path: Path) -> None: def copy_dzgui_to_xdg_data(exe_path: Path) -> None:
+2 -7
View File
@@ -7,11 +7,6 @@ from dzgui.const.constants import APP_NAME
from dzgui.util.ip import get_coords from dzgui.util.ip import get_coords
from dzgui.util.localize import number from dzgui.util.localize import number
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402
if TYPE_CHECKING: if TYPE_CHECKING:
from queue import Queue from queue import Queue
from dzgui.const.enum import ServerTab from dzgui.const.enum import ServerTab
@@ -59,7 +54,7 @@ class CalcDist:
self, self,
addr: str, addr: str,
enum: "ServerTab", enum: "ServerTab",
result_queue: "Queue", result_queue: "Queue[tuple[str, Haversine | None, ServerTab]]",
controller: "Controller", controller: "Controller",
cache: dict[str, Haversine], cache: dict[str, Haversine],
) -> None: ) -> None:
@@ -72,7 +67,7 @@ class CalcDist:
self.ip = self.addr self.ip = self.addr
dist = self.compare(self.ip) dist = self.compare(self.ip)
self.result_queue.put([self.addr, dist, self.enum]) self.result_queue.put((self.addr, dist, self.enum))
def compare(self, remote_ip: str) -> Haversine | None: def compare(self, remote_ip: str) -> Haversine | None:
prefs = self.controller.get_prefs() prefs = self.controller.get_prefs()
+6 -2
View File
@@ -1,12 +1,16 @@
import logging import logging
import subprocess import subprocess
from typing import TYPE_CHECKING
from dzgui.const.constants import APP_NAME, FLATPAK_APPID, GTK_APP_ID, TMP_PATH from dzgui.const.constants import APP_NAME, FLATPAK_APPID, GTK_APP_ID, TMP_PATH
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
if TYPE_CHECKING:
from pathlib import Path
def apply_overrides(xdg: dict[str, str]) -> None:
def apply_overrides(xdg: dict[str, "Path"]) -> None:
try: try:
# NOTE: D-Bus registration required for sandbox # NOTE: D-Bus registration required for sandbox
args = [ args = [
@@ -19,7 +23,7 @@ def apply_overrides(xdg: dict[str, str]) -> None:
subprocess.run([*args], capture_output=True) subprocess.run([*args], capture_output=True)
paths: list[str] = [] paths: list[str] = []
paths.extend([*xdg.values()]) paths.extend([str(path) for path in xdg.values()])
paths.append(TMP_PATH) paths.append(TMP_PATH)
for path in paths: for path in paths:
+8 -8
View File
@@ -1,13 +1,13 @@
import re import re
from typing import Any
from dzgui.util.localize import number from dzgui.util.localize import number
from dzgui.strings.generic import selectable_tree from dzgui.strings import crumbs, errors, generic
from dzgui.util.strings import no_mods, no_servers, workshop
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402 from gi.repository import Gtk
def format_pango(text: str) -> str: def format_pango(text: str) -> str:
@@ -44,10 +44,10 @@ def format_hyperlinks(text: str) -> str:
def format_mods(size: int, mods: int) -> str: def format_mods(size: int, mods: int) -> str:
if mods == 0: if mods == 0:
return no_mods return errors.no_mods
l_size = number(size) l_size = number(size)
plural = pluralize("mods", mods) plural = pluralize("mods", mods)
suffix = selectable_tree suffix = generic.selectable_tree
return f"Found {mods:n} {plural} taking up {l_size} MiB. {suffix}" return f"Found {mods:n} {plural} taking up {l_size} MiB. {suffix}"
@@ -57,15 +57,15 @@ def format_mib(bits: int) -> float:
def format_server_mods(mods: int) -> str: def format_server_mods(mods: int) -> str:
plural = pluralize("mods", mods) plural = pluralize("mods", mods)
return f"Found {mods:n} {plural}. {workshop}" return f"Found {mods:n} {plural}. {crumbs.workshop}"
def format_player_count(model: Gtk.TreeModel | None, control: list) -> str: def format_player_count(model: Gtk.TreeModel | None, control: list[Any]) -> str:
players = 0 players = 0
hits: int hits: int
status: str status: str
if model is None: if model is None:
return no_servers return errors.no_servers
else: else:
hits = len(model) hits = len(model)
for row in model: for row in model:
+9
View File
@@ -0,0 +1,9 @@
from dataclasses import dataclass
from typing import Callable
def immutable_dataclass(cls: type | None = None, **kwargs: bool) -> type | Callable[[type], type]:
kwargs["slots"] = True
kwargs["frozen"] = True
if cls is None:
return lambda c: dataclass(c, **kwargs)
return dataclass(cls, **kwargs)
+3 -4
View File
@@ -1,10 +1,10 @@
import a2s import a2s
from ipaddress import ip_address
import requests import requests
import shutil import shutil
import subprocess import subprocess
from dataclasses import dataclass from dataclasses import dataclass
from ipaddress import ip_address
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.api.servers import Record from dzgui.api.servers import Record
@@ -12,12 +12,11 @@ from dzgui.config.ipdb import read_from_table
from dzgui.const.constants import REQUEST_TIMEOUT from dzgui.const.constants import REQUEST_TIMEOUT
from dzgui.const.endpoints import IP_ECHO from dzgui.const.endpoints import IP_ECHO
if TYPE_CHECKING: if TYPE_CHECKING:
from pathlib import Path from pathlib import Path
@dataclass @dataclass(slots=True, frozen=True)
class Coords: class Coords:
lat: float lat: float
lon: float lon: float
@@ -31,7 +30,7 @@ class ReservedIPError(Exception):
pass pass
def ip2list(ip: str) -> list: def ip2list(ip: str) -> list[int]:
return [int(digit) for digit in ip.split(".")] return [int(digit) for digit in ip.split(".")]
+4 -1
View File
@@ -1,6 +1,8 @@
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gdk # noqa E402 from gi.repository import Gdk
def is_navkey(key: int) -> bool: def is_navkey(key: int) -> bool:
nav_keys = [ nav_keys = [
@@ -18,6 +20,7 @@ def is_navkey(key: int) -> bool:
return True return True
return False return False
def is_ctrl_mask(event: Gdk.EventKey) -> bool: def is_ctrl_mask(event: Gdk.EventKey) -> bool:
if event.state is Gdk.ModifierType.CONTROL_MASK: if event.state is Gdk.ModifierType.CONTROL_MASK:
return True return True
+3 -1
View File
@@ -1,6 +1,8 @@
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402 from gi.repository import Gtk
def set_surrounding_margins(widget: Gtk.Widget, margin: int) -> None: def set_surrounding_margins(widget: Gtk.Widget, margin: int) -> None:
""" """
+1 -1
View File
@@ -4,7 +4,7 @@ from typing import cast, TYPE_CHECKING
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib # noqa E402 from gi.repository import Gdk, GLib
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
-546
View File
@@ -1,546 +0,0 @@
from dataclasses import dataclass
from dzgui.const.constants import SYSTEM_LOG
# General
dialog_header = "DZGUI - Dialog"
dz = "DayZ"
dz_exp = "DayZ Experimental"
delimiter = "␞"
# GenericDialog
main_menu = "Return to main menu"
exit_app = "Exit"
modlist = "Modlist"
input_required = "User input required"
confirm = "Confirmation"
notice = "Notice"
wait = "Please wait"
restart_required = "App relaunch required"
# Wait dialogs
ping = "Ping"
mod = "Mod"
_id = "ID"
# ContextMenu
add_note = "Add note"
edit_note = "Edit note"
show_mods = "Show server-side mods"
show_details = "Show server details"
refresh_players = "Refresh player count"
open_workshop = "Open in Steam Workshop"
unsub_mod = "Unsubscribe mod"
validate_mod = "Validate mod"
copy_name = "Copy name to clipboard"
copy_ip = "Copy IP to clipboard"
copy_log = "Copy record(s) to clipboard"
add = "Add to Saved Servers"
add_fav = "Set as favorite"
remove = "Remove from Saved Servers"
remove_history = "Remove from history"
connect = "Connect"
# Columns
server_mod_cols = ["Mod", "ID", "Installed"]
mod_cols = ["Mod", "Symlink", "ID", "Size (MiB)", "Color"]
log_cols = ["Timestamp", "Flag", "Traceback", "Message"]
browser_cols = [
"Name",
"Map",
"View",
"Gametime",
"Players",
"Max",
"Queue",
"IP",
"Qport",
"Ping",
]
# DetailsDialog
workshop = "Enter/double click a row to open in Steam Workshop."
# LanDialog
default_port = "Use default query port (27016)"
custom_port = "Enter custom query port"
scan_servers = "Scan LAN servers"
select_port = "Select the query port"
# Errors
error_heading = "Error"
config_not_found = "DZGUI configuration file not found. Please exit and restart."
cannot_acquire_lock = "DZGUI is already open."
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."
)
server_timeout = "Timed out when querying server(s). Check IP or try again later."
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",
"Down arrow": "move down a row/scroll down",
"Up arrow": "move up a row/scroll up",
"Right arrow": "jump to sidebar from main area",
"Left arrow": "jump to main area from sidebar",
"Tab": "cycle forward through elements",
"Shift-tab": "cycle backward through elements",
"ESC/Enter": "close dialogs",
"?": "show/hide this dialog",
"Ctrl-q": "Quit",
}
servers = {
"Enter/space/double-click": "connect to server",
"Right-click/Ctrl-l": "additional context menus",
"Ctrl-r": "refresh players",
"Ctrl-f": "jump to keyword search field",
"Ctrl-m": "jump to maps field",
"Ctrl-d": "select default LAN port",
"Ctrl-n": "select custom LAN port",
"Ctrl-u": "connect to server from preconnect dialog",
"Ctrl-i": "jump to IP insert field",
"n": "navigate to next tab",
"p": "navigate to previous tab",
"ESC": "return to table",
"1-9": "toggle filter 1-9 on/off",
"0": "toggle filter 10",
"Minus": "toggle filter 11",
"Backslash": "toggle filter 12",
}
vim = {
"j": "Move down a row/scroll up",
"k": "Move up a row/scroll down",
"h": "Jump to main area from sidebar",
"l": "Jump to sidebar from main area",
"g": "Jump to first row/top of page",
"G": "Jump to last row/bottom of page",
}
key_contexts = ["Servers", "Navigation", "Vim-style keys"]
key_header = "Keybindings"
# ModSelectionPanel
# labels
label_main_menu = "Main menu"
# buttons
ping_servers = "Ping servers"
ping_tooltip = (
"Refresh the ping for visible servers.\n" "Available once per unique filter context"
)
# statusbar_helptext = "Select a row to see its detailed description"
# statusbar_helptext = "No server metadata to list."
# use e.g. filters.1pp
filter_1pp = "1PP"
filter_3pp = "3PP"
filter_day = "Day"
filter_night = "Night"
filter_empty = "Empty"
filter_full = "Full"
filter_lowpop = "Low pop"
filter_nonascii = "Non-ASCII"
filter_duplicate = "Duplicate"
filter_official = "Official"
filter_unofficial = "Unofficial"
filter_modded = "Modded"
filter_unmodded = "Unmodded"
# maps
all_maps = "All maps"
# state
unknown = "Unknown"
none_provided = "None provided"
disabled = "Disabled"
enabled = "Enabled"
null = "-"
unspecified = "not specified"
# DLC
dlc_frostline = "Frostline"
dlc_badlands = "Badlands"
dlc_none = "None"
# platform
windows = "Windows"
linux = "Linux"
# misc
self_workshop = "Open Steam workshop"
settings_updated = "Settings updated!"
@dataclass(slots=True, frozen=True)
class ModPanelStrings:
header: str
unhighlight_stale: str
unhighlight_stale_tooltip: str
highlight_stale: str
highlight_stale_tooltip: str
unsub_selected: str
unsub_selected_tooltip: str
unselect_all: str
unselect_all_tooltip: str
select_all: str
select_all_tooltip: str
bulk_select: str
clear_highlights: str
select_stale: str
select_stale_tooltip: str
validate: str
validate_tooltip: str
@dataclass(slots=True, frozen=True)
class Dialog:
querying: str
fetching: str
filtering: str
refreshing: str
details: str
modlist: str
working: str
updating_mods: str
scanning: 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
servers_tooltip: str
mods_label: str
mods_tooltip: str
options_label: str
options_tooltip: str
help_label: str
help_tooltip: str
exit_label: str
exit_tooltip: str
@dataclass(slots=True, frozen=True)
class Crumbs:
changelog: str
keys: str
log: str
_help: str
mods: str
options: str
servers: str
thanks: str
developers: str
default: str
offline: str
@dataclass(slots=True, frozen=True)
class Thanks:
header: str
description: str
users: list[str]
@dataclass(slots=True, frozen=True)
class Options:
header: str
steam_web: str
enter_steam: str
steam_placeholder: str
name_placeholder: str
last_used: str
always_fs: str
steam: str
flatpak: str
km: str
mi: str
client: str
window_size: str
distance: str
name: str
manual_dl: str
auto_dl: str
update: str
install_mode: str
force_update: str
dl_eventbox: str
force_eventbox: str
self_update: str
no_self_update: str
api_key: str
prefs: str
mods: str
version: str
branch: str
stable: str
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="Your chosen client (Steam/Flatpak Steam) must 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=(
"Shows locally-installed mods which are not \n"
"used by any server in your Saved Servers"
),
unsub_selected="Unsubscribe selected",
unsub_selected_tooltip="Unsubscribes from selected mods",
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",
validate="Validate selected",
validate_tooltip="Validates selected mods and updates them if necessary",
)
thanks = Thanks(
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=[
"bongjutsu",
"Deku",
"dj3hac",
"finntux",
"GaryBlackbourne",
"jiriks74",
"Johnofwrong",
"MatheusLasserr",
"nolan-perez",
"OnniSaarni",
"scandalouss",
"SnackSBR",
"StevelDusa",
"Thoughtduck216",
],
)
options = Options(
header="Options",
steam_web="Steam API page",
enter_steam="Enter your Steam API key",
steam_placeholder="Steam API key",
name_placeholder="Identifies you to other players in-game",
last_used="Last used dimensions",
always_fs="Always fullscreen",
steam="Steam",
flatpak="Flatpak (experimental)",
km="km (kilometers)",
mi="mi (miles)",
client="Steam client",
window_size="Window size at boot",
distance="Distance display",
name="Player name",
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."
),
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=(
"In-app updates are disabled when DZGUI is "
"installed globally (e.g., via package manager)."
),
api_key="API Key",
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.
Open your Profile, then 'Workshop Items' and select 'Unsubscribe from all'
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",
scanning="Scanning LAN ports",
)
buttons = Button(
servers_label="Servers",
servers_tooltip="Search for and connect to servers",
mods_label="Mods",
mods_tooltip="Manage local mods",
options_label="Options",
options_tooltip="Advanced options",
help_label="Help",
help_tooltip="Troubleshooting and documentation",
exit_label="Exit",
exit_tooltip="Quits the application",
)
crumbs = Crumbs(
changelog="Help > Changelog",
keys="Keybindings",
log="Help > Debug log",
_help="Help",
mods="Mods",
options="Options",
servers="Servers > Server browser",
thanks="Help > Special thanks",
developers="Options > Developers",
default="Servers > ",
offline="Mods > Play offline",
)
no_mods = "No local mods found."
no_servers = "No server metadata to list."
@dataclass(slots=True, frozen=True)
class Flags:
description: str
version: str
uninstall: str
debug: str
map_count: str
flags = Flags(
description="DayZ server browser and mod manager",
version="print version information",
uninstall="clean up state/config files",
debug="enable developer debugging features",
map_count="check and update system map count value",
)
@dataclass(slots=True, frozen=True)
class FilePicker:
title: str
placeholder: str
picker = FilePicker(
title="Save diagnostic log to file",
placeholder=SYSTEM_LOG,
)
api_error = (
"API key validation error or timeout. See 'Help > Show debug log' for details."
)
@dataclass(slots=True, frozen=True)
class DevelopersPage:
header: str
paths_label: str
prefs_label: str
columns: list[str]
developers = DevelopersPage(
header="Developers",
paths_label="Resolved XDG paths",
prefs_label="Boot preferences",
columns=["Key", "Value"],
)
@dataclass(slots=True, frozen=True)
class ServerLabels:
browser: str
saved: str
recent: str
lan: str
server_labels = ServerLabels(
browser="Server Browser",
saved="Saved Servers",
recent="Recent",
lan="LAN",
)
distance_suffix = "Distance: calculating..."
dialog_error = "ERROR"
@dataclass(slots=True, frozen=True)
class AtomicButton:
refresh: str
refresh_tooltip: str
copy: str
keys: str
keys_tooltip: str
atomic_buttons = AtomicButton(
refresh="Refresh",
refresh_tooltip="Refresh server data",
copy="Copy",
keys="Keys",
keys_tooltip="Toggles the keybindings dialog",
)
gtk_theme_missing = "No GTK theme provided"
steam_icon_missing = "Steam icon not found in IconTheme"
missing_changelog = "Error: failed to read changelog"
esc_to_return = "Press ESC to return"
question_to_return = "Press ? to return"
alert_button_tooltip = "Click to open debug log"
address_already_saved = "This address is already in your Saved Servers"
stop_scanning = "Stop scanning on first hit"
abort_tooltip = "Unless you have multiple DayZ servers on your LAN,\nleave this checked to get results faster"
+2
View File
@@ -35,6 +35,8 @@ def rebuild_symlinks(config: Path) -> None:
expunge_link(file) expunge_link(file)
workshop = get_local_mod_path(steam_path) workshop = get_local_mod_path(steam_path)
if workshop.is_dir() is False:
return
# NOTE: create symlinks for missing mods # NOTE: create symlinks for missing mods
for mod_id in get_local_mod_ids(steam_path): for mod_id in get_local_mod_ids(steam_path):
uid = str(mod_id) uid = str(mod_id)
+6 -4
View File
@@ -1,3 +1,4 @@
import gi
import logging import logging
import signal import signal
@@ -34,11 +35,9 @@ from dzgui.views.pages.preconnect import PreConnectionAssistant
from dzgui.views.pages.servers import ServerNotebook from dzgui.views.pages.servers import ServerNotebook
from dzgui.views.pages.thanks import Thanks from dzgui.views.pages.thanks import Thanks
import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
gi.require_version("GLibUnix", "2.0") gi.require_version("GLibUnix", "2.0")
from gi.repository import Gtk, GLib, GLibUnix, Gdk # type: ignore # noqa E402 from gi.repository import Gtk, GLib, GLibUnix, Gdk # type: ignore
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.config.userprefs import UserPrefs from dzgui.config.userprefs import UserPrefs
@@ -49,7 +48,10 @@ logger = logging.getLogger(APP_NAME)
class OuterWindow(Gtk.ApplicationWindow): class OuterWindow(Gtk.ApplicationWindow):
def __init__(self, app: "App") -> None: def __init__(self, app: "App") -> None:
super().__init__( super().__init__(
application=app, title=APP_NAME, border_width=10, icon_name=APP_NAME_LOWER application=app,
title=APP_NAME,
border_width=10,
icon_name=APP_NAME_LOWER,
) )
self.hb = AppHeaderBar() self.hb = AppHeaderBar()
+3 -3
View File
@@ -1,9 +1,9 @@
from typing import Sequence
import gi import gi
from typing import Sequence
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa from gi.repository import Gtk
class GenericBox(Gtk.Box): class GenericBox(Gtk.Box):
+11 -7
View File
@@ -1,13 +1,13 @@
import logging import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.const.constants import APP_NAME, NO_EXPAND, NO_FILL, NO_PADDING from dzgui.const.constants import APP_NAME
from dzgui.const.enum import ButtonType from dzgui.const.enum import ButtonType
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk # noqa E402 from gi.repository import Gtk, Gdk
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -19,7 +19,11 @@ if TYPE_CHECKING:
class ContextualButton(Gtk.Button): class ContextualButton(Gtk.Button):
def __init__( def __init__(
self, label: str, opens: "NotebookPage", tooltip: str, context: ButtonType self,
label: str,
opens: "NotebookPage | None",
tooltip: str,
context: ButtonType,
) -> None: ) -> None:
super().__init__( super().__init__(
label=label, label=label,
@@ -51,9 +55,9 @@ class ButtonBox(Gtk.Box):
for side_button in ButtonType: for side_button in ButtonType:
button = ContextualButton( button = ContextualButton(
label=side_button.dict["label"], label=side_button.label,
opens=side_button.dict["opens"], opens=side_button.opens,
tooltip=side_button.dict["tooltip"], tooltip=side_button.tooltip,
context=side_button, context=side_button,
) )
@@ -63,7 +67,7 @@ class ButtonBox(Gtk.Box):
self.buttons.append(button) self.buttons.append(button)
button.connect("clicked", self._on_selection_button_clicked) button.connect("clicked", self._on_selection_button_clicked)
self.pack_start(button, NO_EXPAND, NO_FILL, NO_PADDING) self.pack_start(button, expand=False, fill=False, padding=0)
def _focus_first_button(self, emitter: "Emitter") -> None: def _focus_first_button(self, emitter: "Emitter") -> None:
self.buttons[0].grab_focus() self.buttons[0].grab_focus()
+30 -64
View File
@@ -1,28 +1,22 @@
from typing import Callable, Literal, Self, TYPE_CHECKING, Union from typing import Callable, Literal, Self, TYPE_CHECKING
from dzgui.util.clip import copy_clipboard from dzgui.util.clip import copy_clipboard
from dzgui.util.format import pluralize
from dzgui.strings import buttons from dzgui.strings import buttons
from dzgui.util.strings import ( from dzgui.const.icons import (
alert_button_tooltip, ICON_CLIPBOARD,
atomic_buttons, ICON_CLOSE,
) ICON_INPUT_KEYBOARD,
from dzgui.const.constants import ( ICON_LIST_ADD,
CLIPBOARD, ICON_REFRESH,
CLOSE, ICON_STEAM,
INPUT_KEYBOARD, ICON_WEB_BROWSER,
LIST_ADD,
REFRESH_ICON,
STEAM_ICON,
WARNING,
WEB_BROWSER,
) )
from dzgui.strings import connect_panel from dzgui.strings import connect_panel
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GLib # noqa E402 from gi.repository import Gtk, GLib
if TYPE_CHECKING: if TYPE_CHECKING:
from gi.repository import GLib from gi.repository import GLib
@@ -64,7 +58,7 @@ class IconButton(Gtk.Button):
self.icon = Icon(icon, margin_start=margin_start, margin_end=margin_end) self.icon = Icon(icon, margin_start=margin_start, margin_end=margin_end)
self.set_image(self.icon) self.set_image(self.icon)
self.set_image_position(position) self.set_image_position(position)
self.set_focus_on_click(False) self.set_focus_on_click(False) # type: ignore[no-untyped-call]
self.set_always_show_image(True) self.set_always_show_image(True)
def swap_icon(self, icon: str) -> None: def swap_icon(self, icon: str) -> None:
@@ -101,15 +95,13 @@ class LargeIconTextButton(IconButton):
class ClipboardButton(IconTextButton): class ClipboardButton(IconTextButton):
def __init__(self, controller: Union["Controller", None], func: Callable) -> None: def __init__(self, func: Callable[[], str]) -> None:
super().__init__(CLIPBOARD, atomic_buttons.copy) super().__init__(ICON_CLIPBOARD, buttons.copy_button)
self.controller = controller
self.connect("clicked", self._on_button_clicked, func) self.connect("clicked", self._on_button_clicked, func)
# TODO: strings self.set_tooltip_text(buttons.clipboard_button)
self.set_tooltip_text("Copy to clipboard")
def _on_button_clicked(self, button: Self, func: Callable) -> None: def _on_button_clicked(self, button: Self, func: Callable[[], str]) -> None:
def revert() -> Literal[False]: def revert() -> Literal[False]:
self.revert_icon() self.revert_icon()
return False return False
@@ -120,34 +112,31 @@ class ClipboardButton(IconTextButton):
GLib.timeout_add(600, revert) GLib.timeout_add(600, revert)
# TODO: determine when controller would be passed to this button or drop
class CopyIpButton(ClipboardButton): class CopyIpButton(ClipboardButton):
def __init__(self, controller: Union["Controller", None], func: Callable) -> None: def __init__(self, func: Callable[[], str]) -> None:
super().__init__(controller, func) super().__init__(func)
# TODO: strings self.set_tooltip_text(buttons.clipboard_ip_button)
self.set_tooltip_text("Copy IP to clipboard")
class CloseButton(IconTextButton): class CloseButton(IconTextButton):
def __init__(self, label: str) -> None: def __init__(self, label: str) -> None:
super().__init__(icon=CLOSE, label=label) super().__init__(icon=ICON_CLOSE, label=label)
# TODO: strings self.set_tooltip_text(buttons.unset_button_tooltip)
self.set_tooltip_text("Unset this server as favorite")
class WebButton(IconTextButton): class WebButton(IconTextButton):
def __init__(self, label: str) -> None: def __init__(self, label: str) -> None:
super().__init__(icon=WEB_BROWSER, label=label) super().__init__(icon=ICON_WEB_BROWSER, label=label)
pass pass
class RefreshButton(IconTextButton): class RefreshButton(IconTextButton):
def __init__(self, controller: "Controller") -> None: def __init__(self, controller: "Controller") -> None:
super().__init__( super().__init__(
icon=REFRESH_ICON, icon=ICON_REFRESH,
label=atomic_buttons.refresh, label=buttons.refresh_button,
) )
self.controller = controller self.controller = controller
@@ -160,7 +149,7 @@ class RefreshButton(IconTextButton):
self.set_margin_top(10) self.set_margin_top(10)
self.set_margin_start(80) self.set_margin_start(80)
self.set_margin_end(80) self.set_margin_end(80)
self.set_tooltip_text(atomic_buttons.refresh_tooltip) self.set_tooltip_text(buttons.refresh_tooltip)
self.connect("clicked", self._on_refresh_clicked) self.connect("clicked", self._on_refresh_clicked)
emitter.connect("servers_loaded", self._on_load) emitter.connect("servers_loaded", self._on_load)
@@ -204,21 +193,21 @@ class RefreshButton(IconTextButton):
def show_time(self, state: bool) -> None: def show_time(self, state: bool) -> None:
if state is True: if state is True:
self.set_label(f"{atomic_buttons.refresh} ({str(self.time)})") self.set_label(f"{buttons.refresh_button} ({str(self.time)})")
else: else:
self.set_label(atomic_buttons.refresh) self.set_label(buttons.refresh_button)
class KeysButton(IconTextButton): class KeysButton(IconTextButton):
def __init__(self, controller: "Controller") -> None: def __init__(self, controller: "Controller") -> None:
super().__init__(icon=INPUT_KEYBOARD, label=atomic_buttons.keys) super().__init__(icon=ICON_INPUT_KEYBOARD, label=buttons.keys_button)
self.controller = controller self.controller = controller
self.set_margin_top(10) self.set_margin_top(10)
self.set_margin_start(80) self.set_margin_start(80)
self.set_margin_end(80) self.set_margin_end(80)
self.set_tooltip_text(atomic_buttons.keys_tooltip) self.set_tooltip_text(buttons.keys_button_tooltip)
self.connect("clicked", self._on_keys_clicked) self.connect("clicked", self._on_keys_clicked)
@@ -228,7 +217,7 @@ class KeysButton(IconTextButton):
class SteamConnectButton(LargeIconTextButton): class SteamConnectButton(LargeIconTextButton):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__(icon=STEAM_ICON, label=connect_panel.connect_button) super().__init__(icon=ICON_STEAM, label=connect_panel.connect_button)
self.set_tooltip_text(connect_panel.connect_tooltip) self.set_tooltip_text(connect_panel.connect_tooltip)
@@ -248,33 +237,10 @@ class SteamWorkshopButton(SteamTextButton):
class AddButton(IconTextButton): class AddButton(IconTextButton):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__(icon=LIST_ADD, label=connect_panel.add_button) super().__init__(icon=ICON_LIST_ADD, label=connect_panel.add_button)
self.set_tooltip_text(connect_panel.add_tooltip) self.set_tooltip_text(connect_panel.add_tooltip)
class LoggerAlertsButton(IconTextButton):
def __init__(self, warnings: int, errors: int) -> None:
warnings_text = ""
errors_text = ""
separator = ""
if warnings > 0:
warnings_plural = pluralize("warnings", warnings)
warnings_text = f"{warnings} {warnings_plural}"
if errors > 0:
errors_plural = pluralize("errors", errors)
errors_text = f" {errors} {errors_plural}"
if warnings + errors > 1:
separator = ","
concat = warnings_text + separator + errors_text
super().__init__(
icon=WARNING,
label=f"Loaded with{concat}",
)
self.set_halign(Gtk.Align.END)
self.set_hexpand(True)
self.set_tooltip_text(alert_button_tooltip)
class SpinnerButton(Gtk.Button): class SpinnerButton(Gtk.Button):
def __init__(self, label: str) -> None: def __init__(self, label: str) -> None:
super().__init__() super().__init__()
+16 -15
View File
@@ -1,8 +1,14 @@
from typing import Self, TYPE_CHECKING from typing import Self, TYPE_CHECKING
from dzgui.const.constants import CARET_DOWN, CARET_UP, UDP_PORT from dzgui.const.icons import ICON_CARET_DOWN, ICON_CARET_UP
from dzgui.const.constants import UDP_PORT
from dzgui.model.servers import ServerModelManager from dzgui.model.servers import ServerModelManager
from dzgui.strings import connect_panel from dzgui.strings import connect_panel
from dzgui.strings.buttons import (
dock_button_collapse,
dock_button_expand,
unset_button_label,
)
from dzgui.util.keys import is_ctrl_mask from dzgui.util.keys import is_ctrl_mask
from dzgui.views.components.buttons import ( from dzgui.views.components.buttons import (
AddButton, AddButton,
@@ -18,7 +24,7 @@ from dzgui.views.components.labels import BoldLabel
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk # noqa E402 from gi.repository import Gtk, Gdk
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -30,27 +36,24 @@ ROWS = 1
class DockButton(IconButton): class DockButton(IconButton):
def __init__(self, child: Gtk.Widget) -> None: def __init__(self, child: Gtk.Widget) -> None:
super().__init__(CARET_DOWN) super().__init__(ICON_CARET_DOWN)
self.expanded = True self.expanded = True
self.child = child self.child = child
self.connect("clicked", self._on_click) self.connect("clicked", self._on_click)
self.collapse_text = "Collapse the connection panel"
self.expand_text = "Expand the connection panel"
self.set_margin_top(10) self.set_margin_top(10)
self.set_tooltip_text(self.collapse_text) self.set_tooltip_text(dock_button_collapse)
def collapse(self) -> None: def collapse(self) -> None:
self.set_image(Icon(CARET_UP)) self.set_image(Icon(ICON_CARET_UP))
self.child.hide() self.child.hide()
self.set_tooltip_text(self.expand_text) self.set_tooltip_text(dock_button_expand)
def expand(self) -> None: def expand(self) -> None:
self.set_image(Icon(CARET_DOWN)) self.set_image(Icon(ICON_CARET_DOWN))
self.child.show() self.child.show()
self.set_tooltip_text(self.collapse_text) self.set_tooltip_text(dock_button_collapse)
def _on_click(self, button: Self) -> None: def _on_click(self, button: Self) -> None:
if self.expanded: if self.expanded:
@@ -81,7 +84,6 @@ class LanPanel(Gtk.Frame):
self.scan = Gtk.Button(label=connect_panel.lan_scan_button) self.scan = Gtk.Button(label=connect_panel.lan_scan_button)
self.scan.connect("clicked", self._on_scan_clicked) self.scan.connect("clicked", self._on_scan_clicked)
# TODO: strings
self.early_abort = Gtk.CheckButton(label=connect_panel.lan_checkbox) self.early_abort = Gtk.CheckButton(label=connect_panel.lan_checkbox)
self.early_abort.set_active(True) self.early_abort.set_active(True)
self.early_abort.set_tooltip_text(connect_panel.lan_abort_tooltip) self.early_abort.set_tooltip_text(connect_panel.lan_abort_tooltip)
@@ -187,10 +189,9 @@ class FavPanel(Gtk.Frame):
self.fav_button = SteamConnectButton() self.fav_button = SteamConnectButton()
self.fav_button.connect("clicked", self._on_connect_clicked) self.fav_button.connect("clicked", self._on_connect_clicked)
self.copy_button = CopyIpButton(self.controller, self.get_fav_ip) self.copy_button = CopyIpButton(self.get_fav_ip)
# TODO: strings self.unset_button = CloseButton(unset_button_label)
self.unset_button = CloseButton("Unset")
self.unset_button.connect("clicked", self._on_unset_clicked) self.unset_button.connect("clicked", self._on_unset_clicked)
if favorite is None: if favorite is None:
+5 -5
View File
@@ -1,13 +1,13 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.const.enum import NotebookPage from dzgui.const.enum import NotebookPage
from dzgui.util.strings import label_main_menu, crumbs from dzgui.strings import crumbs as _crumbs
from dzgui.util.format import embolden from dzgui.util.format import embolden
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib, Gdk, GObject, Pango # noqa E402 from gi.repository import Gtk
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -19,7 +19,7 @@ class Breadcrumbs(Gtk.Label):
def __init__(self, controller: "Controller") -> None: def __init__(self, controller: "Controller") -> None:
super().__init__(halign=Gtk.Align.START) super().__init__(halign=Gtk.Align.START)
crumbs = embolden(label_main_menu) crumbs = embolden(_crumbs.main_menu)
self.set_markup(crumbs) self.set_markup(crumbs)
notebook = controller.get_notebook() notebook = controller.get_notebook()
@@ -43,11 +43,11 @@ class Breadcrumbs(Gtk.Label):
label = page.get_current_tab_text() label = page.get_current_tab_text()
self.set_server_crumbs(label) self.set_server_crumbs(label)
else: else:
crumbs = enum.dict["crumbs"] crumbs = enum.crumbs
self.set_crumbs(crumbs) self.set_crumbs(crumbs)
def set_server_crumbs(self, suffix: str) -> None: def set_server_crumbs(self, suffix: str) -> None:
self.set_crumbs(crumbs.default + suffix) self.set_crumbs(_crumbs.default + suffix)
def set_crumbs(self, crumbs: str) -> None: def set_crumbs(self, crumbs: str) -> None:
text = embolden(crumbs) text = embolden(crumbs)
+13 -17
View File
@@ -1,15 +1,14 @@
from typing import Any, Callable, TYPE_CHECKING from typing import Any, Callable, TYPE_CHECKING
from dzgui.api.servers import validate_ip from dzgui.api.servers import validate_ip
from dzgui.const.constants import VIEW_CONCEAL, VIEW_REVEAL from dzgui.const.icons import ICON_VIEW_CONCEAL, ICON_VIEW_REVEAL
from dzgui.util.css import add_class, remove_class from dzgui.util.css import add_class, remove_class
from dzgui.strings import connect_panel from dzgui.strings import connect_panel, errors, options
from dzgui.strings.errors import api_popover
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, GObject # noqa E402 from gi.repository import Gtk, Gdk, GObject
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -38,7 +37,7 @@ class ValidatedEntry(Gtk.Entry):
def __init__( def __init__(
self, self,
controller: "Controller", controller: "Controller",
func: Callable, func: Callable[[str], bool],
placeholder_text: str = "", placeholder_text: str = "",
tooltip_text: str = "", tooltip_text: str = "",
) -> None: ) -> None:
@@ -46,7 +45,6 @@ class ValidatedEntry(Gtk.Entry):
hexpand=True, placeholder_text=placeholder_text, tooltip_text=tooltip_text hexpand=True, placeholder_text=placeholder_text, tooltip_text=tooltip_text
) )
self.func: Callable
self.set_validation_func(func) self.set_validation_func(func)
self.controller = controller self.controller = controller
@@ -72,7 +70,7 @@ class ValidatedEntry(Gtk.Entry):
self.emit("string_validated", False) self.emit("string_validated", False)
remove_class(self, self.classname) remove_class(self, self.classname)
def set_validation_func(self, func: Callable) -> None: def set_validation_func(self, func: Callable[[str], bool]) -> None:
self.func = func self.func = func
def insert_icon(self) -> None: def insert_icon(self) -> None:
@@ -141,27 +139,25 @@ class APIEntry(Gtk.Box):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
self.func: Callable | None = None self.func: Callable[[str], None] | None = None
# TODO: strings
self.entry = Gtk.Entry( self.entry = Gtk.Entry(
width_chars=60, hexpand=True, placeholder_text="Enter API key" width_chars=60, hexpand=True, placeholder_text=options.api_placeholder
) )
self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, VIEW_REVEAL) self.entry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, ICON_VIEW_REVEAL)
self.entry.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, True) self.entry.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, True)
self.entry.set_visibility(False) self.entry.set_visibility(False)
self.entry.connect("changed", self._on_text_changed) self.entry.connect("changed", self._on_text_changed)
self.entry.connect("icon-release", self._on_icon_release) self.entry.connect("icon-release", self._on_icon_release)
self.entry.connect("activate", self._on_field_activated) self.entry.connect("activate", self._on_field_activated)
# TODO: strings self.submit = Gtk.Button(label=options.api_validate)
self.submit = Gtk.Button(label="Validate")
self.submit.set_sensitive(False) self.submit.set_sensitive(False)
self.submit.connect("clicked", self._on_submit) self.submit.connect("clicked", self._on_submit)
self.pop = Gtk.Popover() self.pop = Gtk.Popover()
self.pop_label = Gtk.Label( self.pop_label = Gtk.Label(
label=api_popover, label=errors.api_popover,
margin_start=10, margin_start=10,
margin_end=10, margin_end=10,
) )
@@ -206,9 +202,9 @@ class APIEntry(Gtk.Box):
) -> None: ) -> None:
visible = widget.get_visibility() visible = widget.get_visibility()
if visible: if visible:
icon, state = VIEW_REVEAL, False icon, state = ICON_VIEW_REVEAL, False
else: else:
icon, state = VIEW_CONCEAL, True icon, state = ICON_VIEW_CONCEAL, True
widget.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, icon) widget.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, icon)
widget.set_visibility(state) widget.set_visibility(state)
@@ -222,7 +218,7 @@ class APIEntry(Gtk.Box):
res = self.func(text) res = self.func(text)
return res return res
def set_validation_func(self, func: Callable | None) -> None: def set_validation_func(self, func: Callable[[str], None] | None) -> None:
self.func = func self.func = func
def disable_button(self) -> None: def disable_button(self) -> None:
+3 -3
View File
@@ -1,12 +1,12 @@
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from dzgui.const.enum import NotebookPage from dzgui.const.enum import NotebookPage
from dzgui.const.constants import HELP_BUBBLE from dzgui.const.icons import ICON_HELP_BUBBLE
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk # noqa E402 from gi.repository import Gtk, Gdk
if TYPE_CHECKING: if TYPE_CHECKING:
from dzgui.controllers.mc import Controller from dzgui.controllers.mc import Controller
@@ -20,7 +20,7 @@ class InfoEventBox(Gtk.EventBox):
self.text = text self.text = text
self.icon = Gtk.Image.new_from_icon_name( self.icon = Gtk.Image.new_from_icon_name(
HELP_BUBBLE, Gtk.IconSize.LARGE_TOOLBAR ICON_HELP_BUBBLE, Gtk.IconSize.LARGE_TOOLBAR
) )
self.icon.set_opacity(0.8) self.icon.set_opacity(0.8)
box = Gtk.Box() box = Gtk.Box()
+21 -19
View File
@@ -3,21 +3,22 @@ from typing import Literal, TYPE_CHECKING
from dzgui.const.constants import ( from dzgui.const.constants import (
APP_NAME, APP_NAME,
EXPAND,
NO_EXPAND,
NO_FILL,
NO_PADDING,
SEARCH_ICON,
) )
from dzgui.const.icons import ICON_SEARCH
from dzgui.util.format import format_exception from dzgui.util.format import format_exception
from dzgui.util.strings import all_maps from dzgui.strings.filters import (
all_maps,
filters_heading,
keyword_placeholder,
map_placeholder,
)
from dzgui.views.components.maps_combo import MapsCombo from dzgui.views.components.maps_combo import MapsCombo
from dzgui.views.components.labels import BoldLabel from dzgui.views.components.labels import BoldLabel
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gdk, Pango, GLib # noqa E402 from gi.repository import Gtk, Gdk, Pango, GLib
logger = logging.getLogger(APP_NAME) logger = logging.getLogger(APP_NAME)
@@ -30,7 +31,7 @@ class ButtonGrid(Gtk.Grid):
def __init__( def __init__(
self, self,
controller: "Controller", controller: "Controller",
defaults: dict[str, str], defaults: dict[str, bool],
tooltips: dict[str, str], tooltips: dict[str, str],
) -> None: ) -> None:
super().__init__( super().__init__(
@@ -42,7 +43,10 @@ class ButtonGrid(Gtk.Grid):
self.checks: list[Gtk.CheckButton] = [] self.checks: list[Gtk.CheckButton] = []
flowbox = Gtk.FlowBox( flowbox = Gtk.FlowBox(
halign=Gtk.Align.CENTER, min_children_per_line=3, max_children_per_line=3, selection_mode=Gtk.SelectionMode.NONE halign=Gtk.Align.CENTER,
min_children_per_line=3,
max_children_per_line=3,
selection_mode=Gtk.SelectionMode.NONE,
) )
for check in defaults.keys(): for check in defaults.keys():
@@ -93,14 +97,13 @@ class ButtonGrid(Gtk.Grid):
logger.info(f"User toggled button '{label}' to {state}") logger.info(f"User toggled button '{label}' to {state}")
self.emitter.emit("check_toggled", label, state) self.emitter.emit("check_toggled", label, state)
def get_checkboxes(self) -> list: def get_checkboxes(self) -> list[Gtk.CheckButton]:
return self.checks return self.checks
class KeywordEntry(Gtk.Entry): class KeywordEntry(Gtk.Entry):
def __init__(self, controller: "Controller") -> None: def __init__(self, controller: "Controller") -> None:
# TODO :strings super().__init__(placeholder_text=keyword_placeholder)
super().__init__(placeholder_text="Filter by keyword")
self.keyword = "" self.keyword = ""
self.controller = controller self.controller = controller
@@ -109,7 +112,7 @@ class KeywordEntry(Gtk.Entry):
self.connect("key-press-event", self._on_keypress) self.connect("key-press-event", self._on_keypress)
self.connect("icon-release", lambda *args: self.activate()) self.connect("icon-release", lambda *args: self.activate())
self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, SEARCH_ICON) self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, ICON_SEARCH)
self.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, True) self.set_icon_activatable(Gtk.EntryIconPosition.SECONDARY, True)
self.emitter.connect("load_maps", self._on_maps_loaded) self.emitter.connect("load_maps", self._on_maps_loaded)
@@ -174,8 +177,7 @@ class FilterPanel(Gtk.Box):
self.keyword_entry = KeywordEntry(self.controller) self.keyword_entry = KeywordEntry(self.controller)
self.button_grid = ButtonGrid(self.controller, defaults, tooltips) self.button_grid = ButtonGrid(self.controller, defaults, tooltips)
# TODO: strings self.filters_label = BoldLabel(filters_heading)
self.filters_label = BoldLabel("Filters")
self.emitter.connect( self.emitter.connect(
"request_keyword_focus", lambda _: self.keyword_entry.grab_focus() "request_keyword_focus", lambda _: self.keyword_entry.grab_focus()
@@ -195,13 +197,12 @@ class FilterPanel(Gtk.Box):
self.maps_entry: Gtk.Entry = self.maps_combo.get_child() # type: ignore self.maps_entry: Gtk.Entry = self.maps_combo.get_child() # type: ignore
self.maps_entry.set_completion(completion) self.maps_entry.set_completion(completion)
# TODO: strings self.maps_entry.set_placeholder_text(map_placeholder)
self.maps_entry.set_placeholder_text("Filter by map")
self.maps_entry.connect("changed", self._on_map_completion, True) self.maps_entry.connect("changed", self._on_map_completion, True)
self.maps_entry.connect("key-press-event", self._on_map_entry_keypress) self.maps_entry.connect("key-press-event", self._on_map_entry_keypress)
self.maps_entry.connect("activate", self._on_maps_activated) self.maps_entry.connect("activate", self._on_maps_activated)
self.maps_combo.pack_start(renderer_text, EXPAND) self.maps_combo.pack_start(renderer_text, expand=True)
self.maps_combo.connect("changed", self._on_map_changed) self.maps_combo.connect("changed", self._on_map_changed)
self.maps_combo.connect("key-press-event", self._on_combo_keypress) self.maps_combo.connect("key-press-event", self._on_combo_keypress)
@@ -211,7 +212,7 @@ class FilterPanel(Gtk.Box):
self.maps_combo, self.maps_combo,
self.button_grid, self.button_grid,
): ):
self.pack_start(el, NO_EXPAND, NO_FILL, NO_PADDING) self.pack_start(el, expand=False, fill=False, padding=0)
def _on_maps_activated(self, entry: Gtk.Entry) -> None: def _on_maps_activated(self, entry: Gtk.Entry) -> None:
text = entry.get_text() text = entry.get_text()
@@ -305,6 +306,7 @@ class FilterPanel(Gtk.Box):
Gdk.KEY_0: 9, Gdk.KEY_0: 9,
Gdk.KEY_minus: 10, Gdk.KEY_minus: 10,
Gdk.KEY_backslash: 11, Gdk.KEY_backslash: 11,
Gdk.KEY_apostrophe: 12,
} }
if keyval not in mappings: if keyval not in mappings:
return False return False
+5 -4
View File
@@ -1,10 +1,11 @@
from typing import Self
from dzgui.util import css
import gi import gi
from typing import Self
from dzgui.util import css
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa from gi.repository import Gtk
# TODO: subclass Gtk.Frame directly # TODO: subclass Gtk.Frame directly
+1 -1
View File
@@ -1,7 +1,7 @@
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402 from gi.repository import Gtk
class Icon(Gtk.Image): class Icon(Gtk.Image):
+1 -1
View File
@@ -3,7 +3,7 @@ from dzgui.util.format import embolden
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402 from gi.repository import Gtk
class BoldLabel(Gtk.Label): class BoldLabel(Gtk.Label):
+1 -1
View File
@@ -1,7 +1,7 @@
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GLib # noqa E402 from gi.repository import Gtk
class MapsCombo(Gtk.EntryCompletion): class MapsCombo(Gtk.EntryCompletion):
Loaded 100 of 181 files, more files were not shown because too many files have changed in this diff. Show more