nixos-configs/modules/ags/gtk4/widget/styled-box.ts
matt1432 dc410ebf59
All checks were successful
Discord / discord commits (push) Has been skipped
feat(ags): init gtk4 migration attempt
2024-12-31 23:54:29 -05:00

34 lines
882 B
TypeScript

import { astalify, Gtk } from 'astal/gtk4';
import { property, register } from 'astal';
@register({ GTypeName: 'StyledBox' })
class StyledBoxClass extends Gtk.Box {
declare private _css: string | undefined;
declare private _provider: Gtk.CssProvider | undefined;
@property(String)
get css(): string | undefined {
return this._css;
}
set css(value: string) {
if (!this._provider) {
this._provider = new Gtk.CssProvider();
this.get_style_context().add_provider(
this._provider,
Gtk.STYLE_PROVIDER_PRIORITY_USER,
);
}
this._css = value;
this._provider.load_from_string(value);
}
}
export type StyledBox = StyledBoxClass;
export const StyledBox = astalify<
StyledBoxClass,
Gtk.Box.ConstructorProps & { css: string }
>(StyledBoxClass);