mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 14:42:54 +01:00
fix: use dedicated copy button
This commit is contained in:
1 parent
4852e4a31f
commit
b5d9c030dd
2 files changed
+13
-5
No files matched your search
@@ -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.clip import copy_clipboard
|
||||||
from dzgui.util.format import pluralize
|
from dzgui.util.format import pluralize
|
||||||
@@ -70,18 +70,26 @@ class LargeIconTextButton(IconButton):
|
|||||||
|
|
||||||
|
|
||||||
class ClipboardButton(IconTextButton):
|
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)
|
super().__init__(CLIPBOARD, atomic_buttons.copy)
|
||||||
self.controller = controller
|
self.controller = controller
|
||||||
self.connect("clicked", self._on_button_clicked, func)
|
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:
|
def _on_button_clicked(self, button: Self, func: Callable) -> None:
|
||||||
data = func()
|
data = func()
|
||||||
copy_clipboard(data)
|
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):
|
class WebButton(IconTextButton):
|
||||||
def __init__(self, label: str) -> None:
|
def __init__(self, label: str) -> None:
|
||||||
super().__init__(icon=WEB_BROWSER, label=label)
|
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.util.keys import is_ctrl_mask
|
||||||
from dzgui.views.components.buttons import (
|
from dzgui.views.components.buttons import (
|
||||||
AddButton,
|
AddButton,
|
||||||
ClipboardButton,
|
CopyIpButton,
|
||||||
SteamConnectButton,
|
SteamConnectButton,
|
||||||
)
|
)
|
||||||
from dzgui.views.components.entry import IpEntry, PortEntry
|
from dzgui.views.components.entry import IpEntry, PortEntry
|
||||||
@@ -151,7 +151,7 @@ class FavPanel(Gtk.Frame):
|
|||||||
|
|
||||||
self.fav_button = SteamConnectButton()
|
self.fav_button = SteamConnectButton()
|
||||||
self.fav_button.connect("clicked", self._on_connect_clicked)
|
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:
|
if favorite is None:
|
||||||
self.toggle_buttons(False)
|
self.toggle_buttons(False)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user