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;
|
||||
border-radius: 8px;
|
||||
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 { RadioButton, ToggleButton } from '../misc/subclasses';
|
||||
import { RadioButton } from '../misc/subclasses';
|
||||
import Separator from '../misc/separator';
|
||||
|
||||
|
||||
|
@ -17,56 +17,58 @@ export default () => {
|
|||
// TODO: make a stack to have outputs, inputs and currently playing apps
|
||||
// TODO: figure out ports and profiles
|
||||
|
||||
const defaultGroup = new RadioButton();
|
||||
|
||||
return (
|
||||
<box vertical className="widget audio">
|
||||
{bind(audio, 'speakers').as((speakers) => speakers.map((speaker) => (
|
||||
|
||||
{bind(audio, 'speakers').as((speakers) => {
|
||||
const widgets = speakers.map((speaker, i) => (
|
||||
<box className="stream" vertical>
|
||||
|
||||
<box className="title">
|
||||
|
||||
<RadioButton
|
||||
css="margin-top: 1px;"
|
||||
|
||||
group={defaultGroup}
|
||||
active={speaker.isDefault}
|
||||
active={bind(speaker, 'isDefault')}
|
||||
|
||||
setup={(self) => {
|
||||
speaker.connect('notify::isDefault', () => {
|
||||
self.active = speaker.isDefault;
|
||||
});
|
||||
onRealize={(self) => {
|
||||
if (i !== 0) {
|
||||
self.group = (((widgets[0] as Widget.Box)
|
||||
.get_children()[0] as Widget.Box)
|
||||
.get_children()[0] as RadioButton);
|
||||
}
|
||||
}}
|
||||
|
||||
onToggled={(self) => {
|
||||
speaker.isDefault = self.active;
|
||||
onButtonReleaseEvent={() => {
|
||||
speaker.isDefault = true;
|
||||
}}
|
||||
/>
|
||||
|
||||
<Separator size={8} />
|
||||
|
||||
<label label={bind(speaker, 'description')} />
|
||||
|
||||
</box>
|
||||
|
||||
<Separator size={4} vertical />
|
||||
|
||||
<box className="body">
|
||||
<ToggleButton
|
||||
|
||||
<button
|
||||
cursor="pointer"
|
||||
className="toggle"
|
||||
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';
|
||||
onButtonReleaseEvent={() => {
|
||||
speaker.mute = !speaker.mute;
|
||||
}}
|
||||
>
|
||||
<icon icon={speaker.mute ?
|
||||
<icon
|
||||
icon={bind(speaker, 'mute').as((isMuted) => isMuted ?
|
||||
'audio-volume-muted-symbolic' :
|
||||
'audio-speakers-symbolic'}
|
||||
'audio-speakers-symbolic')}
|
||||
/>
|
||||
</ToggleButton>
|
||||
</button>
|
||||
|
||||
<Separator size={4} />
|
||||
|
||||
|
@ -74,24 +76,21 @@ export default () => {
|
|||
FIXME: lockChannels not working
|
||||
TODO: have two sliders when lockChannels === false
|
||||
*/}
|
||||
<ToggleButton
|
||||
<button
|
||||
cursor="pointer"
|
||||
className="toggle"
|
||||
valign={Gtk.Align.END}
|
||||
|
||||
active={speaker.lockChannels}
|
||||
onToggled={(self) => {
|
||||
speaker.set_lock_channels(self.active);
|
||||
|
||||
(self.get_child() as Widget.Icon).icon = self.active ?
|
||||
'channel-secure-symbolic' :
|
||||
'channel-insecure-symbolic';
|
||||
onButtonReleaseEvent={() => {
|
||||
speaker.lockChannels = !speaker.lockChannels;
|
||||
}}
|
||||
>
|
||||
<icon icon={speaker.lockChannels ?
|
||||
<icon
|
||||
icon={bind(speaker, 'lockChannels').as((locked) => locked ?
|
||||
'channel-secure-symbolic' :
|
||||
'channel-insecure-symbolic'}
|
||||
'channel-insecure-symbolic')}
|
||||
/>
|
||||
</ToggleButton>
|
||||
</button>
|
||||
|
||||
<slider
|
||||
hexpand
|
||||
|
@ -103,9 +102,15 @@ export default () => {
|
|||
speaker.set_volume(self.value);
|
||||
}}
|
||||
/>
|
||||
|
||||
</box>
|
||||
|
||||
</box>
|
||||
)))}
|
||||
));
|
||||
|
||||
return widgets;
|
||||
})}
|
||||
|
||||
</box>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue