From 96193b4f1ba9e0047dfe4b2aff1312939699fbbd Mon Sep 17 00:00:00 2001 From: matt1432 Date: Tue, 27 Feb 2024 18:27:47 -0500 Subject: [PATCH] fix(ags): get rid of stack warnings --- modules/ags/config/global-types.d.ts | 1 - modules/ags/config/ts/osd/ctor.ts | 10 ++++++---- modules/ags/config/ts/osd/main.ts | 6 +++--- modules/ags/config/ts/osd/osds.ts | 18 +++++------------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/modules/ags/config/global-types.d.ts b/modules/ags/config/global-types.d.ts index 338929cd..d64f6197 100644 --- a/modules/ags/config/global-types.d.ts +++ b/modules/ags/config/global-types.d.ts @@ -91,7 +91,6 @@ export type OSDStack = AgsStack void; export type OSD = { name: string; - stack: OSDStack; icon: IconPropsGeneric['icon']; info: { mod: GObject.Object; diff --git a/modules/ags/config/ts/osd/ctor.ts b/modules/ags/config/ts/osd/ctor.ts index fb086070..8537bdeb 100644 --- a/modules/ags/config/ts/osd/ctor.ts +++ b/modules/ags/config/ts/osd/ctor.ts @@ -3,10 +3,10 @@ const { Box, Icon, ProgressBar } = Widget; const Y_POS = 80; // Types -import { ConnectFunc, OSD } from 'global-types'; +import { ConnectFunc, OSD, OSDStack } from 'global-types'; -export default ({ name, stack, icon, info }: OSD) => { +export default ({ name, icon, info }: OSD) => { let connectFunc: ConnectFunc; const status = info.widget ? info.widget : @@ -39,10 +39,12 @@ export default ({ name, stack, icon, info }: OSD) => { info.logic(self); } r(); - }).then(() => stack.attribute.popup(name)); + }).then(() => (osd.get_parent() as OSDStack)?.attribute?.popup(name)) + .catch(console.error); } else { - connectFunc = () => stack.attribute.popup(name); + connectFunc = () => (osd.get_parent() as OSDStack) + ?.attribute?.popup(name); } if (info.signal) { diff --git a/modules/ags/config/ts/osd/main.ts b/modules/ags/config/ts/osd/main.ts index 2401f2a6..7e5b36c8 100644 --- a/modules/ags/config/ts/osd/main.ts +++ b/modules/ags/config/ts/osd/main.ts @@ -4,10 +4,10 @@ const { Stack } = Widget; import PopupWindow from '../misc/popup.ts'; // Types -import { BoxGeneric, StackGeneric } from 'global-types'; +import { BoxGeneric } from 'global-types'; // Import all the OSDs as an array -const OSDList = [] as Array<(stack: StackGeneric) => BoxGeneric>; +const OSDList = [] as Array<() => BoxGeneric>; import * as Modules from './osds.ts'; for (const osd in Modules) { @@ -35,7 +35,7 @@ const OSDs = () => { // Send reference of stack to all children stack.children = Object.fromEntries( OSDList.map((osd) => { - const widget = osd(stack); + const widget = osd(); return [widget.name, widget]; }), diff --git a/modules/ags/config/ts/osd/osds.ts b/modules/ags/config/ts/osd/osds.ts index 36e13a6d..49ec96c7 100644 --- a/modules/ags/config/ts/osd/osds.ts +++ b/modules/ags/config/ts/osd/osds.ts @@ -10,13 +10,9 @@ import { MicIcon } from '../misc/audio-icons.ts'; const AUDIO_MAX = 1.5; -// Types -import { OSDStack } from 'global-types'; - -export const SpeakerOSD = (stack: OSDStack) => OSD({ +export const SpeakerOSD = () => OSD({ name: 'speaker', - stack, icon: SpeakerIcon.bind(), info: { mod: Audio.speaker, @@ -36,9 +32,8 @@ export const SpeakerOSD = (stack: OSDStack) => OSD({ }, }); -export const ScreenBrightnessOSD = (stack: OSDStack) => OSD({ +export const ScreenBrightnessOSD = () => OSD({ name: 'screen', - stack, icon: Brightness.bind('screenIcon'), info: { mod: Brightness, @@ -50,9 +45,8 @@ export const ScreenBrightnessOSD = (stack: OSDStack) => OSD({ }, }); -export const KbdBrightnessOSD = (stack: OSDStack) => OSD({ +export const KbdBrightnessOSD = () => OSD({ name: 'kbd', - stack, icon: 'keyboard-brightness-symbolic', info: { mod: Brightness, @@ -70,9 +64,8 @@ export const KbdBrightnessOSD = (stack: OSDStack) => OSD({ }, }); -export const MicOSD = (stack: OSDStack) => OSD({ +export const MicOSD = () => OSD({ name: 'mic', - stack, icon: MicIcon.bind(), info: { mod: Audio.microphone, @@ -89,9 +82,8 @@ export const MicOSD = (stack: OSDStack) => OSD({ }, }); -export const CapsLockOSD = (stack: OSDStack) => OSD({ +export const CapsLockOSD = () => OSD({ name: 'caps', - stack, icon: Brightness.bind('capsIcon'), info: { mod: Brightness,