1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import PopupWindow from "widget/PopupWindow"
import powermenu, { type Action } from "service/powermenu"
import icons from "lib/icons"
import options from "options"
import type Gtk from "gi://Gtk?version=3.0"
const { layout, labels } = options.powermenu
const SysButton = (action: Action, label: string) => Widget.Button({
on_clicked: () => powermenu.action(action),
child: Widget.Box({
vertical: true,
class_name: "system-button",
children: [
Widget.Icon(icons.powermenu[action]),
Widget.Label({
label,
visible: labels.bind(),
}),
],
}),
})
export default () => PopupWindow({
name: "powermenu",
transition: "crossfade",
child: Widget.Box<Gtk.Widget>({
class_name: "powermenu horizontal",
setup: self => self.hook(layout, () => {
self.toggleClassName("box", layout.value === "box")
self.toggleClassName("line", layout.value === "line")
}),
children: layout.bind().as(layout => {
switch (layout) {
case "line": return [
SysButton("shutdown", "Shutdown"),
SysButton("logout", "Log Out"),
SysButton("reboot", "Reboot"),
SysButton("sleep", "Sleep"),
]
case "box": return [
Widget.Box(
{ vertical: true },
SysButton("shutdown", "Shutdown"),
SysButton("logout", "Log Out"),
),
Widget.Box(
{ vertical: true },
SysButton("reboot", "Reboot"),
SysButton("sleep", "Sleep"),
),
]
}
}),
}),
})
|