From 9e8634d892c559c5b44565a68bf35b13cbcb5572 Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 16 Jan 2025 17:37:00 +0100 Subject: add: gtk3 ts popover example closes #224 closes #157 --- .../gtk3/js/applauncher/widget/Applauncher.tsx | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 examples/gtk3/js/applauncher/widget/Applauncher.tsx (limited to 'examples/gtk3/js/applauncher/widget/Applauncher.tsx') diff --git a/examples/gtk3/js/applauncher/widget/Applauncher.tsx b/examples/gtk3/js/applauncher/widget/Applauncher.tsx new file mode 100644 index 0000000..c7bac68 --- /dev/null +++ b/examples/gtk3/js/applauncher/widget/Applauncher.tsx @@ -0,0 +1,87 @@ +import Apps from "gi://AstalApps" +import { App, Astal, Gdk, Gtk } from "astal/gtk3" +import { Variable } from "astal" + +const MAX_ITEMS = 8 + +function hide() { + App.get_window("launcher")!.hide() +} + +function AppButton({ app }: { app: Apps.Application }) { + return +} + +export default function Applauncher() { + const { CENTER } = Gtk.Align + const apps = new Apps.Apps() + + const text = Variable("") + const list = text(text => apps.fuzzy_query(text).slice(0, MAX_ITEMS)) + const onEnter = () => { + apps.fuzzy_query(text.get())?.[0].launch() + hide() + } + + return text.set("")} + onKeyPressEvent={function (self, event: Gdk.Event) { + if (event.get_keyval()[1] === Gdk.KEY_Escape) + self.hide() + }}> + + + + + + text.set(self.text)} + onActivate={onEnter} + /> + + {list.as(list => list.map(app => ( + + )))} + + l.length === 0)}> + + + + + + + + +} -- cgit v1.2.3