refactor(ags): prioritise getters when using astal libs
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-29 17:22:55 -05:00
parent 10b70583e0
commit 179e402504
30 changed files with 176 additions and 164 deletions

View file

@ -6,21 +6,23 @@ import AstalHyprland from 'gi://AstalHyprland';
export const get_hyprland_monitor = (monitor: Gdk.Monitor): AstalHyprland.Monitor | undefined => { export const get_hyprland_monitor = (monitor: Gdk.Monitor): AstalHyprland.Monitor | undefined => {
const hyprland = AstalHyprland.get_default(); const hyprland = AstalHyprland.get_default();
const manufacturer = monitor.manufacturer?.replace(',', ''); const manufacturer = monitor.get_manufacturer()?.replace(',', '');
const model = monitor.model?.replace(',', ''); const model = monitor.get_model()?.replace(',', '');
const start = `${manufacturer} ${model}`; const start = `${manufacturer} ${model}`;
return hyprland.get_monitors().find((m) => m.description?.startsWith(start)); return hyprland.get_monitors().find((m) => m.get_description()?.startsWith(start));
}; };
export const get_hyprland_monitor_desc = (monitor: Gdk.Monitor): string => { export const get_hyprland_monitor_desc = (monitor: Gdk.Monitor): string => {
const hyprland = AstalHyprland.get_default(); const hyprland = AstalHyprland.get_default();
const manufacturer = monitor.manufacturer?.replace(',', ''); const manufacturer = monitor.get_manufacturer()?.replace(',', '');
const model = monitor.model?.replace(',', ''); const model = monitor.get_model()?.replace(',', '');
const start = `${manufacturer} ${model}`; const start = `${manufacturer} ${model}`;
return `desc:${hyprland.get_monitors().find((m) => m.description?.startsWith(start))?.description}`; return `desc:${hyprland
.get_monitors()
.find((m) => m.get_description()?.startsWith(start))?.get_description()}`;
}; };
export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => { export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => {
@ -38,7 +40,7 @@ export const get_gdkmonitor_from_desc = (desc: string): Gdk.Monitor => {
}; };
export const get_monitor_desc = (mon: AstalHyprland.Monitor): string => { export const get_monitor_desc = (mon: AstalHyprland.Monitor): string => {
return `desc:${mon.description}`; return `desc:${mon.get_description()}`;
}; };
export const hyprMessage = (message: string) => new Promise<string>(( export const hyprMessage = (message: string) => new Promise<string>((
@ -66,25 +68,25 @@ export const centerCursor = (): void => {
let y: number; let y: number;
const monitor = hyprland.get_focused_monitor(); const monitor = hyprland.get_focused_monitor();
switch (monitor.transform) { switch (monitor.get_transform()) {
case 1: case 1:
x = monitor.x - (monitor.height / 2); x = monitor.get_x() - (monitor.get_height() / 2);
y = monitor.y - (monitor.width / 2); y = monitor.get_y() - (monitor.get_width() / 2);
break; break;
case 2: case 2:
x = monitor.x - (monitor.width / 2); x = monitor.get_x() - (monitor.get_width() / 2);
y = monitor.y - (monitor.height / 2); y = monitor.get_y() - (monitor.get_height() / 2);
break; break;
case 3: case 3:
x = monitor.x + (monitor.height / 2); x = monitor.get_x() + (monitor.get_height() / 2);
y = monitor.y + (monitor.width / 2); y = monitor.get_y() + (monitor.get_width() / 2);
break; break;
default: default:
x = monitor.x + (monitor.width / 2); x = monitor.get_x() + (monitor.get_width() / 2);
y = monitor.y + (monitor.height / 2); y = monitor.get_y() + (monitor.get_height() / 2);
break; break;
} }

View file

@ -18,7 +18,7 @@ interface NotifySendProps {
urgency?: 'low' | 'normal' | 'critical' urgency?: 'low' | 'normal' | 'critical'
} }
const escapeShellArg = (arg: string): string => `'${arg?.replace(/'/g, '\'\\\'\'')}'`; const escapeShellArg = (arg: string | undefined): string => `'${arg?.replace(/'/g, '\'\\\'\'') ?? ''}'`;
export const notifySend = ({ export const notifySend = ({
actions = [], actions = [],

View file

@ -27,7 +27,7 @@ export class AppItem extends Widget.Box {
const icon = ( const icon = (
<icon <icon
icon={this.app.iconName} icon={this.app.get_icon_name()}
css="font-size: 42px; margin-right: 25px;" css="font-size: 42px; margin-right: 25px;"
/> />
); );
@ -36,7 +36,7 @@ export class AppItem extends Widget.Box {
<box vertical> <box vertical>
<label <label
className="title" className="title"
label={app.name} label={app.get_name()}
xalign={0} xalign={0}
truncate truncate
valign={Gtk.Align.CENTER} valign={Gtk.Align.CENTER}
@ -45,7 +45,7 @@ export class AppItem extends Widget.Box {
{app.description !== '' && ( {app.description !== '' && (
<label <label
className="description" className="description"
label={app.description} label={app.get_description()}
wrap wrap
xalign={0} xalign={0}
justify={Gtk.Justification.LEFT} justify={Gtk.Justification.LEFT}

View file

@ -16,10 +16,10 @@ export default () => SortedList({
create_row: (app) => <AppItem app={app} />, create_row: (app) => <AppItem app={app} />,
fzf_options: { fzf_options: {
selector: (app) => app.name + app.executable, selector: (app) => app.get_name() + app.get_executable(),
tiebreakers: [ tiebreakers: [
(a, b) => b.item.frequency - a.item.frequency, (a, b) => b.item.get_frequency() - a.item.get_frequency(),
], ],
}, },
@ -40,11 +40,11 @@ export default () => SortedList({
a.set_visible(true); a.set_visible(true);
b.set_visible(true); b.set_visible(true);
return row2.frequency - row1.frequency; return row2.get_frequency() - row1.get_frequency();
} }
else { else {
const s1 = fzfResults.find((r) => r.item.name === row1.name)?.score ?? 0; const s1 = fzfResults.find((r) => r.item.get_name() === row1.get_name())?.score ?? 0;
const s2 = fzfResults.find((r) => r.item.name === row2.name)?.score ?? 0; const s2 = fzfResults.find((r) => r.item.get_name() === row2.get_name())?.score ?? 0;
a.set_visible(s1 !== 0); a.set_visible(s1 !== 0);
b.set_visible(s2 !== 0); b.set_visible(s2 !== 0);

View file

@ -23,5 +23,6 @@ export const launchApp = (app: AstalApps.Application) => {
.join(' '); .join(' ');
bash(`${exe} &`); bash(`${exe} &`);
app.frequency += 1;
app.set_frequency(app.get_frequency() + 1);
}; };

View file

@ -6,7 +6,7 @@ import { ComboBoxText } from '../misc/subclasses';
export default (devices: AstalWp.Device[]) => devices export default (devices: AstalWp.Device[]) => devices
.sort((a, b) => a.description.localeCompare(b.description)) .sort((a, b) => a.get_description().localeCompare(b.description))
.map((device) => ( .map((device) => (
<box className="stream" vertical> <box className="stream" vertical>
@ -15,19 +15,19 @@ export default (devices: AstalWp.Device[]) => devices
<ComboBoxText <ComboBoxText
setup={(self) => { setup={(self) => {
const profiles = (device.get_profiles() ?? []).sort((a, b) => { const profiles = (device.get_profiles() ?? []).sort((a, b) => {
if (a.description === 'Off') { if (a.get_description() === 'Off') {
return 1; return 1;
} }
else if (b.description === 'Off') { else if (b.get_description() === 'Off') {
return -1; return -1;
} }
else { else {
return a.description.localeCompare(b.description); return a.get_description().localeCompare(b.get_description());
} }
}); });
profiles.forEach((profile) => { profiles.forEach((profile) => {
self.append(profile.index.toString(), profile.description); self.append(profile.get_index().toString(), profile.get_description());
}); });
self.set_active( self.set_active(
@ -38,7 +38,11 @@ export default (devices: AstalWp.Device[]) => devices
}} }}
onChanged={(self) => { onChanged={(self) => {
device.set_active_profile(parseInt(self.activeId)); const activeId = self.get_active_id();
if (activeId) {
device.set_active_profile(parseInt(activeId));
}
}} }}
/> />

View file

@ -11,7 +11,7 @@ export default (streams: AstalWp.Endpoint[]) => {
let group: RadioButton | undefined; let group: RadioButton | undefined;
return streams return streams
.sort((a, b) => a.description.localeCompare(b.description)) .sort((a, b) => a.get_description().localeCompare(b.get_description()))
.map((stream) => ( .map((stream) => (
<box className="stream" vertical> <box className="stream" vertical>
@ -29,14 +29,14 @@ export default (streams: AstalWp.Endpoint[]) => {
self.group = group; self.group = group;
} }
self.active = stream.isDefault; self.active = stream.get_is_default();
self.hook(stream, 'notify::is-default', () => { self.hook(stream, 'notify::is-default', () => {
self.active = stream.isDefault; self.active = stream.get_is_default();
}); });
}} }}
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
stream.isDefault = true; stream.set_is_default(true);
}} }}
/> />
@ -56,12 +56,12 @@ export default (streams: AstalWp.Endpoint[]) => {
valign={Gtk.Align.END} valign={Gtk.Align.END}
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
stream.mute = !stream.mute; stream.set_mute(!stream.get_mute());
}} }}
> >
<icon <icon
icon={bind(stream, 'mute').as((isMuted) => { icon={bind(stream, 'mute').as((isMuted) => {
if (stream.mediaClass === AstalWp.MediaClass.AUDIO_MICROPHONE) { if (stream.get_media_class() === AstalWp.MediaClass.AUDIO_MICROPHONE) {
return isMuted ? return isMuted ?
'audio-input-microphone-muted-symbolic' : 'audio-input-microphone-muted-symbolic' :
'audio-input-microphone-symbolic'; 'audio-input-microphone-symbolic';

View file

@ -7,7 +7,7 @@ import PopupWindow from '../../misc/popup-window';
export default () => { export default () => {
const speaker = AstalWp.get_default()?.audio.default_speaker; const speaker = AstalWp.get_default()?.get_audio()?.get_default_speaker();
if (!speaker) { if (!speaker) {
throw new Error('Could not find default audio devices.'); throw new Error('Could not find default audio devices.');
@ -26,7 +26,7 @@ export default () => {
'right', 'right',
); );
win.visible = !win.visible; win.set_visible(!win.get_visible());
}} }}
> >
<overlay passThrough> <overlay passThrough>

View file

@ -27,7 +27,7 @@ export default () => {
'right', 'right',
); );
win.visible = !win.visible; win.set_visible(!win.get_visible());
}} }}
> >
{bind(bluetooth, 'isPowered').as((isPowered) => { {bind(bluetooth, 'isPowered').as((isPowered) => {
@ -38,7 +38,9 @@ export default () => {
return ( return (
<box> <box>
{bind(bluetooth, 'isConnected').as((isConnected) => { {bind(bluetooth, 'isConnected').as((isConnected) => {
const device = bluetooth.get_devices().find((dev) => dev.connected); const device = bluetooth
.get_devices()
.find((dev) => dev.get_connected());
if (!isConnected || !device) { if (!isConnected || !device) {
return (<icon icon="bluetooth-active-symbolic" />); return (<icon icon="bluetooth-active-symbolic" />);

View file

@ -38,13 +38,13 @@ export default () => {
'right', 'right',
); );
win.visible = !win.visible; win.set_visible(!win.get_visible());
}} }}
setup={(self) => { setup={(self) => {
App.connect('window-toggled', (_, win) => { App.connect('window-toggled', (_, win) => {
if (win.name === 'win-notif-center') { if (win.get_name() === 'win-notif-center') {
self.toggleClassName('toggle-on', win.visible); self.toggleClassName('toggle-on', win.get_visible());
} }
}); });
}} }}

View file

@ -21,13 +21,13 @@ export default () => {
const updateVars = ( const updateVars = (
client: AstalHyprland.Client | null = hyprland.get_focused_client(), client: AstalHyprland.Client | null = hyprland.get_focused_client(),
) => { ) => {
lastFocusedAddress = client ? client.address : null; lastFocusedAddress = client ? client.get_address() : null;
const app = applications.fuzzy_query( const app = applications.fuzzy_query(
client?.class ?? '', client?.get_class() ?? '',
)[0]; )[0];
const icon = app?.iconName; const icon = app?.get_icon_name();
if (icon) { if (icon) {
visibleIcon.set(true); visibleIcon.set(true);
@ -37,7 +37,7 @@ export default () => {
visibleIcon.set(false); visibleIcon.set(false);
} }
focusedTitle.set(client?.title ?? ''); focusedTitle.set(client?.get_title() ?? '');
const id = client?.connect('notify::title', (c) => { const id = client?.connect('notify::title', (c) => {
if (c.get_address() !== lastFocusedAddress) { if (c.get_address() !== lastFocusedAddress) {
c.disconnect(id); c.disconnect(id);

View file

@ -18,10 +18,10 @@ export default () => {
client: AstalHyprland.Client | null = hyprland.get_focused_client(), client: AstalHyprland.Client | null = hyprland.get_focused_client(),
) => { ) => {
const app = applications.fuzzy_query( const app = applications.fuzzy_query(
client?.class ?? '', client?.get_class() ?? '',
)[0]; )[0];
const icon = app?.iconName; const icon = app?.get_icon_name();
if (icon) { if (icon) {
visibleIcon.set(true); visibleIcon.set(true);

View file

@ -28,7 +28,7 @@ export default () => {
'right', 'right',
); );
win.visible = !win.visible; win.set_visible(!win.get_visible());
}} }}
> >
{bind(network, 'primary').as((primary) => { {bind(network, 'primary').as((primary) => {
@ -38,7 +38,7 @@ export default () => {
else if (primary === AstalNetwork.Primary.WIFI) { else if (primary === AstalNetwork.Primary.WIFI) {
const Wifi = network.get_wifi(); const Wifi = network.get_wifi();
if (!Wifi || Wifi.accessPoints.length === 0) { return; } if (!Wifi || Wifi.get_access_points().length === 0) { return; }
return ( return (
<box> <box>

View file

@ -27,13 +27,13 @@ export default () => {
'right', 'right',
); );
win.visible = !win.visible; win.set_visible(!win.get_visible());
}} }}
setup={(self) => { setup={(self) => {
App.connect('window-toggled', (_, win) => { App.connect('window-toggled', (_, win) => {
if (win.name === 'win-notif-center') { if (win.get_name() === 'win-notif-center') {
self.toggleClassName('toggle-on', win.visible); self.toggleClassName('toggle-on', win.get_visible());
} }
}); });
}} }}
@ -41,7 +41,7 @@ export default () => {
<box> <box>
<icon <icon
icon={bind(notifications, 'notifications').as((notifs) => { icon={bind(notifications, 'notifications').as((notifs) => {
if (notifications.dontDisturb) { if (notifications.get_dont_disturb()) {
return 'notification-disabled-symbolic'; return 'notification-disabled-symbolic';
} }
else if (notifs.length > 0) { else if (notifs.length > 0) {

View file

@ -8,7 +8,7 @@ const SKIP_ITEMS = ['.spotify-wrapped'];
const TrayItem = (item: AstalTray.TrayItem) => { const TrayItem = (item: AstalTray.TrayItem) => {
if (item.iconThemePath) { if (item.iconThemePath) {
App.add_icons(item.iconThemePath); App.add_icons(item.get_icon_theme_path());
} }
return ( return (
@ -43,7 +43,7 @@ export default () => {
setup={(self) => { setup={(self) => {
self self
.hook(tray, 'item-added', (_, item: string) => { .hook(tray, 'item-added', (_, item: string) => {
if (itemMap.has(item) || SKIP_ITEMS.includes(tray.get_item(item).title)) { if (itemMap.has(item) || SKIP_ITEMS.includes(tray.get_item(item).get_title())) {
return; return;
} }

View file

@ -89,10 +89,10 @@ export default () => {
.child as Widget.Box) .child as Widget.Box)
.children as Widget.Revealer[]; .children as Widget.Revealer[];
const currentIndex = indicators.findIndex((w) => w.name === currentId); const currentIndex = indicators.findIndex((w) => w.get_name() === currentId);
if (currentIndex >= 0) { if (currentIndex >= 0) {
self.css = `margin-left: ${L_PADDING + (currentIndex * WS_WIDTH)}px`; self.set_css(`margin-left: ${L_PADDING + (currentIndex * WS_WIDTH)}px`);
} }
}; };
@ -123,40 +123,40 @@ export default () => {
<box <box
setup={(self) => { setup={(self) => {
const refresh = () => { const refresh = () => {
(self.children as Widget.Revealer[]).forEach((rev) => { (self.get_children() as Widget.Revealer[]).forEach((rev) => {
rev.reveal_child = false; rev.set_reveal_child(false);
}); });
workspaces.forEach((ws) => { workspaces.forEach((ws) => {
ws.reveal_child = true; ws.set_reveal_child(true);
}); });
}; };
const updateWorkspaces = () => { const updateWorkspaces = () => {
Hyprland.get_workspaces().forEach((ws) => { Hyprland.get_workspaces().forEach((ws) => {
const currentWs = (self.children as Widget.Revealer[]) const currentWs = (self.get_children() as Widget.Revealer[])
.find((ch) => ch.name === ws.id.toString()); .find((ch) => ch.get_name() === ws.get_id().toString());
if (!currentWs && ws.id > 0) { if (!currentWs && ws.get_id() > 0) {
self.add(Workspace({ id: ws.id })); self.add(Workspace({ id: ws.get_id() }));
} }
}); });
// Make sure the order is correct // Make sure the order is correct
workspaces.forEach((workspace, i) => { workspaces.forEach((workspace, i) => {
(workspace.get_parent() as Widget.Box) (workspace.get_parent() as Widget.Box).reorder_child(workspace, i);
.reorder_child(workspace, i);
}); });
}; };
const updateAll = () => { const updateAll = () => {
workspaces = (self.children as Widget.Revealer[]) workspaces = (self.get_children() as Widget.Revealer[])
.filter((ch) => { .filter((ch) => {
return Hyprland.get_workspaces().find((ws) => { return Hyprland.get_workspaces().find((ws) => {
return ws.id.toString() === ch.name; return ws.get_id().toString() === ch.get_name();
}); });
}) })
.sort((a, b) => parseInt(a.name ?? '0') - parseInt(b.name ?? '0')); .sort((a, b) =>
parseInt(a.get_name() ?? '0') - parseInt(b.get_name() ?? '0'));
updateWorkspaces(); updateWorkspaces();
refresh(); refresh();

View file

@ -87,7 +87,7 @@ export default class DeviceWidget extends Widget.Revealer {
dev.pair(); dev.pair();
} }
else { else {
bluetooth.adapter.remove_device(dev); bluetooth.get_adapter()?.remove_device(dev);
} }
}} }}
/> />
@ -111,7 +111,7 @@ export default class DeviceWidget extends Widget.Revealer {
<button <button
cursor="pointer" cursor="pointer"
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
rev.revealChild = !rev.revealChild; rev.set_reveal_child(!rev.get_reveal_child());
}} }}
> >
<box> <box>
@ -155,7 +155,7 @@ export default class DeviceWidget extends Widget.Revealer {
this.dev = dev; this.dev = dev;
this.connect('realize', () => idle(() => { this.connect('realize', () => idle(() => {
this.revealChild = true; this.set_reveal_child(true);
})); }));
}; };
}; };

View file

@ -12,29 +12,29 @@ import DeviceWidget from './device';
const calculateDevSort = (dev: AstalBluetooth.Device) => { const calculateDevSort = (dev: AstalBluetooth.Device) => {
let value = 0; let value = 0;
if (dev.connected) { if (dev.get_connected()) {
value += 1000; value += 1000;
} }
if (dev.paired) { if (dev.get_paired()) {
value += 100; value += 100;
} }
if (dev.blocked) { if (dev.get_blocked()) {
value += 10; value += 10;
} }
if (dev.icon) { if (dev.get_icon()) {
if (dev.icon === 'audio-headset') { if (dev.get_icon() === 'audio-headset') {
value += 9; value += 9;
} }
if (dev.icon === 'audio-headphones') { if (dev.get_icon() === 'audio-headphones') {
value += 8; value += 8;
} }
if (dev.icon === 'audio-card') { if (dev.get_icon() === 'audio-card') {
value += 7; value += 7;
} }
if (dev.icon === 'computer') { if (dev.get_icon() === 'computer') {
value += 6; value += 6;
} }
if (dev.icon === 'phone') { if (dev.get_icon() === 'phone') {
value += 5; value += 5;
} }
} }
@ -58,13 +58,13 @@ export default () => {
setup={(self) => { setup={(self) => {
bluetooth.devices bluetooth.devices
.filter((dev) => dev.name) .filter((dev) => dev.get_name())
.forEach((dev) => { .forEach((dev) => {
self.add(<DeviceWidget dev={dev} />); self.add(<DeviceWidget dev={dev} />);
}); });
self.hook(bluetooth, 'device-added', (_, dev) => { self.hook(bluetooth, 'device-added', (_, dev) => {
if (dev.name) { if (dev.get_name()) {
self.add(<DeviceWidget dev={dev} />); self.add(<DeviceWidget dev={dev} />);
self.invalidate_sort(); self.invalidate_sort();
} }
@ -78,11 +78,11 @@ export default () => {
const devWidget = children.find((ch) => ch.dev === dev); const devWidget = children.find((ch) => ch.dev === dev);
if (devWidget) { if (devWidget) {
devWidget.revealChild = false; devWidget.set_reveal_child(false);
setTimeout(() => { setTimeout(() => {
devWidget.get_parent()?.destroy(); devWidget.get_parent()?.destroy();
}, devWidget.transitionDuration + 100); }, devWidget.get_transition_duration() + 100);
} }
}); });
@ -92,7 +92,7 @@ export default () => {
const sort = calculateDevSort(devB) - calculateDevSort(devA); const sort = calculateDevSort(devB) - calculateDevSort(devA);
return sort !== 0 ? sort : devA.name.localeCompare(devB.name); return sort !== 0 ? sort : devA.get_name().localeCompare(devB.get_name());
}); });
}} }}
/> />
@ -114,7 +114,7 @@ export default () => {
setup={(self) => { setup={(self) => {
self.connect('notify::active', () => { self.connect('notify::active', () => {
bluetooth.adapter?.set_powered(self.active); bluetooth.get_adapter()?.set_powered(self.active);
}); });
}} }}
/> />
@ -133,10 +133,10 @@ export default () => {
self.toggleClassName('active', self.active); self.toggleClassName('active', self.active);
if (self.active) { if (self.active) {
bluetooth.adapter?.start_discovery(); bluetooth.get_adapter()?.start_discovery();
} }
else { else {
bluetooth.adapter?.stop_discovery(); bluetooth.get_adapter()?.stop_discovery();
} }
}} }}
> >

View file

@ -64,7 +64,7 @@ export default (hyprpaper: InstanceType<typeof Process>) => {
onActivate={(self) => { onActivate={(self) => {
AstalGreet.login( AstalGreet.login(
dropdown.get_active_text() ?? '', dropdown.get_active_text() ?? '',
self.text || '', self.get_text() || '',
'Hyprland', 'Hyprland',
(_, res) => { (_, res) => {
try { try {
@ -77,7 +77,7 @@ export default (hyprpaper: InstanceType<typeof Process>) => {
}, 500); }, 500);
} }
catch (error) { catch (error) {
response.label = JSON.stringify(error); response.set_label(JSON.stringify(error));
} }
}, },
); );
@ -94,7 +94,7 @@ export default (hyprpaper: InstanceType<typeof Process>) => {
setup={(self) => { setup={(self) => {
centerCursor(); centerCursor();
setTimeout(() => { setTimeout(() => {
self.visible = true; self.set_visible(true);
password.grab_focus(); password.grab_focus();
}, 1000); }, 1000);
}} }}

View file

@ -43,16 +43,16 @@ export default () => {
const unlock = () => { const unlock = () => {
blurBGs.forEach((b) => { blurBGs.forEach((b) => {
b.css = bgCSS({ b.set_css(bgCSS({
w: b.geometry.w, w: b.geometry.w,
h: 1, h: 1,
}); }));
timeout(transition_duration / 2, () => { timeout(transition_duration / 2, () => {
b.css = bgCSS({ b.set_css(bgCSS({
w: 1, w: 1,
h: 1, h: 1,
}); }));
}); });
}); });
timeout(transition_duration, () => { timeout(transition_duration, () => {
@ -86,8 +86,8 @@ export default () => {
idle(() => { idle(() => {
rev.geometry = { rev.geometry = {
w: monitor.geometry.width, w: monitor.get_geometry().width,
h: monitor.geometry.height, h: monitor.get_geometry().height,
}; };
rev.css = bgCSS({ rev.css = bgCSS({
@ -164,17 +164,17 @@ export default () => {
onRealize={(self) => self.grab_focus()} onRealize={(self) => self.grab_focus()}
onActivate={(self) => { onActivate={(self) => {
self.sensitive = false; self.set_sensitive(false);
AstalAuth.Pam.authenticate(self.text ?? '', (_, task) => { AstalAuth.Pam.authenticate(self.get_text() ?? '', (_, task) => {
try { try {
AstalAuth.Pam.authenticate_finish(task); AstalAuth.Pam.authenticate_finish(task);
unlock(); unlock();
} }
catch (e) { catch (e) {
self.text = ''; self.set_text('');
label.label = (e as Error).message; label.set_label((e as Error).message);
self.sensitive = true; self.set_sensitive(true);
} }
}); });
}} }}

View file

@ -87,7 +87,7 @@ export class PopupWindow extends Widget.Window {
const monitor = this.gdkmonitor ?? const monitor = this.gdkmonitor ??
this.get_display().get_monitor_at_point(alloc.x, alloc.y); this.get_display().get_monitor_at_point(alloc.x, alloc.y);
const transform = get_hyprland_monitor(monitor)?.transform; const transform = get_hyprland_monitor(monitor)?.get_transform();
let width: number; let width: number;

View file

@ -80,9 +80,12 @@ export class SortedList<T> {
this.fzf_results = out; this.fzf_results = out;
list.invalidate_sort(); list.invalidate_sort();
const visibleApplications = list.get_children().filter((row) => row.visible).length; const visibleApplications = list
.get_children()
.filter((row) => row.get_visible())
.length;
placeholder.reveal_child = visibleApplications <= 0; placeholder.set_reveal_child(visibleApplications <= 0);
}) })
.catch(() => { /**/ }); .catch(() => { /**/ });
}; };
@ -134,7 +137,7 @@ export class SortedList<T> {
name={name} name={name}
keymode={Astal.Keymode.ON_DEMAND} keymode={Astal.Keymode.ON_DEMAND}
on_open={() => { on_open={() => {
entry.text = ''; entry.set_text('');
refreshItems(); refreshItems();
centerCursor(); centerCursor();
entry.grab_focus(); entry.grab_focus();

View file

@ -15,7 +15,7 @@ const apCommand = (ap: AstalNetwork.AccessPoint, cmd: string[]): void => {
ap.get_ssid()!, ap.get_ssid()!,
]).catch((e) => notifySend({ ]).catch((e) => notifySend({
title: 'Network', title: 'Network',
iconName: ap.iconName, iconName: ap.get_icon_name(),
body: (e as Error).message, body: (e as Error).message,
actions: [ actions: [
{ {

View file

@ -52,7 +52,7 @@ const NotificationList = () => {
const notif = (self.get_children() as NotifGestureWrapper[]) const notif = (self.get_children() as NotifGestureWrapper[])
.find((ch) => ch.id === id); .find((ch) => ch.id === id);
if (notif?.sensitive) { if (notif?.get_sensitive()) {
notif.slideAway('Right'); notif.slideAway('Right');
} }
}); });

View file

@ -143,7 +143,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
return; return;
} }
revChild.css = side === 'Left' ? slideLeft : slideRight; revChild.set_css(side === 'Left' ? slideLeft : slideRight);
timeout(ANIM_DURATION - 100, () => { timeout(ANIM_DURATION - 100, () => {
rev = this.get_child() as Widget.Revealer | null; rev = this.get_child() as Widget.Revealer | null;
@ -265,21 +265,21 @@ export class NotifGestureWrapper extends Widget.EventBox {
// Slide right // Slide right
if (offset > 0) { if (offset > 0) {
self.css = ` self.set_css(`
opacity: 1; transition: none; opacity: 1; transition: none;
margin-left: ${offset}px; margin-left: ${offset}px;
margin-right: -${offset}px; margin-right: -${offset}px;
`; `);
} }
// Slide left // Slide left
else { else {
offset = Math.abs(offset); offset = Math.abs(offset);
self.css = ` self.set_css(`
opacity: 1; transition: none; opacity: 1; transition: none;
margin-right: ${offset}px; margin-right: ${offset}px;
margin-left: -${offset}px; margin-left: -${offset}px;
`; `);
} }
// Put a threshold on if a click is actually dragging // Put a threshold on if a click is actually dragging
@ -301,7 +301,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
this.slideAway(offset > 0 ? 'Right' : 'Left'); this.slideAway(offset > 0 ? 'Right' : 'Left');
} }
else { else {
self.css = defaultStyle; self.set_css(defaultStyle);
this.dragging = false; this.dragging = false;
this.setCursor('grab'); this.setCursor('grab');
@ -313,9 +313,9 @@ export class NotifGestureWrapper extends Widget.EventBox {
} }
// Reverse of slideAway, so it started at squeeze, then we go to slide // Reverse of slideAway, so it started at squeeze, then we go to slide
self.css = this.slide_in_from === 'Left' ? self.set_css(this.slide_in_from === 'Left' ?
slideLeft : slideLeft :
slideRight; slideRight);
idle(() => { idle(() => {
if (!notifications.get_notification(id)) { if (!notifications.get_notification(id)) {
@ -336,7 +336,7 @@ export class NotifGestureWrapper extends Widget.EventBox {
} }
// Then we go to center // Then we go to center
self.css = defaultStyle; self.set_css(defaultStyle);
if (this.is_popup) { if (this.is_popup) {
timeout(ANIM_DURATION, () => { timeout(ANIM_DURATION, () => {

View file

@ -69,7 +69,7 @@ const setupButton = (self: Gtk.Widget) => {
if (!display) { if (!display) {
return; return;
} }
self.window.set_cursor(Gdk.Cursor.new_from_name( self.get_window()?.set_cursor(Gdk.Cursor.new_from_name(
display, display,
'pointer', 'pointer',
)); ));
@ -80,7 +80,7 @@ const setupButton = (self: Gtk.Widget) => {
if (!display) { if (!display) {
return; return;
} }
self.window.set_cursor(null); self.get_window()?.set_cursor(null);
}); });
}; };
@ -127,7 +127,7 @@ export const Notification = ({
} }
}}*/ }}*/
> >
<box vertical className={`notification ${notifObj.urgency} widget`}> <box vertical className={`notification ${notifObj.get_urgency()} widget`}>
{/* Content */} {/* Content */}
<box> <box>
<NotifIcon notifObj={notifObj} /> <NotifIcon notifObj={notifObj} />
@ -146,8 +146,8 @@ export const Notification = ({
max_width_chars={24} max_width_chars={24}
truncate truncate
wrap wrap
label={notifObj.summary} label={notifObj.get_summary()}
use_markup={notifObj.summary.startsWith('<')} use_markup={notifObj.get_summary().startsWith('<')}
/> />
{/* Time */} {/* Time */}
@ -155,7 +155,7 @@ export const Notification = ({
className="time" className="time"
valign={Gtk.Align.CENTER} valign={Gtk.Align.CENTER}
halign={Gtk.Align.END} halign={Gtk.Align.END}
label={setTime(notifObj.time)} label={setTime(notifObj.get_time())}
/> />
{/* Close button */} {/* Close button */}
@ -180,7 +180,7 @@ export const Notification = ({
hexpand hexpand
use_markup use_markup
xalign={0} xalign={0}
label={notifObj.body} label={notifObj.get_body()}
wrap wrap
/> />
</box> </box>

View file

@ -42,8 +42,8 @@ export default () => {
globalThis.popup_osd = popup; globalThis.popup_osd = popup;
const brightness = Brightness.get_default(); const brightness = Brightness.get_default();
const speaker = AstalWp.get_default()?.audio.default_speaker; const speaker = AstalWp.get_default()?.get_audio()?.get_default_speaker();
const microphone = AstalWp.get_default()?.audio.default_microphone; const microphone = AstalWp.get_default()?.get_audio()?.get_default_microphone();
if (!speaker || !microphone) { if (!speaker || !microphone) {
throw new Error('Could not find default audio devices.'); throw new Error('Could not find default audio devices.');

View file

@ -42,20 +42,20 @@ export default (window: OskWindow) => {
if (tablet.oskState) { if (tablet.oskState) {
window.setSlideDown(); window.setSlideDown();
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom ${ANIM_DURATION}ms cubic-bezier(0.36, 0, 0.66, -0.56); transition: margin-bottom ${ANIM_DURATION}ms cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: 0px; margin-bottom: 0px;
`; `);
} }
else { else {
releaseAllKeys(); releaseAllKeys();
window.setSlideUp(); window.setSlideUp();
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom ${ANIM_DURATION}ms cubic-bezier(0.36, 0, 0.66, -0.56); transition: margin-bottom ${ANIM_DURATION}ms cubic-bezier(0.36, 0, 0.66, -0.56);
margin-bottom: -${calculatedHeight}px; margin-bottom: -${calculatedHeight}px;
`; `);
} }
}); });
@ -91,23 +91,23 @@ export default (window: OskWindow) => {
const offset = window.startY - currentY; const offset = window.startY - currentY;
if (offset < 0) { if (offset < 0) {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: -${calculatedHeight}px; margin-bottom: -${calculatedHeight}px;
`; `);
return; return;
} }
if (offset > calculatedHeight) { if (offset > calculatedHeight) {
window.get_child().css = ` window.get_child().set_css(`
margin-bottom: 0px; margin-bottom: 0px;
`; `);
} }
else { else {
window.get_child().css = ` window.get_child().set_css(`
margin-bottom: ${offset - calculatedHeight}px; margin-bottom: ${offset - calculatedHeight}px;
`; `);
} }
}); });
}), }),
@ -125,17 +125,17 @@ export default (window: OskWindow) => {
const offset = window.startY - currentY; const offset = window.startY - currentY;
if (offset > calculatedHeight) { if (offset > calculatedHeight) {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: 0px; margin-bottom: 0px;
`; `);
tablet.oskState = true; tablet.oskState = true;
} }
else { else {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: -${calculatedHeight}px; margin-bottom: -${calculatedHeight}px;
`; `);
} }
window.startY = null; window.startY = null;
@ -172,17 +172,17 @@ export default (window: OskWindow) => {
const offset = window.startY - currentY; const offset = window.startY - currentY;
if (offset > 0) { if (offset > 0) {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: 0px; margin-bottom: 0px;
`; `);
return; return;
} }
window.get_child().css = ` window.get_child().set_css(`
margin-bottom: ${offset}px; margin-bottom: ${offset}px;
`; `);
}); });
}), }),
); );
@ -199,18 +199,18 @@ export default (window: OskWindow) => {
const offset = window.startY - currentY; const offset = window.startY - currentY;
if (offset < -(calculatedHeight * 2 / 3)) { if (offset < -(calculatedHeight * 2 / 3)) {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: -${calculatedHeight}px; margin-bottom: -${calculatedHeight}px;
`; `);
tablet.oskState = false; tablet.oskState = false;
} }
else { else {
window.get_child().css = ` window.get_child().set_css(`
transition: margin-bottom 0.5s ease-in-out; transition: margin-bottom 0.5s ease-in-out;
margin-bottom: 0px; margin-bottom: 0px;
`; `);
} }
window.startY = null; window.startY = null;

View file

@ -148,9 +148,9 @@ const RegularKey = (key: Key) => {
self self
.hook(Shift, () => { .hook(Shift, () => {
if (key.labelShift) { if (key.labelShift) {
self.label = Shift.get() ? self.set_label(Shift.get() ?
key.labelShift : key.labelShift :
key.label; key.label);
} }
}) })
.hook(Caps, () => { .hook(Caps, () => {
@ -161,18 +161,18 @@ const RegularKey = (key: Key) => {
} }
if (key.labelShift && key.label.match(/[A-Za-z]/)) { if (key.labelShift && key.label.match(/[A-Za-z]/)) {
self.label = Caps.get() ? self.set_label(Caps.get() ?
key.labelShift : key.labelShift :
key.label; key.label);
} }
}) })
.hook(AltGr, () => { .hook(AltGr, () => {
if (key.labelAltGr) { if (key.labelAltGr) {
self.toggleClassName('altgr', AltGr.get()); self.toggleClassName('altgr', AltGr.get());
self.label = AltGr.get() ? self.set_label(AltGr.get() ?
key.labelAltGr : key.labelAltGr :
key.label; key.label);
} }
}); });
}} }}

View file

@ -27,7 +27,7 @@ export default () => {
const windowList = <box vertical /> as Widget.Box; const windowList = <box vertical /> as Widget.Box;
const updateWindows = async() => { const updateWindows = async() => {
if (!App.get_window('win-screenshot')?.visible) { if (!App.get_window('win-screenshot')?.get_visible()) {
return; return;
} }
@ -77,11 +77,11 @@ export default () => {
cursor="pointer" cursor="pointer"
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
takeScreenshot(['-o', monitor.name]); takeScreenshot(['-o', monitor.get_name()]);
}} }}
> >
<label <label
label={`${monitor.name}: ${monitor.description}`} label={`${monitor.get_name()}: ${monitor.get_description()}`}
truncate truncate
maxWidthChars={50} maxWidthChars={50}
/> />
@ -125,9 +125,9 @@ export default () => {
onButtonReleaseEvent={() => { onButtonReleaseEvent={() => {
frozen = !frozen; frozen = !frozen;
freezeIcon.icon = frozen ? freezeIcon.set_icon(frozen ?
'checkbox-checked-symbolic' : 'checkbox-checked-symbolic' :
'checkbox-symbolic'; 'checkbox-symbolic');
}} }}
> >
<box halign={Gtk.Align.CENTER}> <box halign={Gtk.Align.CENTER}>