fix(ags audio): misc fixes
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-14 22:14:56 -05:00
parent ce6d31e658
commit a33fc66b15
3 changed files with 140 additions and 112 deletions

View file

@ -24,23 +24,44 @@ export default () => {
transitionType={Gtk.StackTransitionType.SLIDE_LEFT_RIGHT} transitionType={Gtk.StackTransitionType.SLIDE_LEFT_RIGHT}
> >
<scrollable name="outputs" hscroll={Gtk.PolicyType.NEVER}> <scrollable
<box vertical> name="outputs"
{bind(audio, 'speakers').as(Streams)} hscroll={Gtk.PolicyType.NEVER}
</box>
</scrollable>
<scrollable name="inputs" hscroll={Gtk.PolicyType.NEVER}> setup={(self) => setTimeout(() => {
<box vertical> self.add((
{bind(audio, 'microphones').as(Streams)} <box vertical>
</box> {bind(audio, 'speakers').as(Streams)}
</scrollable> </box>
));
}, 1000)}
/>
<scrollable name="profiles" hscroll={Gtk.PolicyType.NEVER}> <scrollable
<box vertical> name="inputs"
{bind(audio, 'devices').as(Profiles)} hscroll={Gtk.PolicyType.NEVER}
</box>
</scrollable> setup={(self) => setTimeout(() => {
self.add((
<box vertical>
{bind(audio, 'microphones').as(Streams)}
</box>
));
}, 1000)}
/>
<scrollable
name="profiles"
hscroll={Gtk.PolicyType.NEVER}
setup={(self) => setTimeout(() => {
self.add((
<box vertical>
{bind(audio, 'devices').as(Profiles)}
</box>
));
}, 1000)}
/>
</stack> </stack>
) as Widget.Stack; ) as Widget.Stack;

View file

@ -5,40 +5,42 @@ import AstalWp from 'gi://AstalWp';
import { ComboBoxText } from '../misc/subclasses'; import { ComboBoxText } from '../misc/subclasses';
export default (devices: AstalWp.Device[]) => devices.map((device) => ( export default (devices: AstalWp.Device[]) => devices
<box className="stream" vertical> .sort((a, b) => a.description.localeCompare(b.description))
.map((device) => (
<box className="stream" vertical>
<label label={bind(device, 'description')} /> <label label={bind(device, 'description')} />
<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.description === 'Off') {
return 1; return 1;
} }
else if (b.description === 'Off') { else if (b.description === 'Off') {
return -1; return -1;
} }
else { else {
return a.description.localeCompare(b.description); return a.description.localeCompare(b.description);
} }
}); });
profiles.forEach((profile) => { profiles.forEach((profile) => {
self.append(profile.index.toString(), profile.description); self.append(profile.index.toString(), profile.description);
}); });
self.set_active( self.set_active(
profiles.indexOf( profiles.indexOf(
device.get_profile(device.get_active_profile())!, device.get_profile(device.get_active_profile())!,
), ),
); );
}} }}
onChanged={(self) => { onChanged={(self) => {
device.set_active_profile(parseInt(self.activeId)); device.set_active_profile(parseInt(self.activeId));
}} }}
/> />
</box> </box>
)); ));

View file

@ -10,82 +10,87 @@ import Separator from '../misc/separator';
export default (streams: AstalWp.Endpoint[]) => { export default (streams: AstalWp.Endpoint[]) => {
let group: RadioButton | undefined; let group: RadioButton | undefined;
return streams.map((stream) => ( return streams
<box className="stream" vertical> .sort((a, b) => a.description.localeCompare(b.description))
.map((stream) => (
<box className="stream" vertical>
<box className="title"> <box className="title">
<RadioButton <RadioButton
cursor="pointer" cursor="pointer"
css="margin-top: 1px;" css="margin-top: 1px;"
active={bind(stream, 'isDefault')} onRealize={(self) => {
if (!group) {
onRealize={(self) => { group = self;
if (!group) {
group = self;
}
else {
self.group = group;
}
}}
onButtonReleaseEvent={() => {
stream.isDefault = true;
}}
/>
<Separator size={8} />
<label label={bind(stream, 'description')} />
</box>
<Separator size={4} vertical />
<box className="body">
<button
cursor="pointer"
className="toggle"
valign={Gtk.Align.END}
onButtonReleaseEvent={() => {
stream.mute = !stream.mute;
}}
>
<icon
icon={bind(stream, 'mute').as((isMuted) => {
if (stream.mediaClass === AstalWp.MediaClass.AUDIO_MICROPHONE) {
return isMuted ?
'audio-input-microphone-muted-symbolic' :
'audio-input-microphone-symbolic';
} }
else { else {
return isMuted ? self.group = group;
'audio-volume-muted-symbolic' :
'audio-speakers-symbolic';
} }
})}
self.active = stream.isDefault;
self.hook(stream, 'notify::is-default', () => {
self.active = stream.isDefault;
});
}}
onButtonReleaseEvent={() => {
stream.isDefault = true;
}}
/> />
</button>
<Separator size={4} /> <Separator size={8} />
<slider <label label={bind(stream, 'description')} />
hexpand
halign={Gtk.Align.FILL}
drawValue
cursor="pointer"
value={bind(stream, 'volume')} </box>
onDragged={(self) => {
stream.set_volume(self.value); <Separator size={4} vertical />
}}
/> <box className="body">
<button
cursor="pointer"
className="toggle"
valign={Gtk.Align.END}
onButtonReleaseEvent={() => {
stream.mute = !stream.mute;
}}
>
<icon
icon={bind(stream, 'mute').as((isMuted) => {
if (stream.mediaClass === AstalWp.MediaClass.AUDIO_MICROPHONE) {
return isMuted ?
'audio-input-microphone-muted-symbolic' :
'audio-input-microphone-symbolic';
}
else {
return isMuted ?
'audio-volume-muted-symbolic' :
'audio-speakers-symbolic';
}
})}
/>
</button>
<Separator size={4} />
<slider
hexpand
halign={Gtk.Align.FILL}
drawValue
cursor="pointer"
value={bind(stream, 'volume')}
onDragged={(self) => {
stream.set_volume(self.value);
}}
/>
</box>
</box> </box>
));
</box>
));
}; };