From 894a9b106db4a0d70c3fa6a9dea7259f88818b9d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Wed, 17 Jun 2026 21:41:34 +0900 Subject: [PATCH] chore: move HBox, VBox classes --- dzgui/views/components/box.py | 25 +++++++++++++++++++++++++ dzgui/views/components/buttons.py | 2 ++ dzgui/views/pages/mods.py | 5 ++--- dzgui/views/pages/offline.py | 20 +------------------- 4 files changed, 30 insertions(+), 22 deletions(-) create mode 100644 dzgui/views/components/box.py diff --git a/dzgui/views/components/box.py b/dzgui/views/components/box.py new file mode 100644 index 0000000..be64f82 --- /dev/null +++ b/dzgui/views/components/box.py @@ -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) diff --git a/dzgui/views/components/buttons.py b/dzgui/views/components/buttons.py index 63b1986..1e7c32e 100644 --- a/dzgui/views/components/buttons.py +++ b/dzgui/views/components/buttons.py @@ -208,6 +208,8 @@ class SteamWorkshopButton(SteamTextButton): def __init__(self) -> None: super().__init__(label=buttons.workshop) self.set_tooltip_text(buttons.workshop_tooltip) + self.set_margin_top(10) + self.set_margin_bottom(10) class AddButton(IconTextButton): diff --git a/dzgui/views/pages/mods.py b/dzgui/views/pages/mods.py index df13967..b840c11 100644 --- a/dzgui/views/pages/mods.py +++ b/dzgui/views/pages/mods.py @@ -3,6 +3,7 @@ from pathlib import Path from typing import Self, TYPE_CHECKING from dzgui.api.steam import find_user_id 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.scrollable import NoOverlayScrolledWindow from dzgui.views.trees.tree_mods import ModTreeView @@ -36,10 +37,8 @@ class Mods(Gtk.Box): uid = find_user_id(steam_path) 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.set_margin_top(10) - workshop_button.set_margin_bottom(10) workshop_button.connect( "clicked", lambda _: self.controller.open_user_workshop(pretty_uid) ) diff --git a/dzgui/views/pages/offline.py b/dzgui/views/pages/offline.py index ff618a9..e082142 100644 --- a/dzgui/views/pages/offline.py +++ b/dzgui/views/pages/offline.py @@ -16,6 +16,7 @@ from dzgui.const.constants import ( from dzgui.const.enum import ContextMenuGroup, NotebookPage from dzgui.managers.offline import OfflineManager 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.eventbox import InfoEventBox from dzgui.views.components.frame import HeadingFrame @@ -39,25 +40,6 @@ class FolderError(Enum): 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): def __init__(self, label: str) -> None: super().__init__(label=label, halign=Gtk.Align.CENTER)