mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 01:37:18 +02:00
fix: use dedicated copy button
This commit is contained in:
parent
4852e4a31f
commit
b5d9c030dd
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user