feat(ags/notifications): add support to actions in floating notifications(popups)

This commit is contained in:
retrozinndev
2025-03-11 16:16:07 -03:00
parent 55a2a9c545
commit 12e4cf58b6
12 changed files with 162 additions and 109 deletions
+54 -1
View File
@@ -1,4 +1,4 @@
import { Widget } from "astal/gtk3";
import { Gtk, Widget } from "astal/gtk3";
import { Page } from "./Page";
import AstalNetwork from "gi://AstalNetwork";
import { bind } from "astal";
@@ -18,6 +18,59 @@ export const PageNetwork = new Page({
} as Widget.ButtonProps)
],
pageChild: () => new Widget.Box({
expand: true,
children: [
new Widget.Box({
className: "devices",
hexpand: true,
orientation: Gtk.Orientation.VERTICAL,
visible: bind(AstalNetwork.get_default().get_client(), "devices").as((devs) => devs.length > 0),
children: bind(AstalNetwork.get_default().get_client(), "devices").as((devices) => [
new Widget.Label({
label: "Devices",
xalign: 0,
className: "sub-header",
} as Widget.LabelProps),
...devices.map(dev => new Widget.Button({
className: "device",
child: new Widget.Label({
className: "interface name",
xalign: 0,
label: dev.interface
} as Widget.LabelProps),
} as Widget.ButtonProps))
])
} as Widget.BoxProps),
new Widget.Box({
className: "wireless-aps",
visible: bind(AstalNetwork.get_default(), "primary").as((primary) => primary === AstalNetwork.Primary.WIFI),
hexpand: true,
orientation: Gtk.Orientation.VERTICAL,
children: AstalNetwork.get_default().wifi ? bind(AstalNetwork.get_default().wifi.get_device(), "accessPoints").as((aps) =>
aps.map(ap => new Widget.Button({
hexpand: true,
onClick: () => console.log("connect to " + ap.get_ssid().toArray().toString()), // TODO I don't have a WiFi board :(
child: new Widget.Box({
hexpand: true,
children: [
new Widget.Icon({
halign: Gtk.Align.START,
className: "icon",
icon: "network-wireless-signal-excellent-symbolic"
} as Widget.IconProps),
new Widget.Label({
className: "ssid",
halign: Gtk.Align.START,
label: ap.ssid.toArray().toString()
} as Widget.LabelProps),
new Widget.Label({
className: "status",
} as Widget.LabelProps)
]
} as Widget.BoxProps)
} as Widget.ButtonProps))) : [],
} as Widget.BoxProps),
]
} as Widget.BoxProps)
});