mirror of
https://github.com/aclist/dztui.git
synced 2026-08-27 10:17:31 +02:00
Merge pull request #337 from aclist/fix/anchor-buttons
fix: wrap main content area in ScrolledWindow
This commit is contained in:
commit
3b69d13817
@ -32,7 +32,10 @@ HEX_GREEN = "#32CD32"
|
||||
HEX_RED = "#FF0000"
|
||||
HEX_ORANGE = "#FFAC1C"
|
||||
|
||||
CARET_DOWN = "go-down-symbolic"
|
||||
CARET_UP = "go-up-symbolic"
|
||||
CLIPBOARD = "edit-copy-symbolic"
|
||||
ERROR = "dialog-error-symbolic"
|
||||
HELP_BUBBLE = "help-about-symbolic"
|
||||
INPUT_KEYBOARD = "input-keyboard-symbolic"
|
||||
LIST_ADD = "list-add-symbolic"
|
||||
@ -41,7 +44,6 @@ SEARCH_ICON = "system-search-symbolic"
|
||||
STEAM_ICON = "steam_tray_mono"
|
||||
VIEW_CONCEAL = "view-conceal-symbolic"
|
||||
VIEW_REVEAL = "view-reveal-symbolic"
|
||||
ERROR = "dialog-error-symbolic"
|
||||
WARNING = "dialog-warning-symbolic"
|
||||
WEB_BROWSER = "web-browser-symbolic"
|
||||
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from typing import Self, TYPE_CHECKING
|
||||
|
||||
from dzgui.const.constants import UDP_PORT
|
||||
from dzgui.const.constants import CARET_DOWN, CARET_UP, UDP_PORT
|
||||
from dzgui.model.servers import ServerModelManager
|
||||
from dzgui.strings import connect_panel
|
||||
from dzgui.util.keys import is_ctrl_mask
|
||||
from dzgui.views.components.buttons import (
|
||||
AddButton,
|
||||
CopyIpButton,
|
||||
Icon,
|
||||
IconButton,
|
||||
SteamConnectButton,
|
||||
)
|
||||
from dzgui.views.components.entry import IpEntry, PortEntry
|
||||
@ -24,6 +26,38 @@ COLS = 1
|
||||
ROWS = 1
|
||||
|
||||
|
||||
class DockButton(IconButton):
|
||||
def __init__(self, child: Gtk.Widget) -> None:
|
||||
super().__init__(CARET_DOWN)
|
||||
|
||||
self.expanded = True
|
||||
self.child = child
|
||||
self.connect("clicked", self._on_click)
|
||||
|
||||
self.collapse_text = "Collapse the connection panel"
|
||||
self.expand_text = "Expand the connection panel"
|
||||
|
||||
self.set_margin_top(10)
|
||||
self.set_tooltip_text(self.collapse_text)
|
||||
|
||||
def collapse(self) -> None:
|
||||
self.set_image(Icon(CARET_UP))
|
||||
self.child.hide()
|
||||
self.set_tooltip_text(self.expand_text)
|
||||
|
||||
def expand(self) -> None:
|
||||
self.set_image(Icon(CARET_DOWN))
|
||||
self.child.show()
|
||||
self.set_tooltip_text(self.collapse_text)
|
||||
|
||||
def _on_click(self, button: Self) -> None:
|
||||
if self.expanded:
|
||||
self.collapse()
|
||||
else:
|
||||
self.expand()
|
||||
self.expanded = not self.expanded
|
||||
|
||||
|
||||
class LanPanel(Gtk.Frame):
|
||||
def __init__(self, controller: "Controller") -> None:
|
||||
super().__init__(margin_top=10, margin_bottom=5)
|
||||
@ -272,12 +306,17 @@ class ConnectPanel(Gtk.Box):
|
||||
emitter = self.controller.get_emitter()
|
||||
emitter.connect("lan_tab_toggled", self._on_lan_tab_toggled)
|
||||
|
||||
self.panel_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self.lan = LanPanel(controller)
|
||||
self.fav = FavPanel(controller)
|
||||
self.add_panel = AddPanel(controller)
|
||||
|
||||
for el in self.lan, self.fav, self.add_panel:
|
||||
self.add(el)
|
||||
self.panel_box.add(el)
|
||||
|
||||
self.add(DockButton(self.panel_box))
|
||||
self.add(self.panel_box)
|
||||
self.lan.set_visible(False)
|
||||
|
||||
def _on_lan_tab_toggled(self, emitter: "Emitter", state: bool) -> None:
|
||||
|
||||
@ -85,9 +85,9 @@ class MaskedTree(Gtk.TreeView):
|
||||
self.store.append([self.icon, item])
|
||||
|
||||
|
||||
class PreConnectionAssistant(Gtk.ScrolledWindow):
|
||||
class PreConnectionAssistant(Gtk.Box):
|
||||
def __init__(self, controller: "Controller") -> None:
|
||||
super().__init__()
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
||||
|
||||
self.controller = controller
|
||||
|
||||
@ -107,7 +107,9 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
||||
)
|
||||
self.ok = Gtk.Button(label=preconnect.update_mods, halign=Gtk.Align.END)
|
||||
self.connect_last = Gtk.Button(
|
||||
label=preconnect.connect_last, halign=Gtk.Align.END, tooltip_text=preconnect.connect_last_tooltip
|
||||
label=preconnect.connect_last,
|
||||
halign=Gtk.Align.END,
|
||||
tooltip_text=preconnect.connect_last_tooltip,
|
||||
)
|
||||
|
||||
# TODO: abstract
|
||||
@ -167,17 +169,17 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
||||
self.tree_frame = HeadingFrame(self.tree_box, preconnect.mods)
|
||||
|
||||
# TODO: abstract into components
|
||||
# TODO: strings
|
||||
self.warning_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.warning_tree = MaskedTree(WARNING)
|
||||
# TODO: strings
|
||||
self.warning_placeholder = Placeholder("No warnings.")
|
||||
self.warning_box.add(self.warning_tree)
|
||||
self.warning_box.add(self.warning_placeholder)
|
||||
self.warning_frame = HeadingFrame(self.warning_box, preconnect.warnings)
|
||||
|
||||
# TODO: strings
|
||||
self.error_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
self.error_tree = MaskedTree(ERROR)
|
||||
# TODO: strings
|
||||
self.error_placeholder = Placeholder("No errors.")
|
||||
self.error_box.add(self.error_tree)
|
||||
self.error_box.add(self.error_placeholder)
|
||||
@ -188,9 +190,13 @@ class PreConnectionAssistant(Gtk.ScrolledWindow):
|
||||
self.box.add(self.tree_frame)
|
||||
self.box.add(self.warning_frame)
|
||||
self.box.add(self.error_frame)
|
||||
self.box.add(self.button_box)
|
||||
|
||||
self.add(self.box)
|
||||
self.scrolled_box = Gtk.ScrolledWindow(
|
||||
vexpand=True, propagate_natural_height=True
|
||||
)
|
||||
self.scrolled_box.add(self.box)
|
||||
self.add(self.scrolled_box)
|
||||
self.add(self.button_box)
|
||||
|
||||
self.connect("key-press-event", self._on_keypress)
|
||||
self.connect("map", self._on_map)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user