From 52ab81f4ecff9ba4dc6bd62bfbe0c66c7d145d0c Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 24 Jul 2026 01:56:29 +0900 Subject: [PATCH 1/2] feat: dynamic update on clipboard button click --- dzgui/views/components/buttons.py | 17 ++++++++++++++++- dzgui/views/components/right_panel.py | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/dzgui/views/components/buttons.py b/dzgui/views/components/buttons.py index 92db284..b3299a4 100644 --- a/dzgui/views/components/buttons.py +++ b/dzgui/views/components/buttons.py @@ -1,4 +1,4 @@ -from typing import Callable, Self, TYPE_CHECKING, Union +from typing import Callable, Literal, Self, TYPE_CHECKING, Union from dzgui.util.clip import copy_clipboard from dzgui.util.format import pluralize @@ -66,6 +66,15 @@ class IconButton(Gtk.Button): # self.set_image_position(Gtk.PositionType.RIGHT) self.set_focus_on_click(False) + def swap_icon(self, icon: str) -> None: + start = self.icon.get_margin_start() + end = self.icon.get_margin_end() + alt_icon = Icon(icon, margin_start=start, margin_end=end) + self.set_image(alt_icon) + + def revert_icon(self) -> None: + self.set_image(self.icon) + class IconTextButton(IconButton): def __init__( @@ -99,8 +108,14 @@ class ClipboardButton(IconTextButton): self.set_tooltip_text("Copy to clipboard") def _on_button_clicked(self, button: Self, func: Callable) -> None: + def revert() -> Literal[False]: + self.revert_icon() + return False + + self.swap_icon("object-select-symbolic") data = func() copy_clipboard(data) + GLib.timeout_add(600, revert) # TODO: determine when controller would be passed to this button or drop diff --git a/dzgui/views/components/right_panel.py b/dzgui/views/components/right_panel.py index 2e93488..f38def4 100644 --- a/dzgui/views/components/right_panel.py +++ b/dzgui/views/components/right_panel.py @@ -131,6 +131,7 @@ class RightPanel(Gtk.Box): return self.copying = True version = self.version_label.get_text() + # TODO: strings self.version_label.set_text("Copied!") copy_clipboard(version) GLib.timeout_add_seconds(1, revert) From 64c8b905c442eef727b3e05f41071d2ffba1d85d Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Fri, 24 Jul 2026 02:00:18 +0900 Subject: [PATCH 2/2] chore: add comments --- dzgui/views/components/buttons.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dzgui/views/components/buttons.py b/dzgui/views/components/buttons.py index b3299a4..8674820 100644 --- a/dzgui/views/components/buttons.py +++ b/dzgui/views/components/buttons.py @@ -105,6 +105,7 @@ class ClipboardButton(IconTextButton): self.controller = controller self.connect("clicked", self._on_button_clicked, func) + # TODO: strings self.set_tooltip_text("Copy to clipboard") def _on_button_clicked(self, button: Self, func: Callable) -> None: @@ -123,6 +124,7 @@ class CopyIpButton(ClipboardButton): def __init__(self, controller: Union["Controller", None], func: Callable) -> None: super().__init__(controller, func) + # TODO: strings self.set_tooltip_text("Copy IP to clipboard")