ags(control-center): drop astal variables onDestroy()

This commit is contained in:
retrozinndev
2025-05-11 22:20:21 -03:00
parent 0898e1da17
commit 8eb1fcf648
3 changed files with 46 additions and 42 deletions
+44 -41
View File
@@ -4,9 +4,6 @@ import AstalHyprland from "gi://AstalHyprland";
import { Windows } from "../../windows"; import { Windows } from "../../windows";
import { Wallpaper } from "../../scripts/wallpaper"; import { Wallpaper } from "../../scripts/wallpaper";
const uptime = new Variable<string>("Just turned on").poll(1000,
() => exec("uptime -p").replace(/^up /, "")
);
function LockButton(): Widget.Button { function LockButton(): Widget.Button {
return new Widget.Button({ return new Widget.Button({
@@ -60,41 +57,47 @@ function LogoutButton(): Widget.Button {
} as Widget.ButtonProps); } as Widget.ButtonProps);
} }
export const QuickActions = () => new Widget.Box({ export const QuickActions = () => {
className: "quickactions", const uptime = new Variable<string>("Just turned on").poll(1000,
children: [ () => exec("uptime -p").replace(/^up /, ""));
new Widget.Box({
orientation: Gtk.Orientation.VERTICAL, return new Widget.Box({
halign: Gtk.Align.START, className: "quickactions",
hexpand: true, children: [
className: "left", new Widget.Box({
children: [ orientation: Gtk.Orientation.VERTICAL,
new Widget.Label({ halign: Gtk.Align.START,
className: "hostname", hexpand: true,
xalign: 0, className: "left",
tooltipText: "Host name", children: [
label: GLib.get_host_name() new Widget.Label({
} as Widget.LabelProps), className: "hostname",
new Widget.Label({ xalign: 0,
className: "uptime", tooltipText: "Host name",
xalign: 0, label: GLib.get_host_name()
tooltipText: "Uptime", } as Widget.LabelProps),
label: uptime().as((uptime: string) => `󰥔 ${uptime}`) new Widget.Label({
} as Widget.LabelProps) className: "uptime",
] xalign: 0,
} as Widget.BoxProps), tooltipText: "Uptime",
new Widget.Box({ onDestroy: () => uptime.drop(),
orientation: Gtk.Orientation.HORIZONTAL, label: uptime().as((uptime: string) => `󰥔 ${uptime}`)
className: "right button-row", } as Widget.LabelProps)
halign: Gtk.Align.END, ]
hexpand: true, } as Widget.BoxProps),
children: [ new Widget.Box({
LockButton(), orientation: Gtk.Orientation.HORIZONTAL,
ColorPickerButton(), className: "right button-row",
ScreenshotButton(), halign: Gtk.Align.END,
SelectWallpaperButton(), hexpand: true,
LogoutButton() children: [
] LockButton(),
} as Widget.BoxProps) ColorPickerButton(),
] ScreenshotButton(),
} as Widget.BoxProps); SelectWallpaperButton(),
LogoutButton()
]
} as Widget.BoxProps)
]
} as Widget.BoxProps);
}
+2
View File
@@ -33,6 +33,8 @@ export function PageSound(): Page {
new Widget.Label({ new Widget.Label({
className: "sub-header", className: "sub-header",
label: tr("apps"), label: tr("apps"),
visible: endpoints.filter((ep) => ep.mediaClass === AstalWp.MediaClass.AUDIO_STREAM ||
ep.mediaClass === AstalWp.MediaClass.VIDEO_STREAM).length > 0,
setup: (self) => self.set_alignment(0, .5) setup: (self) => self.set_alignment(0, .5)
} as Widget.LabelProps), } as Widget.LabelProps),
...endpoints.filter((ep) => ep.mediaClass === AstalWp.MediaClass.AUDIO_STREAM || ...endpoints.filter((ep) => ep.mediaClass === AstalWp.MediaClass.AUDIO_STREAM ||
-1
View File
@@ -53,7 +53,6 @@ export function Tile(props: TileProps): (() => Gtk.Widget) {
onClick: () => { onClick: () => {
if(toggled.get()) { if(toggled.get()) {
toggled.set(false); toggled.set(false);
console.log(toggled.get());
props.onToggledOff && props.onToggledOff(); props.onToggledOff && props.onToggledOff();
return; return;
} }