From da07a1a69f9bde8f0f6ee79e727443ba05eaa73c Mon Sep 17 00:00:00 2001 From: matt1432 Date: Sat, 7 Dec 2024 19:39:31 -0500 Subject: [PATCH] feat(ags audio): make it a stack and add inputs --- .../ags/config/widgets/audio/_index.scss | 23 +++ .../ags/config/widgets/audio/main.tsx | 153 +++++++----------- .../ags/config/widgets/audio/streams.tsx | 91 +++++++++++ 3 files changed, 173 insertions(+), 94 deletions(-) create mode 100644 nixosModules/ags/config/widgets/audio/streams.tsx diff --git a/nixosModules/ags/config/widgets/audio/_index.scss b/nixosModules/ags/config/widgets/audio/_index.scss index 71949687..93ede090 100644 --- a/nixosModules/ags/config/widgets/audio/_index.scss +++ b/nixosModules/ags/config/widgets/audio/_index.scss @@ -2,6 +2,29 @@ @use '../../style/colors'; .widget.audio { + .header { + .header-btn { + font-size: 30px; + margin: 5px; + transition: background 400ms; + + &.active { + background: colors.$window_bg_color; + } + } + } + + scrollable { + margin: 5px; + min-height: 400px; + + box { + .item-btn { + margin: 3px; + } + } + } + .stream { margin: 5px; padding: 10px; diff --git a/nixosModules/ags/config/widgets/audio/main.tsx b/nixosModules/ags/config/widgets/audio/main.tsx index d891cc86..b4686b79 100644 --- a/nixosModules/ags/config/widgets/audio/main.tsx +++ b/nixosModules/ags/config/widgets/audio/main.tsx @@ -1,12 +1,14 @@ -import { bind } from 'astal'; +import { bind, Variable } from 'astal'; import { Gtk, Widget } from 'astal/gtk3'; import AstalWp from 'gi://AstalWp'; -import { RadioButton } from '../misc/subclasses'; import Separator from '../misc/separator'; +import Streams from './streams'; +const ICON_SEP = 6; + export default () => { const audio = AstalWp.get_default()?.get_audio(); @@ -17,100 +19,63 @@ export default () => { // TODO: make a stack to have outputs, inputs and currently playing apps // TODO: figure out ports and profiles + const Shown = Variable('outputs'); + + const stack = ( + + + + {bind(audio, 'speakers').as(Streams)} + + + + + + {bind(audio, 'microphones').as(Streams)} + + + + ) as Widget.Stack; + + const StackButton = ({ label = '', iconName = '' }) => ( + + ) as Widget.Button; + return ( - - - {bind(audio, 'speakers').as((speakers) => { - const widgets = speakers.map((speaker, i) => ( - - - - - { - if (i !== 0) { - self.group = (((widgets[0] as Widget.Box) - .get_children()[0] as Widget.Box) - .get_children()[0] as RadioButton); - } - }} - - onButtonReleaseEvent={() => { - speaker.isDefault = true; - }} - /> - - - - - - - - - - - - - - {/* - FIXME: lockChannels not working - TODO: have two sliders when lockChannels === false - */} - - - { - speaker.set_volume(self.value); - }} - /> - - - - - )); - - return widgets; - })} + + + + + + {stack} + + ); }; diff --git a/nixosModules/ags/config/widgets/audio/streams.tsx b/nixosModules/ags/config/widgets/audio/streams.tsx new file mode 100644 index 00000000..e4487361 --- /dev/null +++ b/nixosModules/ags/config/widgets/audio/streams.tsx @@ -0,0 +1,91 @@ +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; + + return streams.map((stream) => ( + + + + + { + if (!group) { + group = self; + } + else { + self.group = group; + } + }} + + onButtonReleaseEvent={() => { + stream.isDefault = true; + }} + /> + + + + + + + + + + + + + + { + stream.set_volume(self.value); + }} + /> + + + + + )); +};