fix(ags audio): fix crash with default and improve toggles
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
936e9aacb0
commit
0455271294
2 changed files with 88 additions and 73 deletions
|
@ -7,5 +7,15 @@
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background-color: color.adjust(colors.$window_bg_color, $lightness: -3%);
|
background-color: color.adjust(colors.$window_bg_color, $lightness: -3%);
|
||||||
|
|
||||||
|
.body {
|
||||||
|
.toggle {
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
|
icon {
|
||||||
|
font-size: 26px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { Gtk, Widget } from 'astal/gtk3';
|
||||||
|
|
||||||
import AstalWp from 'gi://AstalWp';
|
import AstalWp from 'gi://AstalWp';
|
||||||
|
|
||||||
import { RadioButton, ToggleButton } from '../misc/subclasses';
|
import { RadioButton } from '../misc/subclasses';
|
||||||
import Separator from '../misc/separator';
|
import Separator from '../misc/separator';
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,95 +17,100 @@ export default () => {
|
||||||
// TODO: make a stack to have outputs, inputs and currently playing apps
|
// TODO: make a stack to have outputs, inputs and currently playing apps
|
||||||
// TODO: figure out ports and profiles
|
// TODO: figure out ports and profiles
|
||||||
|
|
||||||
const defaultGroup = new RadioButton();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<box vertical className="widget audio">
|
<box vertical className="widget audio">
|
||||||
{bind(audio, 'speakers').as((speakers) => speakers.map((speaker) => (
|
|
||||||
<box className="stream" vertical>
|
|
||||||
<box className="title">
|
|
||||||
<RadioButton
|
|
||||||
css="margin-top: 1px;"
|
|
||||||
|
|
||||||
group={defaultGroup}
|
{bind(audio, 'speakers').as((speakers) => {
|
||||||
active={speaker.isDefault}
|
const widgets = speakers.map((speaker, i) => (
|
||||||
|
<box className="stream" vertical>
|
||||||
|
|
||||||
setup={(self) => {
|
<box className="title">
|
||||||
speaker.connect('notify::isDefault', () => {
|
|
||||||
self.active = speaker.isDefault;
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
|
|
||||||
onToggled={(self) => {
|
<RadioButton
|
||||||
speaker.isDefault = self.active;
|
css="margin-top: 1px;"
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Separator size={8} />
|
active={bind(speaker, 'isDefault')}
|
||||||
|
|
||||||
<label label={bind(speaker, 'description')} />
|
onRealize={(self) => {
|
||||||
</box>
|
if (i !== 0) {
|
||||||
|
self.group = (((widgets[0] as Widget.Box)
|
||||||
|
.get_children()[0] as Widget.Box)
|
||||||
|
.get_children()[0] as RadioButton);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
|
||||||
<Separator size={4} vertical />
|
onButtonReleaseEvent={() => {
|
||||||
|
speaker.isDefault = true;
|
||||||
<box className="body">
|
}}
|
||||||
<ToggleButton
|
|
||||||
cursor="pointer"
|
|
||||||
valign={Gtk.Align.END}
|
|
||||||
|
|
||||||
active={speaker.mute}
|
|
||||||
onToggled={(self) => {
|
|
||||||
speaker.set_mute(self.active);
|
|
||||||
|
|
||||||
(self.get_child() as Widget.Icon).icon = self.active ?
|
|
||||||
'audio-volume-muted-symbolic' :
|
|
||||||
'audio-speakers-symbolic';
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<icon icon={speaker.mute ?
|
|
||||||
'audio-volume-muted-symbolic' :
|
|
||||||
'audio-speakers-symbolic'}
|
|
||||||
/>
|
/>
|
||||||
</ToggleButton>
|
|
||||||
|
|
||||||
<Separator size={4} />
|
<Separator size={8} />
|
||||||
|
|
||||||
{/*
|
<label label={bind(speaker, 'description')} />
|
||||||
FIXME: lockChannels not working
|
|
||||||
TODO: have two sliders when lockChannels === false
|
|
||||||
*/}
|
|
||||||
<ToggleButton
|
|
||||||
cursor="pointer"
|
|
||||||
valign={Gtk.Align.END}
|
|
||||||
|
|
||||||
active={speaker.lockChannels}
|
</box>
|
||||||
onToggled={(self) => {
|
|
||||||
speaker.set_lock_channels(self.active);
|
|
||||||
|
|
||||||
(self.get_child() as Widget.Icon).icon = self.active ?
|
<Separator size={4} vertical />
|
||||||
'channel-secure-symbolic' :
|
|
||||||
'channel-insecure-symbolic';
|
<box className="body">
|
||||||
}}
|
|
||||||
>
|
<button
|
||||||
<icon icon={speaker.lockChannels ?
|
cursor="pointer"
|
||||||
'channel-secure-symbolic' :
|
className="toggle"
|
||||||
'channel-insecure-symbolic'}
|
valign={Gtk.Align.END}
|
||||||
|
|
||||||
|
onButtonReleaseEvent={() => {
|
||||||
|
speaker.mute = !speaker.mute;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<icon
|
||||||
|
icon={bind(speaker, 'mute').as((isMuted) => isMuted ?
|
||||||
|
'audio-volume-muted-symbolic' :
|
||||||
|
'audio-speakers-symbolic')}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Separator size={4} />
|
||||||
|
|
||||||
|
{/*
|
||||||
|
FIXME: lockChannels not working
|
||||||
|
TODO: have two sliders when lockChannels === false
|
||||||
|
*/}
|
||||||
|
<button
|
||||||
|
cursor="pointer"
|
||||||
|
className="toggle"
|
||||||
|
valign={Gtk.Align.END}
|
||||||
|
|
||||||
|
onButtonReleaseEvent={() => {
|
||||||
|
speaker.lockChannels = !speaker.lockChannels;
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<icon
|
||||||
|
icon={bind(speaker, 'lockChannels').as((locked) => locked ?
|
||||||
|
'channel-secure-symbolic' :
|
||||||
|
'channel-insecure-symbolic')}
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<slider
|
||||||
|
hexpand
|
||||||
|
halign={Gtk.Align.FILL}
|
||||||
|
drawValue
|
||||||
|
|
||||||
|
value={bind(speaker, 'volume')}
|
||||||
|
onDragged={(self) => {
|
||||||
|
speaker.set_volume(self.value);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</ToggleButton>
|
|
||||||
|
|
||||||
<slider
|
</box>
|
||||||
hexpand
|
|
||||||
halign={Gtk.Align.FILL}
|
|
||||||
drawValue
|
|
||||||
|
|
||||||
value={bind(speaker, 'volume')}
|
|
||||||
onDragged={(self) => {
|
|
||||||
speaker.set_volume(self.value);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</box>
|
</box>
|
||||||
</box>
|
));
|
||||||
)))}
|
|
||||||
|
return widgets;
|
||||||
|
})}
|
||||||
|
|
||||||
</box>
|
</box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue