Files
colorshell/ags/window/FloatingNotifications.ts
T
2025-04-21 15:22:43 -03:00

27 lines
1.1 KiB
TypeScript

import { Astal, Gtk, Widget } from "astal/gtk3";
import { bind } from "astal/binding";
import { Notifications } from "../scripts/notifications";
import { NotificationWidget } from "../widget/Notification";
export const FloatingNotifications = (mon: number) => new Widget.Window({
namespace: "floating-notifications",
canFocus: false,
anchor: Astal.WindowAnchor.TOP | Astal.WindowAnchor.RIGHT,
monitor: mon,
layer: Astal.Layer.OVERLAY,
widthRequest: 450,
exclusivity: Astal.Exclusivity.NORMAL,
child: new Widget.Box({
className: "floating-notifications-container",
orientation: Gtk.Orientation.VERTICAL,
homogeneous: false,
visible: bind(Notifications.getDefault(), "notifications").as(notifs => notifs.length > 0),
children: bind(Notifications.getDefault(), "notifications").as((notifs) =>
notifs.map((item) => NotificationWidget(item,
() => Notifications.getDefault().removeNotification(item),
false, true))
),
} as Widget.BoxProps)
} as Widget.WindowProps);