♻️ ags(control-center/notifhistory): more structured function
This commit is contained in:
@@ -4,21 +4,24 @@ import { HistoryNotification, Notifications } from "../../scripts/notifications"
|
|||||||
import { NotificationWidget } from "../Notification";
|
import { NotificationWidget } from "../Notification";
|
||||||
|
|
||||||
|
|
||||||
export const NotifHistory = () => new Widget.Box({
|
export const NotifHistory = () => {
|
||||||
|
return new Widget.Box({
|
||||||
orientation: Gtk.Orientation.VERTICAL,
|
orientation: Gtk.Orientation.VERTICAL,
|
||||||
className: "history",
|
className: bind(Notifications.getDefault(), "history").as(history => history.length > 0 ? "history" : "history hide"),
|
||||||
visible: bind(Notifications.getDefault(), "history").as(history => history.length > 0),
|
|
||||||
children: [
|
children: [
|
||||||
new Widget.Scrollable({
|
new Widget.Scrollable({
|
||||||
className: "history",
|
className: "history",
|
||||||
hscroll: Gtk.PolicyType.NEVER,
|
hscroll: Gtk.PolicyType.NEVER,
|
||||||
vscroll: Gtk.PolicyType.AUTOMATIC,
|
vscroll: Gtk.PolicyType.AUTOMATIC,
|
||||||
visible: bind(Notifications.getDefault(), "history").as(history => history.length > 0),
|
|
||||||
propagateNaturalHeight: true,
|
propagateNaturalHeight: true,
|
||||||
propagateNaturalWidth: false,
|
propagateNaturalWidth: false,
|
||||||
onDraw: (scrollable) => {
|
onDraw: (scrollable) => {
|
||||||
|
if(!(scrollable.get_child()! as Gtk.Viewport).get_child()) return;
|
||||||
|
|
||||||
scrollable.minContentHeight =
|
scrollable.minContentHeight =
|
||||||
((scrollable.get_child()! as Gtk.Viewport).get_child() as Widget.Box).get_children()?.[0].get_allocation().height || 0;
|
((scrollable.get_child()! as Gtk.Viewport).get_child() as Widget.Box
|
||||||
|
).get_children()?.[0].get_allocation().height
|
||||||
|
|| 0;
|
||||||
},
|
},
|
||||||
child: new Widget.Box({
|
child: new Widget.Box({
|
||||||
className: "notifications",
|
className: "notifications",
|
||||||
@@ -59,3 +62,4 @@ export const NotifHistory = () => new Widget.Box({
|
|||||||
})
|
})
|
||||||
]
|
]
|
||||||
} as Widget.BoxProps);
|
} as Widget.BoxProps);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user