💥 ags(notifications): fix some history size when there's a single notification

This commit is contained in:
retrozinndev
2025-03-23 12:39:35 -03:00
parent b10aa363b2
commit 1a8a54c30a
6 changed files with 31 additions and 43 deletions
-2
View File
@@ -1,7 +1,6 @@
import { Astal, Gtk, Widget } from "astal/gtk3";
import AstalNotifd from "gi://AstalNotifd";
import { Separator } from "./Separator";
import Pango from "gi://Pango";
import { HistoryNotification } from "../scripts/notifications";
import { GLib } from "astal";
@@ -119,7 +118,6 @@ export function NotificationWidget(notification: AstalNotifd.Notification|number
xalign: 0,
truncate: false,
wrap: true,
wrapMode: Pango.WrapMode.WORD,
label: notification.body.replace(/\&/g, "&")
} as Widget.LabelProps)
]
+8 -2
View File
@@ -7,20 +7,26 @@ import { NotificationWidget } from "../Notification";
export const NotifHistory: Gtk.Widget = new Widget.Box({
orientation: Gtk.Orientation.VERTICAL,
className: "history",
expand: true,
visible: bind(Notifications.getDefault(), "history").as(history => history.length > 0),
children: [
new Widget.Scrollable({
className: "history",
hscroll: Gtk.PolicyType.NEVER,
vscroll: Gtk.PolicyType.AUTOMATIC,
expand: true,
visible: bind(Notifications.getDefault(), "history").as(history => history.length > 0),
propagateNaturalHeight: true,
propagateNaturalWidth: false,
onDraw: (scrollable) => {
scrollable.minContentHeight =
((scrollable.get_child()! as Gtk.Viewport).get_child() as Widget.Box).get_children()?.[0].get_allocation().height || 0;
},
child: new Widget.Box({
className: "notifications",
hexpand: true,
orientation: Gtk.Orientation.VERTICAL,
homogeneous: false,
spacing: 4,
valign: Gtk.Align.START,
children: bind(Notifications.getDefault(), "history").as((history: Array<HistoryNotification>) =>
history.map((notification: HistoryNotification) => NotificationWidget(notification,
() => Notifications.getDefault().removeHistory(notification.id))