fixed: now the launcher is close when coypying the cliphist history

This commit is contained in:
sankalp committed 2025-03-04 16:50:29 +05:45
1 parent 98e5cca19f
commit 7ab89c65f3
2 files changed
+7 -4

No files matched your search

+1
View File
@@ -31,6 +31,7 @@ PACKAGES=(
wl-clipboard wl-clipboard
wf-recorder wf-recorder
libadwaita libadwaita
acpi
adw-gtk-theme adw-gtk-theme
brightnessctl brightnessctl
wlinhibit wlinhibit
+6 -4
View File
@@ -1,7 +1,6 @@
import os import os
import subprocess import subprocess
from typing import List from typing import List
from functools import partial
from fabric import Fabricator from fabric import Fabricator
from fabric.widgets.box import Box from fabric.widgets.box import Box
from fabric.widgets.button import Button from fabric.widgets.button import Button
@@ -80,6 +79,9 @@ class Cliphist(Box):
def handle_search(self, text: str): def handle_search(self, text: str):
self.cliphist_manager.arrange_viewport(query=text) self.cliphist_manager.arrange_viewport(query=text)
def close_launcher(self):
self.launcher.close()
def handle_clear_history(self, *_): def handle_clear_history(self, *_):
GLib.spawn_command_line_async("cliphist wipe") GLib.spawn_command_line_async("cliphist wipe")
self.cliphist_manager.update_cliphist_history() self.cliphist_manager.update_cliphist_history()
@@ -122,7 +124,7 @@ class CliphistManager:
["cliphist", "decode", clip_id], capture_output=True, check=True ["cliphist", "decode", clip_id], capture_output=True, check=True
) )
subprocess.run(["wl-copy"], input=decode_result.stdout, check=True) subprocess.run(["wl-copy"], input=decode_result.stdout, check=True)
self.launcher.close() self.launcher.close_launcher()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
print(f"Error copying clip {clip_id}: {e}") print(f"Error copying clip {clip_id}: {e}")
@@ -167,7 +169,7 @@ class CliphistManager:
button = Button( button = Button(
h_align="start", h_align="start",
name="clip-img-item", name="clip-img-item",
on_clicked=partial(self._on_clip_clicked, item["id"]), on_clicked=lambda _, clip_id=item["id"]: self.copy_clip(clip_id),
) )
button.set_style( button.set_style(
f"background-image: url('{output_file}'); background-size: cover; background-position: center;" f"background-image: url('{output_file}'); background-size: cover; background-position: center;"
@@ -184,7 +186,7 @@ class CliphistManager:
v_align="center", v_align="center",
h_align="start", h_align="start",
), ),
on_clicked=partial(self._on_clip_clicked, item["id"]), on_clicked=lambda _, clip_id=item["id"]: self.copy_clip(clip_id),
name="clip-item", name="clip-item",
) )