updates
This commit is contained in:
1 parent
95418a6baf
commit
d24d53b6f8
7 files changed
+61
-36
No files matched your search
@@ -1,6 +1,7 @@
|
||||
const WINDOW_NAME = "cliphist";
|
||||
import popupwindow from "./misc/popupwindow.ts";
|
||||
import Gtk from "gi://Gtk?version=3.0";
|
||||
import { MaterialIcon } from "icons";
|
||||
|
||||
type EntryObject = {
|
||||
id: string;
|
||||
@@ -182,32 +183,36 @@ function ClipHistWidget({ width = 500, height = 500, spacing = 12 }) {
|
||||
|
||||
on_change: ({ text }) => {
|
||||
const searchText = (text ?? "").toLowerCase();
|
||||
|
||||
if (searchText === "/clear") {
|
||||
list.children.forEach((item) => {
|
||||
item.destroy();
|
||||
});
|
||||
clipHistItems = [];
|
||||
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --clear`).catch(print);
|
||||
setTimeout(() => {
|
||||
entry.text = "";
|
||||
}, 300);
|
||||
return;
|
||||
}
|
||||
|
||||
list.children.forEach((item) => {
|
||||
item.visible = item.attribute.content.toLowerCase().includes(searchText);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const clearButton = Widget.Button({
|
||||
child: MaterialIcon("delete_forever"),
|
||||
class_name: "clear_button",
|
||||
on_clicked: () => {
|
||||
Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --clear`)
|
||||
.then(() => {
|
||||
repopulate().catch(print);
|
||||
})
|
||||
.catch(print);
|
||||
}
|
||||
});
|
||||
|
||||
const searchBox = Widget.Box({
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
children: [entry, clearButton]
|
||||
});
|
||||
|
||||
return Widget.Box({
|
||||
vertical: true,
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
class_name: "cliphistory_box",
|
||||
margin_top: 14,
|
||||
margin_right: 14,
|
||||
children: [
|
||||
entry,
|
||||
searchBox,
|
||||
Widget.Separator(),
|
||||
Widget.Scrollable({
|
||||
hscroll: "never",
|
||||
|
||||
@@ -33,7 +33,7 @@ const reload = () => {
|
||||
const _reload = () => {
|
||||
if (sideleft?.visible) reload();
|
||||
};
|
||||
Utils.interval(1500, _reload);
|
||||
Utils.interval(15000, _reload);
|
||||
configuration.connect("changed", _reload);
|
||||
App.connect("window-toggled", (_, window_name, visible) => {
|
||||
if (window_name == "sideleft" && visible) reload();
|
||||
|
||||
Reference in new issue
Block a user