Compare commits

...
Author SHA1 Message Date
aclist e286f02342 chore: add flatpak toggle test 2026-10-22 12:36:23 +09:00
aclist 9f3c39fdd6 chore: drop unused print statement 2026-10-22 12:35:56 +09:00
aclist 0359aacd54 chore: clear typehinting errors 2026-10-22 12:09:40 +09:00
aclist 80e127889e chore: drop unused import 2026-10-22 12:09:07 +09:00
aclist da98b1d5b1 feat: toggle flatpak client dynamically 2026-10-22 12:08:44 +09:00
aclist 33869158de change: explicitly disable NSG creation on Flatpak 2026-10-22 12:07:59 +09:00
6 changed files with 75 additions and 1 deletions

No files matched your search

+7
View File
@@ -17,3 +17,10 @@ fullscreen_eventbox = "This option is not available on Steam Deck."
save_button = "Save" save_button = "Save"
api_failed = "API validation failed" api_failed = "API validation failed"
flatpak_label = "Flatpak client"
flatpak_standard = "Standard"
flatpak_container = "Containerized (flatpak-spawn --host)"
flatpak_info = (
"Containerized mode is used on certain distributions. May have side effects."
)
+1
View File
@@ -71,6 +71,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."
), ),
) )
checkbox_start_menu = ( checkbox_start_menu = (
+7
View File
@@ -12,6 +12,7 @@ from dzgui.const.constants import (
APP_NAME, APP_NAME,
APP_NAME_LOWER, APP_NAME_LOWER,
HERO_PATH, HERO_PATH,
FLATPAK_STEAM_PATH,
LEGACY_CONFIG_PATH, LEGACY_CONFIG_PATH,
) )
from dzgui.const.boilerplate import config_boilerplate from dzgui.const.boilerplate import config_boilerplate
@@ -624,6 +625,12 @@ class ShortcutCreationPage(OptionalPageMixin, EnumeratedWizardPage): # type: ig
self.add_start(self.checks_area) self.add_start(self.checks_area)
self.show_all() self.show_all()
self.connect("map", self._on_map) self.connect("map", self._on_map)
self.connect("map", self._toggle_checkbox)
def _toggle_checkbox(self, page: "EnumeratedWizardPage") -> None:
if FLATPAK_STEAM_PATH in str(self.steam_path):
self.steam_checkbox.set_active(False)
self.steam_checkbox.set_sensitive(False)
def _on_start_menu_toggled(self, button: Gtk.CheckButton) -> None: def _on_start_menu_toggled(self, button: Gtk.CheckButton) -> None:
state = button.get_active() state = button.get_active()
+30
View File
@@ -9,6 +9,9 @@ from dzgui.const.constants import (
APPID_DAYZ_EXP, APPID_DAYZ_EXP,
APPNAME_DAYZ, APPNAME_DAYZ,
APPNAME_DAYZ_EXP_HUMAN, APPNAME_DAYZ_EXP_HUMAN,
FLATPAK_RUN_CMD,
FLATPAK_SANDBOX,
FLATPAK_STEAM_PATH,
NO_EXPAND, NO_EXPAND,
NO_FILL, NO_FILL,
NO_PADDING, NO_PADDING,
@@ -246,6 +249,26 @@ class ToggleField(Gtk.Box):
el.set_sensitive(state) el.set_sensitive(state)
class FlatpakToggleField(ToggleField):
def __init__(
self,
controller: "Controller",
) -> None:
super().__init__(
controller,
first_option=options.flatpak_standard,
second_option=options.flatpak_container,
context=Preferences.CLIENT,
)
self.add(InfoEventBox(options.flatpak_info, self.controller))
self.controller = controller
self.radio1.connect("toggled", self._on_radio_toggled, Preferences.CLIENT)
def _on_radio_toggled(self, button: Gtk.RadioButton, context: Preferences) -> None:
cmd = FLATPAK_RUN_CMD if self.radio1.get_active() else FLATPAK_SANDBOX
self.controller.update_config(context, cmd)
class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
def __init__(self, controller: "Controller"): def __init__(self, controller: "Controller"):
super().__init__( super().__init__(
@@ -274,6 +297,7 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
self.player_box.set_halign(Gtk.Align.START) self.player_box.set_halign(Gtk.Align.START)
self.player_box.get_children()[0].set_width_chars(30) # type: ignore self.player_box.get_children()[0].set_width_chars(30) # type: ignore
self.flatpak_toggle = FlatpakToggleField(self.controller)
self.fullscreen_toggle = ToggleField( self.fullscreen_toggle = ToggleField(
self.controller, self.controller,
strings.options.last_used, strings.options.last_used,
@@ -309,6 +333,12 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
[LeftLabel(options.start_tab), start_tab_hbox], [LeftLabel(options.start_tab), start_tab_hbox],
[LeftLabel(strings.options.name), self.player_box], [LeftLabel(strings.options.name), self.player_box],
] ]
default = self.controller.query_config(Preferences.DEFAULT)
if FLATPAK_STEAM_PATH in default:
pref_rows.insert(
0,
[LeftLabel(options.flatpak_label), self.flatpak_toggle],
)
self.dayz_version_label = Gtk.Label(label=strings.null) self.dayz_version_label = Gtk.Label(label=strings.null)
self.dayz_exp_version_label = Gtk.Label(label=strings.null) self.dayz_exp_version_label = Gtk.Label(label=strings.null)
+30
View File
@@ -0,0 +1,30 @@
import pytest
from dzgui.const.constants import FLATPAK_RUN_CMD, FLATPAK_SANDBOX
from dzgui.const.enum import Preferences
from dzgui.views.pages.options import FlatpakToggleField
class MockController:
def __init__(self) -> None:
self.command: str
def update_config(self, context: Preferences, cmd: str) -> None:
self.command = cmd
def get_command(self) -> str:
return self.command
@pytest.mark.parametrize("index, expect", [(0, FLATPAK_RUN_CMD), (1, FLATPAK_SANDBOX)])
def test_toggle(index: int, expect: str) -> None:
controller = MockController()
toggle = FlatpakToggleField(controller)
match index:
case 0:
toggle.radio2.set_active(True)
toggle.radio1.set_active(True)
case 1:
toggle.radio1.set_active(True)
toggle.radio2.set_active(True)
assert controller.get_command() == expect
-1
View File
@@ -6,7 +6,6 @@ from dzgui.const.constants import (
FLATPAK_ROOT_PATH, FLATPAK_ROOT_PATH,
FLATPAK_RUN_CMD, FLATPAK_RUN_CMD,
FLATPAK_SANDBOX, FLATPAK_SANDBOX,
STEAM_CMD,
) )
from dzgui.init import proc from dzgui.init import proc