mirror of
https://github.com/aclist/dztui.git
synced 2026-10-25 20:22:37 +01:00
Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
141f96fb9f | ||
|
|
0359aacd54 | ||
|
|
80e127889e | ||
|
|
da98b1d5b1 | ||
|
|
33869158de | ||
|
|
5cb8c68f5c | ||
|
|
2f92c2a44f | ||
|
|
da48834fa7 | ||
|
|
197c2eba06 | ||
|
|
0131ee6f0e |
No files matched your search
+28
-2
@@ -1,10 +1,13 @@
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
from warnings import deprecated
|
||||
|
||||
|
||||
from dzgui.const.constants import APP_NAME
|
||||
from dzgui.const.constants import APP_NAME, STEAM_ICON, STEAM_ICONS_PATH
|
||||
from dzgui.const.enum import Preferences
|
||||
from dzgui.config.query import lookup
|
||||
from dzgui.config.userprefs import UserPrefs
|
||||
@@ -23,7 +26,7 @@ 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
|
||||
from dzgui.util.strings import init, steam_icon_missing
|
||||
|
||||
from dzgui.views.base import App
|
||||
from dzgui.views.dialogs.boot import BootWindow
|
||||
@@ -96,6 +99,28 @@ def copy_bare_configs(config: "Path", resolution: "Path") -> tuple[bool, bool]:
|
||||
return (config_changed, state_changed)
|
||||
|
||||
|
||||
@deprecated("Currently unused")
|
||||
def load_steam_icon(config: Path) -> None:
|
||||
import gi
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk # noqa
|
||||
|
||||
default = lookup(config, Preferences.DEFAULT)
|
||||
icon_path = Path(default).joinpath(STEAM_ICONS_PATH)
|
||||
try:
|
||||
theme = Gtk.IconTheme.get_default()
|
||||
paths = theme.get_search_path()
|
||||
theme.set_search_path(paths + [str(icon_path)])
|
||||
paths = theme.get_search_path()
|
||||
icons = theme.list_icons(None)
|
||||
if STEAM_ICON not in icons:
|
||||
logger.warning(steam_icon_missing)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
logger.warning(e)
|
||||
|
||||
|
||||
def load_gui(version: str, is_debug: bool) -> None:
|
||||
lock = lock_acquire() # noqa
|
||||
|
||||
@@ -143,6 +168,7 @@ def load_gui(version: str, is_debug: bool) -> None:
|
||||
local_coords, latest_release = bootwin.get_results()
|
||||
|
||||
use_miles = lookup(XDG.config, Preferences.DIST)
|
||||
|
||||
prefs = UserPrefs(
|
||||
is_steam_deck=_is_steam_deck,
|
||||
is_game_mode=_is_game_mode,
|
||||
|
||||
@@ -89,6 +89,7 @@ FLATPAK_ROOT_PATH = ".var/app/com.valvesoftware.Steam"
|
||||
FLATPAK_STEAM_PATH = FLATPAK_ROOT_PATH + "/data/Steam"
|
||||
UBUNTU_STEAM_PATH = ".steam/steam"
|
||||
DEBIAN_STEAM_PATH = ".steam/debian-installation"
|
||||
STEAM_ICONS_PATH = "public"
|
||||
|
||||
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
||||
|
||||
|
||||
@@ -111,6 +111,10 @@ class Emitter(GObject.GObject):
|
||||
def check_toggled(self, label: str, state: bool) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||
def servers_timed_out(self) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(object,))
|
||||
def servers_loaded(self, tag: "ServerTab") -> None:
|
||||
pass
|
||||
|
||||
@@ -92,6 +92,7 @@ class ServerModelManager:
|
||||
job = Servers.query_api
|
||||
params = Servers.params
|
||||
servers = []
|
||||
|
||||
with ThreadPoolExecutor() as executor:
|
||||
futures = [executor.submit(job, key, APPID_DAYZ, param) for param in params]
|
||||
for future in as_completed(futures):
|
||||
@@ -414,6 +415,8 @@ class ServerModelManager:
|
||||
# TODO: disable map, keyword, and filter widgets if model is None
|
||||
# signal driven (servers_empty, servers_failed_to_load)
|
||||
|
||||
self.emitter.emit("servers_timed_out")
|
||||
|
||||
if self.preserve_on_fail is False:
|
||||
self.tv.set_model(None)
|
||||
filter_man = self.tv.get_filter_man()
|
||||
|
||||
@@ -17,3 +17,10 @@ fullscreen_eventbox = "This option is not available on Steam Deck."
|
||||
save_button = "Save"
|
||||
|
||||
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."
|
||||
)
|
||||
@@ -70,7 +70,8 @@ checkbox_steam_shortcut = (
|
||||
(
|
||||
"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. "
|
||||
"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 = (
|
||||
|
||||
+1
-11
@@ -7,12 +7,11 @@ from dzgui.const.constants import (
|
||||
APP_NAME,
|
||||
APP_NAME_LOWER,
|
||||
GTK_APP_ID,
|
||||
STEAM_ICON,
|
||||
)
|
||||
from dzgui.const.enum import NotebookPage
|
||||
from dzgui.controllers.emitter import Emitter
|
||||
from dzgui.controllers.mc import Controller
|
||||
from dzgui.util import css, strings
|
||||
from dzgui.util import css
|
||||
from dzgui.util.keys import is_ctrl_mask
|
||||
from dzgui.views.components.connect_panel import ConnectPanel
|
||||
from dzgui.views.components.crumbs import Breadcrumbs
|
||||
@@ -332,13 +331,4 @@ class App(ColorAwareApp, Gtk.Application): # type: ignore
|
||||
) -> None:
|
||||
self.win.halt_proc_and_quit()
|
||||
|
||||
|
||||
MainController = Controller()
|
||||
|
||||
try:
|
||||
theme = Gtk.IconTheme.get_default()
|
||||
icons = theme.list_icons(None)
|
||||
if STEAM_ICON not in icons:
|
||||
logger.warning(strings.steam_icon_missing)
|
||||
except Exception as e:
|
||||
logger.warning(e)
|
||||
@@ -65,6 +65,7 @@ class IconButton(Gtk.Button):
|
||||
self.set_image(self.icon)
|
||||
self.set_image_position(position)
|
||||
self.set_focus_on_click(False)
|
||||
self.set_always_show_image(True)
|
||||
|
||||
def swap_icon(self, icon: str) -> None:
|
||||
start = self.icon.get_margin_start()
|
||||
@@ -162,18 +163,24 @@ class RefreshButton(IconTextButton):
|
||||
self.set_tooltip_text(atomic_buttons.refresh_tooltip)
|
||||
|
||||
self.connect("clicked", self._on_refresh_clicked)
|
||||
emitter.connect("servers_loaded", self.start_decrement)
|
||||
emitter.connect("servers_loaded", self._on_load)
|
||||
emitter.connect("servers_timed_out", self._on_timeout)
|
||||
|
||||
def _on_timeout(self, emitter: "Emitter") -> None:
|
||||
self.is_clicked = True
|
||||
self.start_decrement()
|
||||
|
||||
def _on_load(self, emitter: "Emitter", tab: "ServerTab") -> None:
|
||||
self.start_decrement()
|
||||
|
||||
def _on_refresh_clicked(self, button: Self) -> None:
|
||||
"""Spawned in a thread"""
|
||||
if self.controller.get_active_treeview().is_loaded() is False:
|
||||
return
|
||||
self.is_clicked = True
|
||||
self.controller.refresh_tree()
|
||||
# TODO: get server tab enum
|
||||
# if LAN tab, reload existing entries in place
|
||||
|
||||
def start_decrement(self, emitter: "Emitter", tab: "ServerTab") -> None:
|
||||
def start_decrement(self) -> None:
|
||||
if self.is_clicked is False:
|
||||
return
|
||||
if self.loading:
|
||||
|
||||
@@ -12,6 +12,7 @@ from dzgui.const.constants import (
|
||||
APP_NAME,
|
||||
APP_NAME_LOWER,
|
||||
HERO_PATH,
|
||||
FLATPAK_STEAM_PATH,
|
||||
LEGACY_CONFIG_PATH,
|
||||
)
|
||||
from dzgui.const.boilerplate import config_boilerplate
|
||||
@@ -624,6 +625,12 @@ class ShortcutCreationPage(OptionalPageMixin, EnumeratedWizardPage): # type: ig
|
||||
self.add_start(self.checks_area)
|
||||
self.show_all()
|
||||
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:
|
||||
state = button.get_active()
|
||||
|
||||
@@ -9,6 +9,9 @@ from dzgui.const.constants import (
|
||||
APPID_DAYZ_EXP,
|
||||
APPNAME_DAYZ,
|
||||
APPNAME_DAYZ_EXP_HUMAN,
|
||||
FLATPAK_RUN_CMD,
|
||||
FLATPAK_SANDBOX,
|
||||
FLATPAK_STEAM_PATH,
|
||||
NO_EXPAND,
|
||||
NO_FILL,
|
||||
NO_PADDING,
|
||||
@@ -246,6 +249,27 @@ class ToggleField(Gtk.Box):
|
||||
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
|
||||
print(context)
|
||||
self.controller.update_config(context, cmd)
|
||||
|
||||
|
||||
class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
|
||||
def __init__(self, controller: "Controller"):
|
||||
super().__init__(
|
||||
@@ -274,6 +298,7 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
|
||||
self.player_box.set_halign(Gtk.Align.START)
|
||||
self.player_box.get_children()[0].set_width_chars(30) # type: ignore
|
||||
|
||||
self.flatpak_toggle = FlatpakToggleField(self.controller)
|
||||
self.fullscreen_toggle = ToggleField(
|
||||
self.controller,
|
||||
strings.options.last_used,
|
||||
@@ -309,6 +334,12 @@ class Options(ScrollableMixin, Gtk.ScrolledWindow): # type: ignore
|
||||
[LeftLabel(options.start_tab), start_tab_hbox],
|
||||
[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_exp_version_label = Gtk.Label(label=strings.null)
|
||||
|
||||
@@ -6,7 +6,6 @@ from dzgui.const.constants import (
|
||||
FLATPAK_ROOT_PATH,
|
||||
FLATPAK_RUN_CMD,
|
||||
FLATPAK_SANDBOX,
|
||||
STEAM_CMD,
|
||||
)
|
||||
from dzgui.init import proc
|
||||
|
||||
|
||||
Reference in new issue
Block a user