2024-12-07 19:39:31 -05:00
|
|
|
import { bind } from 'astal';
|
|
|
|
import { Gtk } from 'astal/gtk3';
|
|
|
|
|
|
|
|
import AstalWp from 'gi://AstalWp';
|
|
|
|
|
|
|
|
import { RadioButton } from '../misc/subclasses';
|
|
|
|
import Separator from '../misc/separator';
|
|
|
|
|
|
|
|
|
|
|
|
export default (streams: AstalWp.Endpoint[]) => {
|
|
|
|
let group: RadioButton | undefined;
|
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
return streams
|
|
|
|
.sort((a, b) => a.description.localeCompare(b.description))
|
|
|
|
.map((stream) => (
|
|
|
|
<box className="stream" vertical>
|
2024-12-07 19:39:31 -05:00
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
<box className="title">
|
2024-12-07 19:39:31 -05:00
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
<RadioButton
|
|
|
|
cursor="pointer"
|
|
|
|
css="margin-top: 1px;"
|
2024-12-07 19:39:31 -05:00
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
onRealize={(self) => {
|
|
|
|
if (!group) {
|
|
|
|
group = self;
|
2024-12-07 19:39:31 -05:00
|
|
|
}
|
|
|
|
else {
|
2024-12-14 22:14:56 -05:00
|
|
|
self.group = group;
|
2024-12-07 19:39:31 -05:00
|
|
|
}
|
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
self.active = stream.isDefault;
|
|
|
|
self.hook(stream, 'notify::is-default', () => {
|
|
|
|
self.active = stream.isDefault;
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
|
|
|
|
onButtonReleaseEvent={() => {
|
|
|
|
stream.isDefault = true;
|
|
|
|
}}
|
|
|
|
/>
|
2024-12-07 19:39:31 -05:00
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
<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 {
|
|
|
|
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);
|
|
|
|
}}
|
|
|
|
/>
|
2024-12-07 19:39:31 -05:00
|
|
|
|
2024-12-14 22:14:56 -05:00
|
|
|
</box>
|
2024-12-07 19:39:31 -05:00
|
|
|
|
|
|
|
</box>
|
2024-12-14 22:14:56 -05:00
|
|
|
));
|
2024-12-07 19:39:31 -05:00
|
|
|
};
|