ags: add brightness class, media widget on center-window and more

This commit is contained in:
retrozinndev
2025-02-15 08:24:00 -03:00
parent 2eb2f15db9
commit 6e9f2d4a7d
23 changed files with 441 additions and 268 deletions
@@ -1,60 +0,0 @@
import { Binding } from "astal";
import { Gtk, Widget } from "astal/gtk3";
export interface MoreTileProps {
className?: string | Binding<string | undefined>;
iconName?: string | Binding<string | undefined>;
iconSize?: Gtk.IconSize;
title: string | Binding<string>;
description?: string | Binding<string | undefined>;
defaultToggleState?: boolean;
onToggledOn: Function;
onToggledOff: Function;
onClickMore: Function;
}
export function MoreTile(props: MoreTileProps): Gtk.Widget {
let toggleState: boolean = props?.defaultToggleState !== undefined ?
props.defaultToggleState : false;
const mainEventBox = new Widget.EventBox({
onClick: () => toggleState ? props.onToggledOff() : props.onToggledOn(),
expand: true,
child: new Widget.Box({
className: props?.className || "",
expand: true,
children: [
new Widget.Icon({
iconName: props?.iconName,
visible: props.iconName !== undefined,
iconSize: props.iconSize || Gtk.IconSize.BUTTON
}),
new Widget.Box({
className: "text",
orientation: Gtk.Orientation.VERTICAL,
children: [
new Widget.Label({
className: "title",
label: props.title
} as Widget.LabelProps),
new Widget.Label({
className: "description",
visible: props?.description !== undefined,
label: props?.description
} as Widget.LabelProps)
]
} as Widget.BoxProps),
new Widget.Button({
onClick: () => props.onClickMore(),
child: new Widget.Icon({
iconName: "go-next",
iconSize: Gtk.IconSize.BUTTON
} as Widget.IconProps),
} as Widget.ButtonProps)
]
} as Widget.BoxProps)
} as Widget.EventBoxProps);
return mainEventBox;
}
@@ -1,58 +0,0 @@
import { Binding, Variable } from "astal";
import { Gtk, Widget } from "astal/gtk3";
export interface NormalTileProps {
className?: string | Binding<string | undefined>;
iconName?: string | Binding<string | undefined>;
iconSize?: Gtk.IconSize;
title: string | Binding<string>;
description?: string | Binding<string | undefined>;
toggleState?: boolean | Binding<boolean | undefined>;
onToggledOn: Function;
onToggledOff: Function;
}
export function MoreTile(props: NormalTileProps): Gtk.Widget {
const mainEventBox = new Widget.EventBox({
onClick: () => toggleState ? props.onToggledOff() : props.onToggledOn(),
expand: true,
child: new Widget.Box({
className: props?.className || "",
expand: true,
children: [
new Widget.Icon({
iconName: props?.iconName,
visible: props.iconName !== undefined,
iconSize: props.iconSize || Gtk.IconSize.BUTTON
}),
new Widget.Box({
className: "text",
orientation: Gtk.Orientation.VERTICAL,
children: [
new Widget.Label({
className: "title",
label: props.title
} as Widget.LabelProps),
new Widget.Label({
className: "description",
visible: props?.description !== undefined,
label: props?.description
} as Widget.LabelProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.EventBoxProps);
function toggleOn(): void {
mainEventBox.set_class_name(mainEventBox + "")
props.onToggledOn();
}
function toggleOff(): void {
props.onToggledOff();
}
return mainEventBox;
}
+39
View File
@@ -0,0 +1,39 @@
import { Binding } from "astal";
import { Gtk, Widget } from "astal/gtk3";
export type TileProps = {
className?: string | Binding<string | undefined>;
iconName?: string | Binding<string | undefined>;
visible?: boolean | Binding<boolean | undefined>;
iconSize?: number | Binding<number | undefined>;
title: string | Binding<string>;
description?: string | Binding<string | undefined>;
defaultToggleState?: boolean;
onToggledOn: () => void;
onToggledOff: () => void;
onClickMore?: () => void;
}
export function Tile(props: TileProps): Widget.Box {
const toggleButton = new Gtk.ToggleButton();
toggleButton.set_active(props.defaultToggleState || false);
const moreButton = new Widget.Button({
className: "more",
visible: props.onClickMore
});
return new Widget.Box({
className: (typeof Binding<string | undefined>) === (typeof props.className) ?
(props.className as Binding<string | undefined>).as((clsName: (string|undefined)) =>
`tile ${clsName || ""}`)
:
props.className,
visible: props.visible,
children: [
toggleButton,
moreButton
]
})
}