From 3af2e1cd413566c59dc56c51a8eb73e513571c93 Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 27 Jun 2023 01:54:24 +0200 Subject: [PATCH] app mixer percent label --- src/widgets/audio.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/widgets/audio.js b/src/widgets/audio.js index 7c7c30c..450d872 100644 --- a/src/widgets/audio.js +++ b/src/widgets/audio.js @@ -94,7 +94,12 @@ export function AppMixer({ item, ...props }) { item ||= stream => { const icon = Icon(); const label = Label({ xalign: 0, justify: 'left', wrap: true }); - const slider = Slider({ onChange: value => stream.volume = value }); + const percent = Label({ xalign: 1 }); + const slider = Widget({ + type: 'slider', + hexpand: true, + onChange: value => stream.volume = value, + }); const box = Widget({ type: 'box', hexpand: true, @@ -106,7 +111,13 @@ export function AppMixer({ item, ...props }) { orientation: 'vertical', children: [ label, - slider, + { + type: 'box', + children: [ + slider, + percent, + ], + }, ], }), ], @@ -115,6 +126,7 @@ export function AppMixer({ item, ...props }) { icon.icon_name = stream.state.iconName; icon.set_tooltip_text(stream.state.name); slider.set_value(stream.volume); + percent.label = `${Math.floor(stream.volume)}%`; stream.state.description.length > 37 ? label.label = stream.state.description.substring(0, 37)+'..' : label.label = stream.state.description;