feature: prefs, search, LF-ification

This commit is contained in:
Failure 2025-12-13 00:58:52 -08:00
parent f846a6fb6b
commit 6745dba616

View file

@ -55,10 +55,9 @@ func (t *Threenis) Mumble(server string, username string, password string, chann
} }
func Ui() { func Ui() {
myApp := app.New() threenisApp := app.NewWithID("threenis")
myWindow := myApp.NewWindow("Threenis") window := threenisApp.NewWindow("Threenis")
myWindow.Resize(fyne.NewSize(800, 400)) window.Resize(fyne.NewSize(800, 400))
myWindow.SetFixedSize(true)
processes := GetProcessStrings() processes := GetProcessStrings()
threenis := Threenis{} threenis := Threenis{}
@ -96,14 +95,19 @@ func Ui() {
serverLabel := widget.NewLabel("Server") serverLabel := widget.NewLabel("Server")
server := widget.NewEntry() server := widget.NewEntry()
server.SetText(threenisApp.Preferences().StringWithFallback("server", ""))
usernameLabel := widget.NewLabel("Username") usernameLabel := widget.NewLabel("Username")
username := widget.NewEntry() username := widget.NewEntry()
username.SetText(threenisApp.Preferences().StringWithFallback("username", ""))
passwordLabel := widget.NewLabel("Password") passwordLabel := widget.NewLabel("Password")
password := widget.NewEntry() password := widget.NewEntry()
password.SetText(threenisApp.Preferences().StringWithFallback("password", ""))
channelLabel := widget.NewLabel("Channel") channelLabel := widget.NewLabel("Channel")
channel := widget.NewEntry() channel := widget.NewEntry()
channel.SetText(threenisApp.Preferences().StringWithFallback("channel", ""))
refresh := widget.NewButton("Refresh", func() { refresh := widget.NewButton("Refresh", func() {
processes = GetProcessStrings() processes = GetProcessStrings()
@ -111,13 +115,31 @@ func Ui() {
}) })
connect := widget.NewButton("Connect", func() { connect := widget.NewButton("Connect", func() {
threenisApp.Preferences().SetString("server", server.Text)
threenisApp.Preferences().SetString("username", username.Text)
threenisApp.Preferences().SetString("password", password.Text)
threenisApp.Preferences().SetString("channel", channel.Text)
go threenis.Mumble(server.Text, username.Text, password.Text, channel.Text) go threenis.Mumble(server.Text, username.Text, password.Text, channel.Text)
}) })
search := widget.NewEntry()
search.OnChanged = func(s string) {
procs := GetProcessStrings()
processes = make([]string, 0)
for _, proc := range procs {
if strings.Contains(strings.ToLower(proc), strings.ToLower(s)) {
processes = append(processes, proc)
}
}
list.Refresh()
}
content := container.NewBorder(nil, search, nil, nil, list)
form := container.New(layout.NewFormLayout(), serverLabel, server, usernameLabel, username, passwordLabel, password, channelLabel, channel, refresh, connect) form := container.New(layout.NewFormLayout(), serverLabel, server, usernameLabel, username, passwordLabel, password, channelLabel, channel, refresh, connect)
grid := container.New(layout.NewGridLayout(2), list, form) grid := container.New(layout.NewGridLayout(2), content, form)
myWindow.SetContent(grid) window.SetContent(grid)
myWindow.ShowAndRun() window.ShowAndRun()
} }