refactor(ags): update typechecking to match latest types
This commit is contained in:
parent
a126d97bbf
commit
ae615b08f5
13 changed files with 142 additions and 139 deletions
|
@ -7,9 +7,7 @@ import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
import CursorBox from '../misc/cursorbox.js';
|
import CursorBox from '../misc/cursorbox.js';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** @param {import('types/service/applications.js').Application} app */
|
||||||
* @param {import('types/service/applications.js').Application} app
|
|
||||||
*/
|
|
||||||
export default (app) => {
|
export default (app) => {
|
||||||
const icon = Icon({ size: 42 });
|
const icon = Icon({ size: 42 });
|
||||||
const iconString = app.app.get_string('Icon');
|
const iconString = app.app.get_string('Icon');
|
||||||
|
|
|
@ -23,10 +23,9 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
fzfResults = fzf.find(text);
|
fzfResults = fzf.find(text);
|
||||||
|
// @ts-expect-error
|
||||||
list.set_sort_func((a, b) => {
|
list.set_sort_func((a, b) => {
|
||||||
// @ts-expect-error
|
|
||||||
const row1 = a.get_children()[0]?.attribute.app.name;
|
const row1 = a.get_children()[0]?.attribute.app.name;
|
||||||
// @ts-expect-error
|
|
||||||
const row2 = b.get_children()[0]?.attribute.app.name;
|
const row2 = b.get_children()[0]?.attribute.app.name;
|
||||||
|
|
||||||
if (!row1 || !row2) {
|
if (!row1 || !row2) {
|
||||||
|
@ -39,7 +38,8 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const makeNewChildren = () => {
|
const makeNewChildren = () => {
|
||||||
list.get_children().forEach((ch) => {
|
// @ts-expect-error
|
||||||
|
Array.from(list.get_children()).forEach((ch) => {
|
||||||
ch.destroy();
|
ch.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => {
|
||||||
.flatMap((app) => AppItem(app));
|
.flatMap((app) => AppItem(app));
|
||||||
|
|
||||||
children.forEach((ch) => {
|
children.forEach((ch) => {
|
||||||
|
// @ts-expect-error
|
||||||
list.add(ch);
|
list.add(ch);
|
||||||
});
|
});
|
||||||
list.show_all();
|
list.show_all();
|
||||||
|
@ -84,11 +85,10 @@ const Applauncher = ({ window_name = 'applauncher' } = {}) => {
|
||||||
setSort(text);
|
setSort(text);
|
||||||
let visibleApps = 0;
|
let visibleApps = 0;
|
||||||
|
|
||||||
list.get_children().forEach((row) => {
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
|
Array.from(list.get_children()).forEach((row) => {
|
||||||
row.changed();
|
row.changed();
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
const item = row.get_children()[0];
|
const item = row.get_children()[0];
|
||||||
|
|
||||||
if (item?.attribute.app) {
|
if (item?.attribute.app) {
|
||||||
|
|
|
@ -14,7 +14,6 @@ export default () => Box({
|
||||||
children: [
|
children: [
|
||||||
Icon({
|
Icon({
|
||||||
class_name: 'battery-indicator',
|
class_name: 'battery-indicator',
|
||||||
// @ts-expect-error
|
|
||||||
icon: Battery.bind('icon_name'),
|
icon: Battery.bind('icon_name'),
|
||||||
}).hook(Battery, (self) => {
|
}).hook(Battery, (self) => {
|
||||||
self.toggleClassName('charging', Battery.charging);
|
self.toggleClassName('charging', Battery.charging);
|
||||||
|
|
|
@ -8,7 +8,6 @@ const SPACING = 5;
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
const icon = Icon({
|
const icon = Icon({
|
||||||
// @ts-expect-error
|
|
||||||
icon: Brightness.bind('screenIcon'),
|
icon: Brightness.bind('screenIcon'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default () => Box({
|
||||||
.query(Hyprland.active.client.class)[0];
|
.query(Hyprland.active.client.class)[0];
|
||||||
|
|
||||||
if (app) {
|
if (app) {
|
||||||
self.icon = app.icon_name;
|
self.icon = app.icon_name || '';
|
||||||
self.visible = Hyprland.active.client.title !== '';
|
self.visible = Hyprland.active.client.title !== '';
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -9,7 +9,7 @@ const SPACING = 4;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Label} self
|
* @param {import('types/widgets/label').default} self
|
||||||
* @param {string} layout
|
* @param {string} layout
|
||||||
* @param {string} _
|
* @param {string} _
|
||||||
*/
|
*/
|
||||||
|
@ -21,7 +21,6 @@ const getKbdLayout = (self, _, layout) => {
|
||||||
|
|
||||||
const shortName = layout.match(/\(([A-Za-z]+)\)/);
|
const shortName = layout.match(/\(([A-Za-z]+)\)/);
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
self.label = shortName ? shortName[1] : layout;
|
self.label = shortName ? shortName[1] : layout;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -35,7 +34,6 @@ const getKbdLayout = (self, _, layout) => {
|
||||||
const shortName = layout
|
const shortName = layout
|
||||||
.match(/\(([A-Za-z]+)\)/);
|
.match(/\(([A-Za-z]+)\)/);
|
||||||
|
|
||||||
// @ts-expect-error
|
|
||||||
self.label = shortName ? shortName[1] : layout;
|
self.label = shortName ? shortName[1] : layout;
|
||||||
}).catch(print);
|
}).catch(print);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ export default () => {
|
||||||
const label = Label().hook(Network, (self) => {
|
const label = Label().hook(Network, (self) => {
|
||||||
if (Network.wifi.internet === 'connected' ||
|
if (Network.wifi.internet === 'connected' ||
|
||||||
Network.wifi.internet === 'connecting') {
|
Network.wifi.internet === 'connecting') {
|
||||||
self.label = Network.wifi.ssid;
|
self.label = Network.wifi.ssid || 'Unknown';
|
||||||
}
|
}
|
||||||
else if (Network.wired.internet === 'connected' ||
|
else if (Network.wired.internet === 'connected' ||
|
||||||
Network.wired.internet === 'connecting') {
|
Network.wired.internet === 'connecting') {
|
||||||
|
|
|
@ -26,6 +26,7 @@ const SysTrayItem = (item) => {
|
||||||
|
|
||||||
child: Icon({
|
child: Icon({
|
||||||
size: 24,
|
size: 24,
|
||||||
|
// @ts-expect-error
|
||||||
icon: item.bind('icon'),
|
icon: item.bind('icon'),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
@ -38,11 +39,8 @@ const SysTray = () => MenuBar({
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: (self) => {
|
setup: (self) => {
|
||||||
/**
|
self
|
||||||
* @param {import('types/widget').default} _
|
.hook(SystemTray, (_, id) => {
|
||||||
* @param {string} id
|
|
||||||
*/
|
|
||||||
const addTray = (_, id) => {
|
|
||||||
const item = SystemTray.getItem(id);
|
const item = SystemTray.getItem(id);
|
||||||
|
|
||||||
if (self.attribute.items.has(id) || !item) {
|
if (self.attribute.items.has(id) || !item) {
|
||||||
|
@ -61,13 +59,9 @@ const SysTray = () => MenuBar({
|
||||||
self.show_all();
|
self.show_all();
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
w.child.reveal_child = true;
|
w.child.reveal_child = true;
|
||||||
};
|
}, 'added')
|
||||||
|
|
||||||
/**
|
.hook(SystemTray, (_, id) => {
|
||||||
* @param {import('types/widget').default} _
|
|
||||||
* @param {string} id
|
|
||||||
*/
|
|
||||||
const removeTray = (_, id) => {
|
|
||||||
if (!self.attribute.items.has(id)) {
|
if (!self.attribute.items.has(id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,11 +71,7 @@ const SysTray = () => MenuBar({
|
||||||
self.attribute.items.get(id).destroy();
|
self.attribute.items.get(id).destroy();
|
||||||
self.attribute.items.delete(id);
|
self.attribute.items.delete(id);
|
||||||
});
|
});
|
||||||
};
|
}, 'removed');
|
||||||
|
|
||||||
self
|
|
||||||
.hook(SystemTray, addTray, 'added')
|
|
||||||
.hook(SystemTray, removeTray, 'removed');
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -102,6 +92,7 @@ export default () => {
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
}).hook(SystemTray, (self) => {
|
}).hook(SystemTray, (self) => {
|
||||||
|
// @ts-expect-error
|
||||||
self.reveal_child = systray.get_children().length > 0;
|
self.reveal_child = systray.get_children().length > 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,8 +14,11 @@ const BarCloser = (variable) => Window({
|
||||||
child: EventBox({
|
child: EventBox({
|
||||||
on_hover: (self) => {
|
on_hover: (self) => {
|
||||||
variable.value = false;
|
variable.value = false;
|
||||||
// @ts-expect-error
|
const parent = self.get_parent();
|
||||||
self.get_parent().visible = false;
|
|
||||||
|
if (parent) {
|
||||||
|
parent.visible = false;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
child: Box({
|
child: Box({
|
||||||
|
@ -64,11 +67,11 @@ export default (props) => {
|
||||||
transition: 'slide_down',
|
transition: 'slide_down',
|
||||||
reveal_child: true,
|
reveal_child: true,
|
||||||
|
|
||||||
binds: [['revealChild', Revealed, 'value']],
|
}).bind('reveal_child', Revealed),
|
||||||
}),
|
|
||||||
|
|
||||||
Revealer({
|
Revealer({
|
||||||
binds: [['revealChild', Revealed, 'value', (v) => !v]],
|
reveal_child: Revealed.bind()
|
||||||
|
.transform((v) => !v),
|
||||||
|
|
||||||
child: EventBox({
|
child: EventBox({
|
||||||
on_hover: () => {
|
on_hover: () => {
|
||||||
|
|
|
@ -126,9 +126,14 @@ export default () => {
|
||||||
setup: false,
|
setup: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup: (self) => {
|
setup: /** @param {any} self */ (self) => {
|
||||||
self
|
self
|
||||||
.hook(Mpris, (overlay, bus_name) => {
|
.hook(Mpris,
|
||||||
|
/**
|
||||||
|
* @param {Overlay} overlay
|
||||||
|
* @param {string} bus_name
|
||||||
|
*/
|
||||||
|
(overlay, bus_name) => {
|
||||||
const players = overlay.attribute.players;
|
const players = overlay.attribute.players;
|
||||||
|
|
||||||
if (players.has(bus_name)) {
|
if (players.has(bus_name)) {
|
||||||
|
@ -172,18 +177,26 @@ export default () => {
|
||||||
.includesWidget(previousFirst);
|
.includesWidget(previousFirst);
|
||||||
|
|
||||||
// Select favorite player at startup
|
// Select favorite player at startup
|
||||||
if (!overlay.attribute.setup && players.has(FAVE_PLAYER)) {
|
const attrs = overlay.attribute;
|
||||||
overlay.attribute.moveToTop(players.get(FAVE_PLAYER));
|
|
||||||
overlay.attribute.setup = true;
|
if (!attrs.setup && players.has(FAVE_PLAYER)) {
|
||||||
|
attrs.moveToTop(players.get(FAVE_PLAYER));
|
||||||
|
attrs.setup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move previousFirst on top again
|
// Move previousFirst on top again
|
||||||
else if (includes) {
|
else if (includes) {
|
||||||
overlay.attribute.moveToTop(previousFirst);
|
attrs.moveToTop(previousFirst);
|
||||||
}
|
}
|
||||||
}, 'player-added')
|
},
|
||||||
|
'player-added')
|
||||||
|
|
||||||
.hook(Mpris, (overlay, bus_name) => {
|
.hook(Mpris,
|
||||||
|
/**
|
||||||
|
* @param {Overlay} overlay
|
||||||
|
* @param {string} bus_name
|
||||||
|
*/
|
||||||
|
(overlay, bus_name) => {
|
||||||
const players = overlay.attribute.players;
|
const players = overlay.attribute.players;
|
||||||
|
|
||||||
if (!bus_name || !players.has(bus_name)) {
|
if (!bus_name || !players.has(bus_name)) {
|
||||||
|
@ -205,7 +218,8 @@ export default () => {
|
||||||
if (includes) {
|
if (includes) {
|
||||||
overlay.attribute.moveToTop(previousFirst);
|
overlay.attribute.moveToTop(previousFirst);
|
||||||
}
|
}
|
||||||
}, 'player-closed');
|
},
|
||||||
|
'player-closed');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ export default ({
|
||||||
|
|
||||||
get_child: () => widget.child,
|
get_child: () => widget.child,
|
||||||
|
|
||||||
|
/** @param {import('types/widget').Widget} new_child */
|
||||||
set_child: (new_child) => {
|
set_child: (new_child) => {
|
||||||
widget.child = new_child;
|
widget.child = new_child;
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,16 +3,15 @@ const { get_home_dir } = imports.gi.GLib;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} Persist
|
* @param {{
|
||||||
* @property {string} name
|
* name: string
|
||||||
* @property {typeof imports.gi.GObject} gobject
|
* gobject: typeof imports.gi.GObject
|
||||||
* @property {string} prop
|
* prop: string
|
||||||
* @property {boolean|string=} condition - if string, compare following props to this
|
* condition?: boolean|string // if string, compare following props to this
|
||||||
* @property {boolean|string=} whenTrue
|
* whenTrue?: boolean|string
|
||||||
* @property {boolean|string=} whenFalse
|
* whenFalse?: boolean|string
|
||||||
* @property {string=} signal
|
* signal?: string
|
||||||
*
|
* }} o
|
||||||
* @param {Persist} props
|
|
||||||
*/
|
*/
|
||||||
export default ({
|
export default ({
|
||||||
name,
|
name,
|
||||||
|
|
|
@ -68,9 +68,10 @@ export default ({
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
get_child: () => window.child.children[0].child,
|
get_child: () => window.child.children[0].child,
|
||||||
|
|
||||||
set_child: (newChild) => {
|
/** @param {import('types/widget').Widget} new_child */
|
||||||
|
set_child: (new_child) => {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
window.child.children[0].child = newChild;
|
window.child.children[0].child = new_child;
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
window.child.children[0].show_all();
|
window.child.children[0].show_all();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue