Cthulhu is no longer a fork. Now it is a screen reader written in Golang.
This commit is contained in:
1 parent
a998fe67de
commit
069fc674dc
708 files changed
+112482
-532
No files matched your search
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// Authors: Storm Dragon, Angus Kola
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package preferences
|
||||
|
||||
import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
func soundChecks(values *Values) []struct {
|
||||
id string
|
||||
value *bool
|
||||
} {
|
||||
return []struct {
|
||||
id string
|
||||
value *bool
|
||||
}{
|
||||
{"enableSoundCheckButton", &values.EnableSound},
|
||||
{"playSoundForRoleCheckButton", &values.PlaySoundForRole},
|
||||
{"playSoundForStateCheckButton", &values.PlaySoundForState},
|
||||
{"playSoundForPositionInSetCheckButton", &values.PlaySoundForPositionInSet},
|
||||
{"spatializeObjectSoundsCheckButton", &values.SpatializeObjectSounds},
|
||||
}
|
||||
}
|
||||
|
||||
func (session *uiSession) setSoundTheme(theme string) {
|
||||
session.soundThemes = []string{"default", "none"}
|
||||
selected := 0
|
||||
if theme == "none" {
|
||||
selected = 1
|
||||
} else if theme != "" && theme != "default" {
|
||||
selected = len(session.soundThemes)
|
||||
session.soundThemes = append(session.soundThemes, theme)
|
||||
}
|
||||
labels := make([]string, len(session.soundThemes))
|
||||
for i, value := range session.soundThemes {
|
||||
if value == "default" {
|
||||
labels[i] = "Default"
|
||||
} else if value == "none" {
|
||||
labels[i] = "None"
|
||||
} else {
|
||||
labels[i] = value
|
||||
}
|
||||
}
|
||||
comboItems("soundThemeCombo", labels, selected)
|
||||
}
|
||||
|
||||
func set_sound_checks(values Values) {
|
||||
for _, check := range soundChecks(&values) {
|
||||
setCheck(check.id, *check.value)
|
||||
}
|
||||
}
|
||||
|
||||
func (session *uiSession) set_sound_values(values Values) {
|
||||
setRange("soundVolumeScale", values.SoundVolume)
|
||||
setCombo("soundSinkCombo", map[string]int{"auto": 0, "pipewire": 1, "pulse": 2, "alsa": 3}[values.SoundSink])
|
||||
session.setSoundTheme(values.SoundTheme)
|
||||
setCombo("roleSoundPresentationCombo", map[string]int{"sound_and_speech": 0, "speech_only": 1, "sound_only": 2}[values.RoleSoundPresentation])
|
||||
}
|
||||
|
||||
func get_sound_checks(values *Values) {
|
||||
for _, check := range soundChecks(values) {
|
||||
*check.value = getCheck(check.id)
|
||||
}
|
||||
}
|
||||
|
||||
func (session *uiSession) get_sound_values(values *Values) error {
|
||||
values.SoundVolume = getRange("soundVolumeScale")
|
||||
sink, theme, presentation := getCombo("soundSinkCombo"), getCombo("soundThemeCombo"), getCombo("roleSoundPresentationCombo")
|
||||
if sink < 0 || sink > 3 || theme < 0 || theme >= len(session.soundThemes) || presentation < 0 || presentation > 2 {
|
||||
return errors.New("Choose valid sound output settings.")
|
||||
}
|
||||
values.SoundSink = []string{"auto", "pipewire", "pulse", "alsa"}[sink]
|
||||
values.SoundTheme = session.soundThemes[theme]
|
||||
values.RoleSoundPresentation = []string{"sound_and_speech", "speech_only", "sound_only"}[presentation]
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user