From b5d9c030dd44766cf7cbf527593792c8a1de415d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Wed, 27 May 2026 15:49:02 +0900 Subject: [PATCH] fix: use dedicated copy button --- dzgui/views/components/buttons.py | 14 +++++++++++--- dzgui/views/components/connect_panel.py | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dzgui/views/components/buttons.py b/dzgui/views/components/buttons.py index c4b3bf2..affcc5b 100644 --- a/dzgui/views/components/buttons.py +++ b/dzgui/views/components/buttons.py @@ -1,4 +1,4 @@ -from typing import Callable, Self, TYPE_CHECKING +from typing import Callable, Self, TYPE_CHECKING, Union from dzgui.util.clip import copy_clipboard from dzgui.util.format import pluralize @@ -70,18 +70,26 @@ class LargeIconTextButton(IconButton): class ClipboardButton(IconTextButton): - def __init__(self, controller: "Controller", func: Callable) -> None: + def __init__(self, controller: Union["Controller", None], func: Callable) -> None: super().__init__(CLIPBOARD, atomic_buttons.copy) self.controller = controller self.connect("clicked", self._on_button_clicked, func) - self.set_tooltip_text("Copy IP to clipboard") + self.set_tooltip_text("Copy to clipboard") def _on_button_clicked(self, button: Self, func: Callable) -> None: data = func() copy_clipboard(data) +# TODO: determine when controller would be passed to this button or drop +class CopyIpButton(ClipboardButton): + def __init__(self, controller: Union["Controller", None], func: Callable) -> None: + super().__init__(controller, func) + + self.set_tooltip_text("Copy IP to clipboard") + + class WebButton(IconTextButton): def __init__(self, label: str) -> None: super().__init__(icon=WEB_BROWSER, label=label) diff --git a/dzgui/views/components/connect_panel.py b/dzgui/views/components/connect_panel.py index 552a9bc..9e0a4c8 100644 --- a/dzgui/views/components/connect_panel.py +++ b/dzgui/views/components/connect_panel.py @@ -6,7 +6,7 @@ from dzgui.strings import connect_panel from dzgui.util.keys import is_ctrl_mask from dzgui.views.components.buttons import ( AddButton, - ClipboardButton, + CopyIpButton, SteamConnectButton, ) from dzgui.views.components.entry import IpEntry, PortEntry @@ -151,7 +151,7 @@ class FavPanel(Gtk.Frame): self.fav_button = SteamConnectButton() self.fav_button.connect("clicked", self._on_connect_clicked) - self.copy_button = ClipboardButton(self.controller, self.get_fav_ip) + self.copy_button = CopyIpButton(self.controller, self.get_fav_ip) if favorite is None: self.toggle_buttons(False)