Compare commits

...

4 Commits

Author SHA1 Message Date
aclist
412f0d3193 chore: clear typehinting errors
Some checks failed
Mirror to Codeberg / mirror-to-codeberg (push) Has been cancelled
2026-06-17 21:42:02 +09:00
aclist
894a9b106d chore: move HBox, VBox classes 2026-06-17 21:41:34 +09:00
aclist
1b0a9c9a69 chore: drop foreground logic 2026-06-17 21:33:49 +09:00
aclist
c4818d2097 fix: name collision between function signature and variable 2026-06-17 21:33:28 +09:00
8 changed files with 51 additions and 64 deletions

View File

@ -71,21 +71,21 @@ def get_local_signatures(version_file: Path) -> dict[str, int]:
for line in lines: for line in lines:
data = line.split(",") data = line.split(",")
_id = data[0] _id = data[0]
_hash = int(data[1]) mod_hash = int(data[1])
hashes[_id] = _hash hashes[_id] = mod_hash
return hashes return hashes
def get_needs_update( def get_needs_update(
version_file: Path, remote_hashes: list[tuple[str, str, int, int]] version_file: Path, remote_hashes: list[tuple[str, str, int, int]]
) -> list[tuple[str, str, int, int]]: ) -> list[tuple[str, str, int, int]]:
local_hashes = get_local_signatures(version_file) local_stamps = get_local_signatures(version_file)
needs_update: list[tuple[str, str, int, int]] = [] needs_update: list[tuple[str, str, int, int]] = []
for title, _id, mod_hash, size in remote_hashes: for title, _id, stamp, size in remote_hashes:
if _id not in local_hashes: if _id not in local_stamps:
needs_update.append((title, _id, mod_hash, size)) needs_update.append((title, _id, stamp, size))
elif _hash != local_hashes[_id]: elif stamp != local_stamps[_id]:
needs_update.append((title, _id, mod_hash, size)) needs_update.append((title, _id, stamp, size))
else: else:
continue continue
return needs_update return needs_update
@ -252,6 +252,7 @@ def subscribe(key: str, mod: int) -> None:
def unsubscribe(key: str, mod: int) -> None: def unsubscribe(key: str, mod: int) -> None:
update_workshop(key, mod, UNSUB_ENDPOINT) update_workshop(key, mod, UNSUB_ENDPOINT)
def gen_shortcut() -> None: def gen_shortcut() -> None:
# TODO: # TODO:
""" """
@ -265,6 +266,7 @@ def gen_shortcut() -> None:
# STEAMID_64 & 0xFFFFFFFF # STEAMID_64 & 0xFFFFFFFF
pass pass
@deprecated("Use subscribe()") @deprecated("Use subscribe()")
def enqueue_mod(client: str, mod: str, appid: int) -> None: def enqueue_mod(client: str, mod: str, appid: int) -> None:
client_args = concat_bash_args(client) client_args = concat_bash_args(client)

View File

@ -523,11 +523,11 @@ class Controller(GObject.GObject):
ind = self.config_man.get_start_tab() ind = self.config_man.get_start_tab()
self.get_servers().notebook.set_current_page(ind) self.get_servers().notebook.set_current_page(ind)
def update_and_load_to_menu(self, raise_window: bool) -> None: def update_and_load_to_menu(self) -> None:
self.connection_man.update_and_connect(raise_window, menu_only=True) self.connection_man.update_and_connect(menu_only=True)
def update_and_connect(self, raise_window: bool) -> None: def update_and_connect(self) -> None:
self.connection_man.update_and_connect(raise_window) self.connection_man.update_and_connect()
def update_status(self) -> None: def update_status(self) -> None:
self.mediator.preconnect.mark_finished() self.mediator.preconnect.mark_finished()

View File

@ -294,7 +294,7 @@ class ConnectionManager:
self.controller.add_to_history(self.history, self.record) self.controller.add_to_history(self.history, self.record)
self.controller.open_page(NotebookPage.SERVERS) self.controller.open_page(NotebookPage.SERVERS)
def _update_mods(self, raise_window: bool, menu_only: bool = False) -> None: def _update_mods(self, menu_only: bool = False) -> None:
prefs = self.controller.get_prefs() prefs = self.controller.get_prefs()
config_man = self.controller.get_config_man() config_man = self.controller.get_config_man()
key = config_man.lookup(Preferences.STEAM) key = config_man.lookup(Preferences.STEAM)
@ -305,10 +305,6 @@ class ConnectionManager:
subscribe(key, int(mod)) subscribe(key, int(mod))
time.sleep(RATE_LIMIT_THRESHOLD) time.sleep(RATE_LIMIT_THRESHOLD)
if raise_window is True:
logger.info("Bringing window to foreground")
GLib.idle_add(self.controller.present_window)
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
@ -331,8 +327,8 @@ class ConnectionManager:
self._connect_steam(menu_only) self._connect_steam(menu_only)
@call_on_thread(waiting_for_mods, show_cancel=True) @call_on_thread(waiting_for_mods, show_cancel=True)
def update_and_connect(self, raise_window: bool, 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(raise_window, menu_only) self._update_mods(menu_only)
else: else:
self._connect_steam(menu_only) self._connect_steam(menu_only)

View File

@ -0,0 +1,25 @@
from typing import Sequence
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk # noqa
class GenericBox(Gtk.Box):
def __init__(self, orientation: Gtk.Orientation, spacing: int = 0) -> None:
super().__init__(orientation=orientation, spacing=spacing)
def extend(self, els: Sequence[Gtk.Widget]) -> None:
for el in els:
self.add(el)
class HBox(GenericBox):
def __init__(self, spacing: int = 0) -> None:
super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=spacing)
class VBox(GenericBox):
def __init__(self, spacing: int = 0) -> None:
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=spacing)

View File

@ -208,6 +208,8 @@ class SteamWorkshopButton(SteamTextButton):
def __init__(self) -> None: def __init__(self) -> None:
super().__init__(label=buttons.workshop) super().__init__(label=buttons.workshop)
self.set_tooltip_text(buttons.workshop_tooltip) self.set_tooltip_text(buttons.workshop_tooltip)
self.set_margin_top(10)
self.set_margin_bottom(10)
class AddButton(IconTextButton): class AddButton(IconTextButton):

View File

@ -3,6 +3,7 @@ from pathlib import Path
from typing import Self, TYPE_CHECKING from typing import Self, TYPE_CHECKING
from dzgui.api.steam import find_user_id from dzgui.api.steam import find_user_id
from dzgui.const.enum import NotebookPage, Preferences from dzgui.const.enum import NotebookPage, Preferences
from dzgui.views.components.box import HBox
from dzgui.views.components.buttons import SteamWorkshopButton from dzgui.views.components.buttons import SteamWorkshopButton
from dzgui.views.components.scrollable import NoOverlayScrolledWindow from dzgui.views.components.scrollable import NoOverlayScrolledWindow
from dzgui.views.trees.tree_mods import ModTreeView from dzgui.views.trees.tree_mods import ModTreeView
@ -36,10 +37,8 @@ class Mods(Gtk.Box):
uid = find_user_id(steam_path) uid = find_user_id(steam_path)
pretty_uid = "" if uid is None else uid pretty_uid = "" if uid is None else uid
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10) hbox = HBox(spacing=10)
workshop_button = SteamWorkshopButton() workshop_button = SteamWorkshopButton()
workshop_button.set_margin_top(10)
workshop_button.set_margin_bottom(10)
workshop_button.connect( workshop_button.connect(
"clicked", lambda _: self.controller.open_user_workshop(pretty_uid) "clicked", lambda _: self.controller.open_user_workshop(pretty_uid)
) )

View File

@ -1,6 +1,6 @@
from __future__ import annotations from __future__ import annotations
from enum import Enum from enum import Enum
from typing import Self, Sequence, TYPE_CHECKING, Union from typing import Self, TYPE_CHECKING, Union
from dzgui.util import css from dzgui.util import css
from dzgui.const.constants import ( from dzgui.const.constants import (
@ -16,6 +16,7 @@ from dzgui.const.constants import (
from dzgui.const.enum import ContextMenuGroup, NotebookPage from dzgui.const.enum import ContextMenuGroup, NotebookPage
from dzgui.managers.offline import OfflineManager from dzgui.managers.offline import OfflineManager
from dzgui.strings import generic, offline from dzgui.strings import generic, offline
from dzgui.views.components.box import HBox, VBox
from dzgui.views.components.buttons import Icon, IconTextButton from dzgui.views.components.buttons import Icon, IconTextButton
from dzgui.views.components.eventbox import InfoEventBox from dzgui.views.components.eventbox import InfoEventBox
from dzgui.views.components.frame import HeadingFrame from dzgui.views.components.frame import HeadingFrame
@ -39,25 +40,6 @@ class FolderError(Enum):
NO_VALID_MISSION = 2 NO_VALID_MISSION = 2
class GenericBox(Gtk.Box):
def __init__(self, orientation: Gtk.Orientation, spacing: int = 0) -> None:
super().__init__(orientation=orientation, spacing=spacing)
def extend(self, els: Sequence[Gtk.Widget]) -> None:
for el in els:
self.add(el)
class HBox(GenericBox):
def __init__(self, spacing: int = 0) -> None:
super().__init__(orientation=Gtk.Orientation.HORIZONTAL, spacing=spacing)
class VBox(GenericBox):
def __init__(self, spacing: int = 0) -> None:
super().__init__(orientation=Gtk.Orientation.VERTICAL, spacing=spacing)
class PageHeading(Gtk.Label): class PageHeading(Gtk.Label):
def __init__(self, label: str) -> None: def __init__(self, label: str) -> None:
super().__init__(label=label, halign=Gtk.Align.CENTER) super().__init__(label=label, halign=Gtk.Align.CENTER)

View File

@ -112,18 +112,6 @@ class PreConnectionAssistant(Gtk.Box):
tooltip_text=preconnect.connect_last_tooltip, tooltip_text=preconnect.connect_last_tooltip,
) )
# TODO: abstract
self.raise_window = Gtk.CheckButton(
label="Foreground DZGUI while downloading",
halign=Gtk.Align.END,
hexpand=True,
valign=Gtk.Align.END,
visible=False,
has_tooltip=True,
sensitive=False,
tooltip_text="Foreground the DZGUI window after mod downloads are queued",
active=True,
)
self.button_box = Gtk.Box( self.button_box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL, orientation=Gtk.Orientation.VERTICAL,
valign=Gtk.Align.END, valign=Gtk.Align.END,
@ -133,8 +121,7 @@ class PreConnectionAssistant(Gtk.Box):
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5)
for button in self.back, self.ok, self.connect_last: for button in self.back, self.ok, self.connect_last:
box.add(button) box.add(button)
for el in self.raise_window, box: self.button_box.add(box)
self.button_box.add(el)
self.back.connect("clicked", self._on_back_clicked) self.back.connect("clicked", self._on_back_clicked)
self.ok.connect("clicked", self._on_ok_clicked) self.ok.connect("clicked", self._on_ok_clicked)
@ -217,8 +204,6 @@ class PreConnectionAssistant(Gtk.Box):
for child in widgets: for child in widgets:
child.set_visible(True) child.set_visible(True)
self.raise_window.set_visible(False)
self.raise_window.set_sensitive(False)
self.ok.set_sensitive(True) self.ok.set_sensitive(True)
self.ok.set_label(preconnect.update_mods) self.ok.set_label(preconnect.update_mods)
@ -230,10 +215,10 @@ class PreConnectionAssistant(Gtk.Box):
self.ok.emit("clicked") self.ok.emit("clicked")
def _on_connect_last_clicked(self, button: Gtk.Button) -> None: def _on_connect_last_clicked(self, button: Gtk.Button) -> None:
self.controller.update_and_load_to_menu(self.raise_window.get_active()) self.controller.update_and_load_to_menu()
def _on_ok_clicked(self, button: Gtk.Button) -> None: def _on_ok_clicked(self, button: Gtk.Button) -> None:
self.controller.update_and_connect(self.raise_window.get_active()) self.controller.update_and_connect()
def _on_back_clicked(self, button: Gtk.Button) -> None: def _on_back_clicked(self, button: Gtk.Button) -> None:
self.controller.open_page(NotebookPage.SERVERS) self.controller.open_page(NotebookPage.SERVERS)
@ -317,10 +302,6 @@ class PreConnectionAssistant(Gtk.Box):
if prereqs.required_space == 0: if prereqs.required_space == 0:
self.ok.set_label(preconnect.connect) self.ok.set_label(preconnect.connect)
self.raise_window.set_visible(False)
else:
self.raise_window.set_visible(True)
self.raise_window.set_sensitive(True)
pretty = number(prereqs.required_space) pretty = number(prereqs.required_space)
suffix = f" Need to download {pretty} MiB of mod updates." suffix = f" Need to download {pretty} MiB of mod updates."