From 9e32cd4b61b7a22554d1ac046d685a916a926f3f Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 16 Jan 2025 22:29:13 +1100 Subject: updates: make popup window --- src/modules/updates.tsx | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 src/modules/updates.tsx (limited to 'src/modules/updates.tsx') diff --git a/src/modules/updates.tsx b/src/modules/updates.tsx new file mode 100644 index 0000000..0a8cbea --- /dev/null +++ b/src/modules/updates.tsx @@ -0,0 +1,102 @@ +import { bind, execAsync, Variable } from "astal"; +import { App, Astal, Gtk } from "astal/gtk3"; +import Updates, { Repo as IRepo, Update as IUpdate } from "../services/updates"; +import { MenuItem } from "../utils/widgets"; +import PopupWindow from "../widgets/popupwindow"; + +const constructItem = (label: string, exec: string, quiet = true) => + new MenuItem({ + label, + onActivate() { + App.get_window("updates")?.hide(); + execAsync(exec).catch(e => !quiet && console.error(e)); + }, + }); + +const Update = (update: IUpdate) => { + const menu = new Gtk.Menu(); + menu.append(constructItem("Open info in browser", `xdg-open '${update.url}'`, false)); + menu.append(constructItem("Open info in terminal", `uwsm app -- foot -H pacman -Qi ${update.name}`)); + menu.append(constructItem("Reinstall", `uwsm app -T -- yay -S ${update.name}`)); + menu.append(constructItem("Remove with dependencies", `uwsm app -T -- yay -Rns ${update.name}`)); + + return ( + + ); +}; + +const Repo = (repo: IRepo) => { + const expanded = Variable(false); + + return ( + + + + + {repo.updates.map(Update)} + + + + ); +}; + +const List = () => ( + + {bind(Updates.get_default(), "updateData").as(d => d.repos.map(Repo))} + +); + +export default () => ( + + + +