ags(bar,scripts,i18n): added i18n system(wip), changed some bar stuff and started doing control center

This commit is contained in:
retrozinndev
2025-02-04 12:39:25 -03:00
parent 09692bae90
commit b544f4a45b
32 changed files with 980 additions and 141 deletions
+74
View File
@@ -0,0 +1,74 @@
import { Gdk, Astal, Gtk, Widget } from "astal/gtk3";
import { Clock } from "../widget/bar/Clock";
import { Logo } from "../widget/bar/Logo";
import { CCToggle } from "../widget/bar/CCToggle";
import { Tray } from "../widget/bar/Tray";
import { Workspaces } from "../widget/bar/Workspaces";
import { Audio } from "../widget/bar/Audio";
import { FocusedWindow } from "../widget/bar/FocusedWindow";
//import { Media } from "../widget/bar/Media";
interface BarProps {
monitor: number;
width?: number;
height?: number;
}
export const Bar: Widget.Window = newBar({
monitor: 0
} as BarProps);
function newBar(props: BarProps): Widget.Window {
return new Widget.Window({
className: "bar",
monitor: props.monitor,
namespace: "top-bar",
anchor: Astal.WindowAnchor.TOP,
layer: Astal.Layer.TOP,
exclusivity: Astal.Exclusivity.EXCLUSIVE,
canFocus: false,
visible: true, // Recommendation: set visible to false if you don't want this window to appear on app start
heightRequest: props.height || 0,
widthRequest: props.width || Gdk.Screen.get_default()?.get_monitor_geometry(props.monitor)?.width,
hexpand: false,
vexpand: false,
child: new Widget.Box({
className: "bar-container",
child: new Widget.CenterBox({
className: "bar-centerbox",
expand: true,
homogeneous: false,
startWidget: new Widget.Box({
className: "widgets-left",
homogeneous: false,
halign: Gtk.Align.START,
children: [
Logo(),
Workspaces(),
FocusedWindow()
]
} as Widget.BoxProps),
centerWidget: new Widget.Box({
className: "widgets-center",
homogeneous: false,
halign: Gtk.Align.CENTER,
children: [
Clock(),
/*<Media />*/
]
} as Widget.BoxProps),
endWidget: new Widget.Box({
className: "widgets-right",
homogeneous: false,
halign: Gtk.Align.END,
children: [
Tray(),
Audio(),
CCToggle()
]
} as Widget.BoxProps)
} as Widget.CenterBoxProps)
} as Widget.BoxProps)
} as Widget.WindowProps);
}
-50
View File
@@ -1,50 +0,0 @@
import { Box, CenterBox } from "astal/gtk3/widget";
import { Astal, Gtk } from "astal/gtk3";
import Gdk from "gi://Gdk?version=3.0";
import { Clock } from "../widget/bar/Clock";
import { Logo } from "../widget/bar/Logo";
import { CCToggle } from "../widget/bar/CCToggle";
import { Tray } from "../widget/bar/Tray";
import { Workspaces } from "../widget/bar/Workspaces";
import { Audio } from "../widget/bar/Audio";
import { FocusedWindow } from "../widget/bar/FocusedWindow";
import { Media } from "../widget/bar/Media";
export function Bar(monitor: number = 0, width: (number|undefined) = undefined, height: (number|undefined) = undefined) {
return (
<window className="bar" monitor={ monitor } namespace={ "top-bar" }
anchor={ Astal.WindowAnchor.TOP } layer={ Astal.Layer.TOP }
exclusivity={ Astal.Exclusivity.EXCLUSIVE } canFocus={ false }
heightRequest={ height ? height : 0 }
widthRequest={ width ? width : Gdk.Screen.get_default()?.get_monitor_geometry(monitor)?.width }>
<Box className={ "bar-container" } spacing={ 2 }>
<CenterBox className={ "bar-centerbox" } expand={ true }>
<Box className={ "widgets-left" } vertical={ false }
homogeneous={ false } halign={ Gtk.Align.START }>
<Logo />
<Workspaces />
<FocusedWindow />
</Box>
<Box className={ "widgets-center" } halign={ Gtk.Align.CENTER }
vertical={ false } homogeneous={ false }>
<Clock />
<Media />
</Box>
<Box className={ "widgets-right" } halign={ Gtk.Align.END }
vertical={ false } homogeneous={ false }>
<Tray />
<Audio />
<CCToggle />
</Box>
</CenterBox>
</Box>
</window>
)
}
+31
View File
@@ -0,0 +1,31 @@
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
import { QuickActionsWidget } from "../widget/control-center/QuickActions";
export const ControlCenter: Widget.Window = CC();
export const widgetsBox: Widget.Box = new Widget.Box({
visible: true,
className: "control-center-container",
orientation: Gtk.Orientation.VERTICAL,
children: [
QuickActionsWidget()
]
} as Widget.BoxProps);
widgetsBox.connect("add", (_: Widget.Box, widget: Gtk.Widget) => {
widget.set_size_request(widgetsBox.get_allocated_width(), widget.get_allocated_height());
});
function CC(): Widget.Window {
return new Widget.Window({
className: "control-center",
namespace: "control-center",
canFocus: true,
exclusivity: Astal.Exclusivity.NORMAL,
anchor: Astal.WindowAnchor.RIGHT,
width_request: 450,
height_request: Gdk.Screen.get_default()?.get_monitor_geometry(0)?.height || 800,
monitor: 0,
visible: false,
child: widgetsBox
} as Widget.WindowProps);
}
+58
View File
@@ -0,0 +1,58 @@
import { Astal, Gtk, Widget } from "astal/gtk3";
import { getNotifd, removeNotification } from "../scripts/notification-handler";
import { notifications as popupNotifications } from "../scripts/notification-handler";
import AstalNotifd from "gi://AstalNotifd";
export const FloatingNotifications: Widget.Window = FloatingNotificationsWindow();
let gtkNotificationPopups: Array<Widget.Box> = [];
function FloatingNotificationsWindow(): Widget.Window {
const notificationsBox = new Widget.Box({
className: "notifications",
orientation: Gtk.Orientation.VERTICAL,
homogeneous: false
} as Widget.BoxProps);
getNotifd().connect("notified", () => {
for(let i = 0; i < popupNotifications.length; i++) {
const notification: AstalNotifd.Notification = popupNotifications[i];
gtkNotificationPopups[i] = new Widget.Box({
className: "notification",
homogeneous: false,
children: [
new Widget.Box({
className: "top",
orientation: Gtk.Orientation.HORIZONTAL,
hexpand: true,
vexpand: false,
children: [
new Widget.Label({
className: "app-name",
halign: Gtk.Align.START,
label: notification.appName || "Unknown Application"
} as Widget.LabelProps),
new Widget.Button({
className: "close-button",
onClick: () => removeNotification(notification.id)
} as Widget.ButtonProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps);
}
})
return new Widget.Window({
className: "window floating-notifications",
namespace: "floating-notifications",
canFocus: false,
anchor: Astal.WindowAnchor.RIGHT,
monitor: 0,
layer: Astal.Layer.OVERLAY,
visible: false,
exclusivity: Astal.Exclusivity.NORMAL,
child: notificationsBox
} as Widget.WindowProps);
}
+48
View File
@@ -0,0 +1,48 @@
import { bind } from "astal";
import { Astal, Gtk, Widget } from "astal/gtk3";
import { Time } from "astal/time";
import AstalWp from "gi://AstalWp";
import { Windows } from "../scripts/windows";
export const OSD: Widget.Window = OSDWindow();
function OSDWindow() {
return new Widget.Window({
className: "osd-window",
namespace: "osd",
layer: Astal.Layer.OVERLAY,
anchor: Astal.WindowAnchor.BOTTOM,
canFocus: false,
monitor: 0,
visible: false,
child: new Widget.Box({
className: "osd",
children: [
new Widget.Label({
className: "icon",
label: "󰕾",
css: ".icon { color: white; }"
} as Widget.LabelProps),
new Widget.Box({
className: "volume",
orientation: Gtk.Orientation.VERTICAL,
valign: Gtk.Align.CENTER,
children: [
new Widget.Label({
className: "value",
label: bind(AstalWp.get_default()?.defaultSpeaker!, "volume").as((volume: number) => `${Math.round(volume * 100)}%`),
halign: Gtk.Align.CENTER
} as Widget.LabelProps),
new Widget.LevelBar({
className: "levelbar",
width_request: 120,
value: bind(AstalWp.get_default()?.defaultSpeaker!, "volume").as((volume: number) => Math.round(volume * 100)),
maxValue: 100,
halign: Gtk.Align.CENTER
} as Widget.LevelBarProps)
]
} as Widget.BoxProps)
]
} as Widget.BoxProps)
} as Widget.WindowProps);
}