Compare commits

...
28 Commits
Author SHA1 Message Date
aclist 5532e4e267 chore: simplify control flow
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
2026-08-13 13:42:51 +09:00
aclist 120703e702 chore: move map count test to pre-config 2026-08-13 13:37:47 +09:00
aclist b31896387a chore: simplify strings 2026-08-13 13:37:21 +09:00
aclist e5bb25cd60 chore: drop forced exception test 2026-08-13 13:32:08 +09:00
aclist e59b7e01fd chore: drop debug message 2026-08-13 13:31:05 +09:00
aclist 7994bf988c chore: clear typehinting errors 2026-08-13 13:27:40 +09:00
aclist 90b1c875df fix: center label in message area 2026-08-13 13:24:48 +09:00
aclist b61e806009 chore: lowercase launch flags for conformity with parser 2026-08-13 13:24:26 +09:00
aclist b46d0614c9 chore: add strings file 2026-08-13 13:24:10 +09:00
aclist c73864d545 fix: unreachable code 2026-08-13 13:23:29 +09:00
aclist 314fed559c chore: drop unused log file metadata 2026-08-13 13:22:41 +09:00
aclist 1c346a6c3c chore: change sort order of CLI args 2026-08-13 13:22:05 +09:00
aclist 65e11ddd03 chore: clear typehinting errors 2026-08-12 05:07:01 +09:00
aclist a1c0592c7d chore: drop unused import 2026-08-12 05:05:28 +09:00
aclist 22c82677cb chore: drop unused import 2026-08-12 05:05:18 +09:00
aclist c5b41346ca chore: drop unused import 2026-08-12 05:04:47 +09:00
aclist c2fc9b2cca feat: test map count at boot 2026-08-12 05:04:28 +09:00
aclist ba9d6e1d3b chore: update strings 2026-08-12 05:04:16 +09:00
aclist be6ab2c9cb feat: test and set map count 2026-08-12 05:04:06 +09:00
aclist 2413dd1f14 feat: dedicated ignore dialog 2026-08-12 05:03:36 +09:00
aclist 9d8d37e110 chore: move ShortHBox to generics
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
2026-08-12 00:54:14 +09:00
aclist fc28d419bf fix: change bool state
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
2026-08-11 22:23:49 +09:00
aclist 095af395f9 feat: dynamic radio sensitivity on steam deck 2026-08-11 22:23:18 +09:00
aclist 4ada06d305 chore: test html escaping in descriptions 2026-08-11 21:44:47 +09:00
aclist 5a0ab92985 chore: add tech debt comment 2026-08-11 21:44:08 +09:00
aclist f2501871ee feat: update dialog on cancel action 2026-08-11 21:43:53 +09:00
aclist cf70182733 feat: unset fav server by button
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
2026-08-09 23:48:17 +09:00
aclist 42feeae8d0 fix: html escape server desc 2026-08-09 21:07:37 +09:00
19 changed files with 264 additions and 98 deletions

No files matched your search

+2 -1
View File
@@ -18,10 +18,10 @@ from dzgui.init.flock import lock_acquire
from dzgui.init.prereqs import has_steam_client
from dzgui.strings import boot
# from dzgui.util.map_count import get_map_count
from dzgui.util.deck import is_steam_deck, is_game_mode
from dzgui.util.dirs import make_parents
from dzgui.util.localize import set_locale
from dzgui.util.map_count import test_map_count
from dzgui.util.redact import RedactionFilter, REDACTION_PATTERNS
from dzgui.util.strings import init
@@ -119,6 +119,7 @@ def load_gui(version: str, is_debug: bool) -> None:
del os.environ["GTK_IM_MODULE"]
if has_new_config(XDG.config) is False:
test_map_count()
migrate_cols_file(XDG.columns)
copy_state_files(xdg_paths["XDG_STATE_HOME"])
# TODO: add logging inside wizard
+1
View File
@@ -38,6 +38,7 @@ HEX_ORANGE = "#FFAC1C"
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"
+8
View File
@@ -402,6 +402,9 @@ class Controller(GObject.GObject):
def get_menu(self) -> "MenuTreeView":
return self.mediator.menu
def unset_fav(self) -> None:
self.config_man.unset_fav()
def has_favorites(self) -> bool:
favs = self.config_man.get_favorites()
if len(favs) < 1:
@@ -459,6 +462,9 @@ class Controller(GObject.GObject):
open_workshop_page(mod, cmd)
def has_note(self) -> bool:
# TODO: get record string, store in memory
# get note by record, get is in favs, etc. store as a block
# this is only used by context mixin
note = self.get_note()
if len(note) > 0:
return True
@@ -473,11 +479,13 @@ class Controller(GObject.GObject):
return self.notes_man.get_note(record)
def add_note(self, note: str) -> None:
# TODO: record should be cached upon creation of dialog
tv = self.get_active_treeview()
record = tv.get_record_string()
self.notes_man.add_note(record, note)
def delete_note(self) -> None:
# TODO: record should be cached upon creation of dialog
tv = self.get_active_treeview()
record = tv.get_record_string()
self.notes_man.delete_note(record)
+8 -2
View File
@@ -5,12 +5,14 @@ import warnings
from dzgui.const.constants import APP_NAME
from dzgui.init.libgi import test_libgi_missing
from dzgui.init.prefix import get_version
from dzgui.util.map_count import set_map_count
from dzgui.util.strings import flags
parser = argparse.ArgumentParser(description=flags.description)
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
parser.add_argument("-d", "--debug", action="store_true", help=flags.debug)
parser.add_argument("-m", "--map", action="store_true", help=flags.map_count)
parser.add_argument("-u", "--uninstall", action="store_true", help=flags.uninstall)
parser.add_argument("-v", "--version", action="store_true", help=flags.version)
args = parser.parse_args()
@@ -24,6 +26,7 @@ def uninstall() -> None:
def main() -> None:
# TODO: isolate single flags
if args.version is True:
print(get_version())
sys.exit(0)
@@ -32,6 +35,9 @@ def main() -> None:
sys.exit(0)
if args.debug is True:
warnings.filterwarnings("default", category=DeprecationWarning)
if args.map is True:
set_map_count()
sys.exit(0)
version = get_version()
+7
View File
@@ -160,6 +160,13 @@ class ConfigManager:
except Exception:
return
def unset_fav(self) -> None:
try:
self.write_config(Preferences.FAV_LBL, "")
self.write_config(Preferences.FAV_SRV, "")
except Exception:
return
def write_config(self, key: Preferences, value: str) -> None:
try:
real_key = self.enum_to_key(key)
+3 -3
View File
@@ -21,11 +21,11 @@ class FilterManager:
strings.filter_3pp: True,
strings.filter_night: True,
strings.filter_full: show_full,
strings.filter_lowpop: True,
strings.filter_nonascii: False,
strings.filter_duplicate: False,
strings.filter_official: True,
strings.filter_nonascii: False,
strings.filter_lowpop: True,
strings.filter_unofficial: True,
strings.filter_duplicate: False,
strings.filter_modded: True,
}
+16
View File
@@ -0,0 +1,16 @@
exit_msg = (
"System map count is not high enough to run DayZ. "
"Please exit and run 'dzgui -m' to update map count."
)
failed_to_parse = (
"Failed to parse system map count.\n"
"This usually indicates that systemd is not installed."
)
failed_to_update = (
"Failed to update system map count.\n"
"Please report the issue upstream and provide the following traceback.\n\n"
"{0}"
)
meets_minimum = "System map count of {0} already meets the minimum."
prompt = "Updated map count will be written to the file {0}."
user_exit = "User exit"
-4
View File
@@ -54,8 +54,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
cpu = get_cpu_model()
version = get_version()
debug = lookup(config, Preferences.DEBUG)
install = lookup(config, Preferences.INSTALL)
default = lookup(config, Preferences.DEFAULT)
steam_path = Path(default)
@@ -79,8 +77,6 @@ def write_diagnostic(config: Path, outfile: Path) -> None:
Kernel: {kernel}
CPU: {cpu}
Debug: {debug}
Auto-install: {install}
Steam path: {steam_redacted}
Workshop path: {workshop_redacted}
+59 -16
View File
@@ -1,28 +1,71 @@
import logging
import subprocess
import sys
import tempfile
import traceback
from pathlib import Path
from dzgui.const.constants import VM_FILE, MIN_COUNT
from dzgui.const.constants import APP_NAME, VM_FILE, MIN_COUNT
from dzgui.util.bash import concat_bash_args
from dzgui.strings import map_count
from dzgui.views.dialogs.early_alert import EarlyIgnoreDialog
logger = logging.getLogger(APP_NAME)
def is_map_count_valid(count: int | None) -> bool:
if count is None:
# NOTE: permit if count was unreadable
return True
return count >= MIN_COUNT
def get_map_count() -> int | None:
path = Path(VM_FILE)
if path.is_file() is False:
try:
count = int(path.read_text())
except Exception as e:
logger.debug(e)
return None
count = int(path.read_text())
return count
# TODO: unfinished
#if count < MIN_COUNT:
# print("needs sudo escalation")
# # pop prompt
# # get response
# set_map_count()
#return count
# TODO: unfinished
def test_map_count() -> None:
count = get_map_count()
if is_map_count_valid(count):
return
msg = map_count.exit_msg
EarlyIgnoreDialog(msg)
def set_map_count() -> None:
count = get_map_count()
if count is None:
print(map_count.failed_to_parse)
return
if is_map_count_valid(count):
msg = map_count.meets_minimum.format(count)
print(msg)
return
conf = "/etc/sysctl.d/dayz.conf"
count = f"vm.max_map_count={MIN_COUNT}"
with open(conf, "w") as f:
f.write(count)
# TODO: use concat_bash_args()
subprocess.run(["/usr/bin/sudo", "sysctl", "-p", conf])
value = f"vm.max_map_count={MIN_COUNT}"
try:
msg = map_count.prompt.format(conf)
print(msg)
with tempfile.NamedTemporaryFile(delete=False) as f:
tmp = f.name
Path(tmp).write_text(value)
mv_cmd = f"sudo mv {tmp} {conf}"
reload_cmd = f"sudo sysctl -p {conf}"
for cmd in mv_cmd, reload_cmd:
args = concat_bash_args(cmd)
subprocess.run([*args])
except Exception as e:
logger.debug(e)
trace = traceback.format_exc()
print(map_count.failed_to_update.format(trace))
except KeyboardInterrupt:
print(map_count.user_exit)
sys.exit(0)
+6 -6
View File
@@ -467,13 +467,15 @@ class Flags:
version: str
uninstall: str
debug: str
map_count: str
flags = Flags(
description="DayZ server browser and mod manager",
version="Print version information",
uninstall="Uninstall data files (use prior to 'pip uninstall')",
debug="Enables developer debugging features",
version="print version information",
uninstall="clean up state/config files",
debug="enable developer debugging features",
map_count="check and update system map count value",
)
@@ -541,9 +543,7 @@ connect_panel = ConnectPanel(
add="Add",
add_con="Add/connect",
placeholder="Enter IP (IP:Query port)",
entry_tooltip=(
"- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"
),
entry_tooltip=("- IP: format as IP:Query port\ne.g. 192.168.1.1:27016"),
add_tooltip="Add to Saved Servers",
connect_tooltip="Connect to this server",
)
+7
View File
@@ -23,3 +23,10 @@ class HBox(GenericBox):
class VBox(GenericBox):
def __init__(self, spacing: int = 0) -> None:
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=spacing)
class ShortHBox(HBox):
def __init__(self, widget: Gtk.Widget) -> None:
super().__init__(spacing=5)
self.set_halign(Gtk.Align.START)
self.pack_start(widget, expand=False, fill=False, padding=0)
+9
View File
@@ -10,6 +10,7 @@ from dzgui.util.strings import (
)
from dzgui.const.constants import (
CLIPBOARD,
CLOSE,
INPUT_KEYBOARD,
LIST_ADD,
REFRESH_ICON,
@@ -128,6 +129,14 @@ class CopyIpButton(ClipboardButton):
self.set_tooltip_text("Copy IP to clipboard")
class CloseButton(IconTextButton):
def __init__(self, label: str) -> None:
super().__init__(icon=CLOSE, label=label)
# TODO: strings
self.set_tooltip_text("Unset this server as favorite")
class WebButton(IconTextButton):
def __init__(self, label: str) -> None:
super().__init__(icon=WEB_BROWSER, label=label)
+24 -5
View File
@@ -6,6 +6,7 @@ from dzgui.strings import connect_panel
from dzgui.util.keys import is_ctrl_mask
from dzgui.views.components.buttons import (
AddButton,
CloseButton,
CopyIpButton,
Icon,
IconButton,
@@ -187,17 +188,27 @@ class FavPanel(Gtk.Frame):
self.fav_button = SteamConnectButton()
self.fav_button.connect("clicked", self._on_connect_clicked)
self.copy_button = CopyIpButton(self.controller, self.get_fav_ip)
# TODO: strings
self.unset_button = CloseButton("Unset")
self.unset_button.connect("clicked", self._on_unset_clicked)
if favorite is None:
self.toggle_buttons(False)
# NOTE: disable vscrollbar to prevent layout jumping behavior
scrollable_label = Gtk.ScrolledWindow(vscrollbar_policy=Gtk.PolicyType.NEVER)
scrollable_label.add(self.fav_label)
self.scrollable_label = Gtk.ScrolledWindow(
vscrollbar_policy=Gtk.PolicyType.NEVER, overlay_scrolling=False
)
self.scrollable_label.add(self.fav_label)
grid = Gtk.Grid(margin=10, vexpand=False, column_spacing=15, row_spacing=5)
grid.attach(scrollable_label, 0, 0, 3, ROWS)
grid.attach(self.scrollable_label, 0, 0, 3, ROWS)
grid.attach_next_to(
self.copy_button, scrollable_label, Gtk.PositionType.RIGHT, COLS, ROWS
self.unset_button, self.scrollable_label, Gtk.PositionType.RIGHT, COLS, ROWS
)
grid.attach_next_to(
self.copy_button, self.unset_button, Gtk.PositionType.RIGHT, COLS, ROWS
)
grid.attach_next_to(
self.fav_button, self.copy_button, Gtk.PositionType.RIGHT, COLS, ROWS
@@ -205,8 +216,16 @@ class FavPanel(Gtk.Frame):
self.add(grid)
def _on_unset_clicked(self, button: Gtk.Button) -> None:
try:
self.controller.unset_fav()
except Exception:
return
self.fav_label.set_text(connect_panel.favs_empty)
self.toggle_buttons(False)
def toggle_buttons(self, state: bool) -> None:
for button in self.fav_button, self.copy_button:
for button in self.fav_button, self.copy_button, self.unset_button:
button.set_sensitive(state)
def _on_connect_clicked(self, button: Gtk.Button) -> None:
+7 -9
View File
@@ -33,15 +33,15 @@ class ButtonGrid(Gtk.Grid):
super().__init__(
halign=Gtk.Align.CENTER, column_spacing=5, column_homogeneous=True
)
row = 1
col = 0
self.controller = controller
self.emitter = controller.get_emitter()
self.checks: list[Gtk.CheckButton] = []
# TODO: use enumerated checks
flowbox = Gtk.FlowBox(
halign=Gtk.Align.CENTER, min_children_per_line=3, max_children_per_line=3
)
for check in defaults.keys():
checkbox = Gtk.CheckButton(label=check)
label = checkbox.get_child()
@@ -51,14 +51,12 @@ class ButtonGrid(Gtk.Grid):
if defaults[check]:
checkbox.set_active(True)
col = col + 1
if col > 3:
row += 1
col = 1
self.attach(checkbox, col, row, 1, 1)
checkbox.connect("toggled", self._on_check_toggled)
flowbox.add(checkbox)
self.checks.append(checkbox)
self.add(flowbox)
def block_toggles(self, state: bool) -> None:
for check in self.checks:
self.controller.suppress_signal(
+19 -10
View File
@@ -10,21 +10,26 @@ gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402
class EarlyAlertDialog(Gtk.MessageDialog):
def __init__(self, string: str) -> None:
class AbortDialog(Gtk.MessageDialog):
def __init__(self, string: str, buttons: Gtk.ButtonsType) -> None:
super().__init__(
title=dialog_header,
text=dialog_error,
transient_for=None,
buttons=Gtk.ButtonsType.OK,
buttons=buttons,
)
msg = textwrap.fill(string, 50)
self.format_secondary_text(msg)
ma = self.get_message_area()
label = ma.get_children()[1] # type: ignore
label.set_justify(Gtk.Justification.CENTER)
aa = self.get_action_area()
aa.set_margin_bottom(20)
# self.action_area.set_margin_bottom(20)
aa.set_layout(Gtk.ButtonBoxStyle.CENTER) # type: ignore
self.outer = self.get_content_area()
self.outer.set_margin_start(30)
self.outer.set_margin_end(30)
@@ -32,26 +37,30 @@ class EarlyAlertDialog(Gtk.MessageDialog):
self.set_default_size(250, 100)
abort = self.get_widget_for_response(Gtk.ResponseType.OK)
ignore = self.get_widget_for_response(Gtk.ResponseType.CANCEL)
if abort is not None and hasattr(abort, "set_label"):
abort.set_label("Exit")
if ignore is not None and hasattr(ignore, "set_label"):
ignore.set_label("Ignore")
self.connect("response", self._on_response)
self.run()
self.destroy()
def _on_response(self, dialog: Self, response: Gtk.ResponseType) -> None:
match response:
case Gtk.ResponseType.OK:
case Gtk.ResponseType.OK | Gtk.ResponseType.DELETE_EVENT:
sys.exit(1)
case Gtk.ResponseType.CANCEL:
return
class EarlyIgnoreDialog(EarlyAlertDialog):
class EarlyAlertDialog(AbortDialog):
def __init__(self, string: str) -> None:
super().__init__(string=string)
super().__init__(string=string, buttons=Gtk.ButtonsType.OK)
# TODO: reverse order
self.add_button("Ignore", Gtk.ResponseType.CANCEL)
# TODO: if exit, sys.exit(1), else pass
class EarlyIgnoreDialog(AbortDialog):
def __init__(self, string: str) -> None:
super().__init__(string=string, buttons=Gtk.ButtonsType.OK_CANCEL)
+7 -1
View File
@@ -107,7 +107,7 @@ class WaitDialog(GenericDialog):
self.cur_job = 1
self.cancel = Gtk.Button(label="Cancel", halign=Gtk.Align.CENTER)
self.cancel.connect("clicked", lambda _: self.controller.set_cancel_event())
self.cancel.connect("clicked", self._on_cancel_clicked)
self.connect("delete-event", lambda widget, event: True)
content = self.get_content_area()
@@ -138,6 +138,11 @@ class WaitDialog(GenericDialog):
self.prog.set_fraction(fraction)
self.cur_job += 1
def _on_cancel_clicked(self, button: Gtk.Button) -> None:
# TODO: strings
GLib.idle_add(self.update_text, "Caught cancel signal, cleaning up")
self.controller.set_cancel_event()
def show_cancel(self, state: bool) -> None:
self.cancel.set_visible(state)
@@ -156,6 +161,7 @@ class QuitDialog(GenericDialog):
self.add_button(strings.exit_app, Gtk.ResponseType.OK)
self.connect("response", self._on_response)
# TODO: superfluous with the above
self.connect("delete-event", self._on_response)
def _on_response(self, dialog: Self, response: Gtk.ResponseType) -> None:
+3 -1
View File
@@ -1,3 +1,4 @@
import html
from typing import Self, TYPE_CHECKING
from dzgui.const.constants import EXPAND, FILL
@@ -65,6 +66,7 @@ class ServerDialog(GenericDialog):
class ServerDetailsDialog(ServerDialog):
def __init__(self, controller: "Controller", details: "Details"):
# TODO: server name should also be packed in details struct
name = controller.get_server_name()
super().__init__(controller, strings.server_details, name, menu=None)
@@ -109,7 +111,7 @@ class ServerDetailsDialog(ServerDialog):
self.view.set_model(self.store)
text = details.description
text = format_hyperlinks(text)
self.description.set_markup(text)
self.description.set_markup(html.escape(text))
self.show_all()
+48 -40
View File
@@ -20,7 +20,8 @@ from dzgui.const.enum import Preferences, ServerTab
from dzgui.strings import errors, options
from dzgui.util import strings, css, open_links
from dzgui.views.components.box import VBox
from dzgui.views.components.box import ShortHBox, VBox
from dzgui.views.components.eventbox import InfoEventBox
from dzgui.views.components.labels import LeftLabel
from dzgui.views.components.buttons import WebButton
from dzgui.views.components.frame import HeadingFrame
@@ -39,11 +40,35 @@ if TYPE_CHECKING:
from dzgui.controllers.emitter import Emitter
class ShortHBox(Gtk.Box):
def __init__(self, widget: Gtk.Widget) -> None:
class ToggleField(Gtk.Box):
def __init__(
self,
controller: "Controller",
first_option: str,
second_option: str,
context: Preferences,
) -> None:
super().__init__(spacing=5, halign=Gtk.Align.START)
self.pack_start(widget, NO_EXPAND, NO_FILL, NO_PADDING)
self.controller = controller
self.context = context
self.radio1 = Gtk.RadioButton.new_with_label(None, first_option)
self.radio2 = Gtk.RadioButton.new_from_widget(self.radio1)
self.radio2.set_label(second_option)
self.pack_start(self.radio1, NO_EXPAND, NO_FILL, NO_PADDING)
self.pack_start(self.radio2, NO_EXPAND, NO_FILL, NO_PADDING)
def set_suboption_active(self, state: bool) -> None:
# NOTE: defer connection of signal until after state is set
self.radio2.set_active(state)
self.radio1.connect("toggled", self._on_radio_toggled, self.context)
def _on_radio_toggled(self, button: Gtk.RadioButton, context: Preferences) -> None:
self.controller.toggle_config(context)
def set_sensitive(self, state: bool) -> None:
for el in self.radio1, self.radio2:
el.set_sensitive(state)
class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
@@ -80,19 +105,26 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
# TODO: make submit field a standalone class
self.player_box.get_children()[0].set_width_chars(30) # type: ignore
self.fullscreen_toggle = self.make_binary_radio(
self.fullscreen_toggle = ToggleField(
self.controller,
strings.options.last_used,
strings.options.always_fs,
Preferences.WINDOW,
)
# TODO: strings
eb = InfoEventBox(
"This option is not available on Steam Deck.", self.controller
)
self.fullscreen_toggle.add(eb)
self.client_combo = ClientCombo()
self.client_combo.connect("changed", self._on_client_changed)
client_hbox = ShortHBox(self.client_combo)
self.distance_toggle = self.make_binary_radio(
strings.options.km, strings.options.mi, Preferences.DIST
self.distance_toggle = ToggleField(
self.controller, strings.options.km, strings.options.mi, Preferences.DIST
)
combo_store = Gtk.ListStore(str, object)
@@ -293,14 +325,6 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
real_cmd = combo.get_model()[_iter][1]
self.controller.update_config(Preferences.CLIENT, real_cmd)
def _on_radio_toggled(self, button: Gtk.RadioButton, context: Preferences) -> None:
try:
self.controller.toggle_config(context)
except Exception:
button.handler_block_by_func(self._on_radio_toggled)
self.populate_settings()
button.handler_unblock_by_func(self._on_radio_toggled)
def _is_valid_text(self, text: str, context: Preferences) -> bool:
if text.isspace():
return False
@@ -344,23 +368,6 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
state = self._is_valid_text(text, context)
button.set_sensitive(state)
def make_binary_radio(
self,
first_option: str,
second_option: str,
context: Preferences,
) -> Gtk.Box:
hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
radio1 = Gtk.RadioButton.new_with_label(None, first_option)
radio2 = Gtk.RadioButton.new_from_widget(radio1)
radio2.set_label(second_option)
radio1.connect("toggled", self._on_radio_toggled, context)
hbox.pack_start(radio1, NO_EXPAND, NO_FILL, NO_PADDING)
hbox.pack_start(radio2, NO_EXPAND, NO_FILL, NO_PADDING)
return hbox
def populate_settings(self) -> None:
prefs = self.controller.get_prefs()
# NOTE: re-check in case file was removed by user between runs
@@ -386,14 +393,15 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
if hasattr(p, "set_text"):
p.set_text(name)
# NOTE: suppress toggle signal until radios are built
self._suppress_toggles(True)
for el, conf_state in [
(self.fullscreen_toggle, config["fullscreen"]),
(self.distance_toggle, config["use_miles"]),
]:
el.get_children()[conf_state].set_active(True)
self._suppress_toggles(False)
fs = config["fullscreen"]
miles = config["use_miles"]
if prefs.is_steam_deck:
self.fullscreen_toggle.set_sensitive(False)
fs = True
self.fullscreen_toggle.set_suboption_active(fs)
self.distance_toggle.set_suboption_active(miles)
# NOTE: disable buttons if no text is set
for field in (
+30
View File
@@ -0,0 +1,30 @@
from dzgui.api.servers import Details
from dzgui.views.dialogs.servers import ServerDetailsDialog
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa E402
class MockController:
def __init__(self) -> None:
self.window = Gtk.Window()
def get_window(self) -> Gtk.Window:
return self.window
def get_server_name(self) -> str:
return "My server"
def get_emitter(self) -> None:
return None
def test_html_escaping() -> None:
text = "<Server description> Game & mods"
details = Details([["0", "1"]], text, True)
controller = MockController()
dialog = ServerDetailsDialog(controller, details)
assert dialog.description.get_text() == text