Files
2026-10-28 22:06:04 -04:00

141 lines
4.6 KiB
Go

// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
// Package preferences implements the isolated GTK preferences process and its
// bounded, typed protocol. The UI never opens settings files or speech sockets.
package preferences
import (
"git.stormux.org/storm/cthulhu/internal/config"
"git.stormux.org/storm/cthulhu/internal/input"
"git.stormux.org/storm/cthulhu/internal/interaction"
"git.stormux.org/storm/cthulhu/internal/speech"
"git.stormux.org/storm/cthulhu/internal/tentacle"
"git.stormux.org/storm/cthulhu/internal/tentaclewire"
)
type Values struct {
StructuralNavigationTriggersFocusMode bool
Pronunciations []config.PronunciationEntry
TextAttributes config.TextAttributeSettings
OCR config.OCRSettings
ProgressBar config.ProgressBarSettings
KeyboardLayout int
CthulhuModifierKeys []string
KeyBindings []input.BindingOverride
TimeFormat string
DateFormat string
EnableSound bool
EnableSpeech bool
SpeechHistoryLimit int
SpeechInterruption input.InterruptionSettings
SpeechVerbosityLevel int
SayAllStyle string
EnableBraille bool
EnableContractedBraille bool
BrailleContractionTable string
Braille config.BrailleOptions
SoundVolume float64
SoundSink string
SoundTheme string
PlaySoundForRole bool
PlaySoundForState bool
PlaySoundForPositionInSet bool
SpatializeObjectSounds bool
RoleSoundPresentation string
EnableKeyEcho bool
KeyEchoInEditFieldsOnly bool
EnableAlphabeticKeys bool
EnableNumericKeys bool
EnablePunctuationKeys bool
EnableSpace bool
EnableModifierKeys bool
EnableFunctionKeys bool
EnableActionKeys bool
EnableNavigationKeys bool
EnableDiacriticalKeys bool
EnableEchoByCharacter bool
EnableEchoByWord bool
EnableEchoBySentence bool
UseCustomEchoVoice bool
UseCustomEchoSpeechServer bool
UseCustomEchoForKey bool
UseCustomEchoForCharacter bool
UseCustomEchoForWord bool
UseCustomEchoForSentence bool
EchoVoice config.Voice
EchoSpeechServer string
Rate *float64
Pitch *float64
Volume *float64
SpeechServerFactory string
HardwareSpeechDevice string
HardwareSpeechBaudRate int
SpeechOutputModule string
SpeechVoiceFamily *config.VoiceFamily
UppercaseVoice config.Voice
HyperlinkVoice config.Voice
SystemVoice config.Voice
VoiceType string // Preview selection; never persisted as reader state.
Punctuation int
RaisePitchForCapitals bool
BeepForCapitals bool
SayCapForCapitals bool
Reading config.ReadingSettings
SpeakDescription bool
}
type ExtensionPage struct {
Session string
Revision uint64
tentaclewire.PreferencePage
}
type PageDraft struct {
Session string
ID string
Revision uint64
Values map[string]interaction.Value
}
type Request struct {
ExtensionPages []PageDraft `json:",omitempty"`
Tentacle *tentacle.ManagementRequest
Application string
Values Values
Save bool
Close bool
// Preview applies the default voice controls to the running speech
// backend without committing session or persistent settings.
Preview bool
// EchoPreview identifies the focused echo control (rate, pitch, volume,
// synthesizer or person). Only its value uses the draft echo voice.
EchoPreview string `json:",omitempty"`
// Focus previews include the control label in the normal voice before its value.
EchoPreviewFocus bool `json:",omitempty"`
// Cancel restores the last committed settings after a live preview.
Cancel bool
}
type Response struct {
ExtensionPages []ExtensionPage `json:",omitempty"`
ExtensionsOnly bool `json:",omitempty"`
Tentacles *tentacle.Snapshot `json:",omitempty"`
ChooseApplication bool
Catalog speech.Catalog
SpeechDefaults speech.Settings
CatalogPending bool // More catalog parts follow before the UI can initialize.
Application string
Present bool
Close bool
Values Values
CanSave bool
Message string
Preview bool
// Accepted distinguishes committed session values from rejected drafts.
Accepted bool
}