✨ ags: new window management system, adjustments, use adwaita sans
This commit is contained in:
@@ -4,7 +4,7 @@ import { HistoryNotification, Notifications } from "../../scripts/notifications"
|
||||
import { NotificationWidget } from "../Notification";
|
||||
|
||||
|
||||
export const NotifHistory: Gtk.Widget = new Widget.Box({
|
||||
export const NotifHistory = () => new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
className: "history",
|
||||
visible: bind(Notifications.getDefault(), "history").as(history => history.length > 0),
|
||||
|
||||
@@ -2,20 +2,29 @@ import { timeout, Variable } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import { Page } from "./pages/Page";
|
||||
|
||||
const currentPage = new Variable<Page|undefined>(undefined);
|
||||
const currentPage = new Variable<Page | undefined>(undefined);
|
||||
let pagesInstance: (Widget.Revealer | undefined);
|
||||
|
||||
export const PagesWidget: Widget.Revealer = new Widget.Revealer({
|
||||
revealChild: false,
|
||||
className: "pages",
|
||||
transitionType: Gtk.RevealerTransitionType.SLIDE_DOWN,
|
||||
transitionDuration: 360,
|
||||
child: currentPage((page: (Page|undefined)) =>
|
||||
!page ? new Widget.Box() : page.getPage())
|
||||
} as Widget.RevealerProps);
|
||||
export const PagesWidget = () => {
|
||||
const revealer = new Widget.Revealer({
|
||||
revealChild: false,
|
||||
className: "pages",
|
||||
transitionType: Gtk.RevealerTransitionType.SLIDE_DOWN,
|
||||
transitionDuration: 360,
|
||||
child: currentPage((page: (Page|undefined)) =>
|
||||
!page ? new Widget.Box() : page.getPage())
|
||||
} as Widget.RevealerProps);
|
||||
|
||||
pagesInstance = revealer;
|
||||
|
||||
return revealer;
|
||||
}
|
||||
|
||||
export function showPages(page: Page): void {
|
||||
if(!pagesInstance) return;
|
||||
|
||||
currentPage.set(page);
|
||||
PagesWidget.set_reveal_child(true);
|
||||
pagesInstance.set_reveal_child(true);
|
||||
page.props.onOpen && page.props.onOpen();
|
||||
}
|
||||
|
||||
@@ -24,7 +33,9 @@ export function getPage(): (Page|undefined) {
|
||||
}
|
||||
|
||||
export function togglePage(page: Page): void {
|
||||
if(!PagesWidget.revealChild) {
|
||||
if(!pagesInstance) return;
|
||||
|
||||
if(!pagesInstance.revealChild) {
|
||||
showPages(page);
|
||||
return;
|
||||
}
|
||||
@@ -33,10 +44,12 @@ export function togglePage(page: Page): void {
|
||||
}
|
||||
|
||||
export function hidePages() {
|
||||
PagesWidget.set_reveal_child(false);
|
||||
if(!pagesInstance) return;
|
||||
|
||||
pagesInstance.set_reveal_child(false);
|
||||
if(!currentPage.get()) return;
|
||||
|
||||
timeout(500, () => {
|
||||
timeout(pagesInstance.transitionDuration || 500, () => {
|
||||
if(currentPage.get() && currentPage.get()?.props.onClose)
|
||||
currentPage.get()!.props.onClose!();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ function LogoutButton(): Widget.Button {
|
||||
} as Widget.ButtonProps);
|
||||
}
|
||||
|
||||
export const QuickActions: Widget.Box = new Widget.Box({
|
||||
export const QuickActions = () => new Widget.Box({
|
||||
className: "quickactions",
|
||||
children: [
|
||||
new Widget.Box({
|
||||
|
||||
@@ -2,7 +2,7 @@ import { bind } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import { Wireplumber } from "../../scripts/volume";
|
||||
|
||||
export const Sliders: Gtk.Widget = new Widget.Box({
|
||||
export const Sliders = () => new Widget.Box({
|
||||
className: "sliders",
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
expand: true,
|
||||
@@ -17,6 +17,7 @@ export const Sliders: Gtk.Widget = new Widget.Box({
|
||||
new Widget.Slider({
|
||||
drawValue: false,
|
||||
hexpand: true,
|
||||
setup: (slider) => slider.set_value(Wireplumber.getDefault().getSinkVolume()),
|
||||
value: bind(Wireplumber.getDefault().getDefaultSink(), "volume").as((volume: number) =>
|
||||
Math.floor(volume * 100)),
|
||||
max: Wireplumber.getDefault().getMaxSinkVolume(),
|
||||
@@ -34,6 +35,7 @@ export const Sliders: Gtk.Widget = new Widget.Box({
|
||||
new Widget.Slider({
|
||||
drawValue: false,
|
||||
hexpand: true,
|
||||
setup: (slider) => slider.set_value(Wireplumber.getDefault().getSourceVolume()),
|
||||
value: bind(Wireplumber.getDefault().getDefaultSource(), "volume").as((volume: number) =>
|
||||
Math.floor(volume * 100)),
|
||||
max: Wireplumber.getDefault().getMaxSourceVolume(),
|
||||
|
||||
@@ -3,13 +3,13 @@ import { TileNetwork } from "./tiles/Network";
|
||||
import { TileBluetooth } from "./tiles/Bluetooth";
|
||||
import { TileDND } from "./tiles/DoNotDisturb";
|
||||
|
||||
export const tileList: Array<any> = [
|
||||
export const tileList: Array<() => Gtk.Widget> = [
|
||||
TileNetwork,
|
||||
TileBluetooth,
|
||||
TileDND
|
||||
];
|
||||
|
||||
export function TilesWidget(): Gtk.Widget {
|
||||
export function Tiles(): Gtk.Widget {
|
||||
const tilesFlowBox: Gtk.FlowBox = new Gtk.FlowBox({
|
||||
visible: true,
|
||||
orientation: Gtk.Orientation.HORIZONTAL,
|
||||
@@ -21,13 +21,11 @@ export function TilesWidget(): Gtk.Widget {
|
||||
homogeneous: true,
|
||||
} as Gtk.FlowBox.ConstructorProps);
|
||||
|
||||
tileList.map((item: Gtk.Widget) =>
|
||||
tilesFlowBox.insert(item, -1));
|
||||
tileList.map((item: (() => Gtk.Widget)) =>
|
||||
tilesFlowBox.insert(item(), -1));
|
||||
|
||||
return new Widget.Box({
|
||||
className: "tiles-container",
|
||||
child: tilesFlowBox
|
||||
} as Widget.BoxProps);
|
||||
}
|
||||
|
||||
export const Tiles: Gtk.Widget = TilesWidget();
|
||||
|
||||
@@ -6,7 +6,7 @@ import { togglePage } from "../Pages";
|
||||
import { PageNetwork } from "../pages/Network";
|
||||
import { tr } from "../../../i18n/intl";
|
||||
|
||||
export const TileNetwork = new Widget.Box({
|
||||
export const TileNetwork = () => new Widget.Box({
|
||||
child: Variable.derive([
|
||||
bind(AstalNetwork.get_default(), "primary"),
|
||||
bind(AstalNetwork.get_default(), "wired"),
|
||||
@@ -36,7 +36,7 @@ export const TileNetwork = new Widget.Box({
|
||||
icon: "",
|
||||
iconSize: 16,
|
||||
toggleState: bind(wifi, "enabled")
|
||||
} as TileProps);
|
||||
} as TileProps)();
|
||||
|
||||
} else if(primary === AstalNetwork.Primary.WIRED) {
|
||||
return Tile({
|
||||
@@ -69,7 +69,7 @@ export const TileNetwork = new Widget.Box({
|
||||
internet === AstalNetwork.Internet.CONNECTING
|
||||
|| internet === AstalNetwork.Internet.CONNECTED
|
||||
)
|
||||
} as TileProps);
|
||||
} as TileProps)();
|
||||
}
|
||||
|
||||
return Tile({
|
||||
@@ -82,6 +82,6 @@ export const TileNetwork = new Widget.Box({
|
||||
iconSize: 16,
|
||||
toggleState: bind(wired, "internet").as((internet: AstalNetwork.Internet) =>
|
||||
internet === AstalNetwork.Internet.CONNECTING || internet === AstalNetwork.Internet.CONNECTED)
|
||||
} as TileProps);
|
||||
} as TileProps)();
|
||||
})()
|
||||
} as Widget.BoxProps);
|
||||
|
||||
@@ -15,7 +15,7 @@ export type TileProps = {
|
||||
onClickMore?: () => void;
|
||||
}
|
||||
|
||||
export function Tile(props: TileProps): Widget.EventBox {
|
||||
export function Tile(props: TileProps): (() => Widget.EventBox) {
|
||||
const toggled = new Variable<boolean>(props.toggleState instanceof Binding ?
|
||||
(props.toggleState.get() || false) : (props.toggleState || false));
|
||||
|
||||
@@ -24,7 +24,7 @@ export function Tile(props: TileProps): Widget.EventBox {
|
||||
if(props?.toggleState instanceof Binding)
|
||||
subscription = props.toggleState.subscribe(val => toggled.set(val || false));
|
||||
|
||||
return new Widget.EventBox({
|
||||
return () => new Widget.EventBox({
|
||||
className: toggled().as((state: boolean) =>
|
||||
state ? "tile-eventbox toggled" : "tile-eventbox"),
|
||||
expand: true,
|
||||
@@ -39,7 +39,7 @@ export function Tile(props: TileProps): Widget.EventBox {
|
||||
toggled.set(true);
|
||||
props.onToggledOn && props.onToggledOn();
|
||||
},
|
||||
onDestroy: () => subscription(),
|
||||
onDestroy: () => subscription?.(),
|
||||
child: new Widget.Box({
|
||||
className: (props.className instanceof Binding) ?
|
||||
props.className.as((clsName: (string|undefined)) =>
|
||||
|
||||
Reference in New Issue
Block a user