refactor(ags): prioritise getters when using astal libs

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
modules/ags/config/widgets/audio

View file

@ -6,7 +6,7 @@ import { ComboBoxText } from '../misc/subclasses';
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) => (
<box className="stream" vertical>
@ -15,19 +15,19 @@ export default (devices: AstalWp.Device[]) => devices
<ComboBoxText
setup={(self) => {
const profiles = (device.get_profiles() ?? []).sort((a, b) => {
if (a.description === 'Off') {
if (a.get_description() === 'Off') {
return 1;
}
else if (b.description === 'Off') {
else if (b.get_description() === 'Off') {
return -1;
}
else {
return a.description.localeCompare(b.description);
return a.get_description().localeCompare(b.get_description());
}
});
profiles.forEach((profile) => {
self.append(profile.index.toString(), profile.description);
self.append(profile.get_index().toString(), profile.get_description());
});
self.set_active(
@ -38,7 +38,11 @@ export default (devices: AstalWp.Device[]) => devices
}}
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;
return streams
.sort((a, b) => a.description.localeCompare(b.description))
.sort((a, b) => a.get_description().localeCompare(b.get_description()))
.map((stream) => (
<box className="stream" vertical>
@ -29,14 +29,14 @@ export default (streams: AstalWp.Endpoint[]) => {
self.group = group;
}
self.active = stream.isDefault;
self.active = stream.get_is_default();
self.hook(stream, 'notify::is-default', () => {
self.active = stream.isDefault;
self.active = stream.get_is_default();
});
}}
onButtonReleaseEvent={() => {
stream.isDefault = true;
stream.set_is_default(true);
}}
/>
@ -56,12 +56,12 @@ export default (streams: AstalWp.Endpoint[]) => {
valign={Gtk.Align.END}
onButtonReleaseEvent={() => {
stream.mute = !stream.mute;
stream.set_mute(!stream.get_mute());
}}
>
<icon
icon={bind(stream, 'mute').as((isMuted) => {
if (stream.mediaClass === AstalWp.MediaClass.AUDIO_MICROPHONE) {
if (stream.get_media_class() === AstalWp.MediaClass.AUDIO_MICROPHONE) {
return isMuted ?
'audio-input-microphone-muted-symbolic' :
'audio-input-microphone-symbolic';