mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-06-04 19:39:45 +00:00
(feature): uncheck mark if error appears
This commit is contained in:
@@ -14,6 +14,7 @@ type Program struct {
|
||||
App fyne.App
|
||||
ParentWindow fyne.Window
|
||||
RunString string
|
||||
RunCheck *widget.Check
|
||||
Config *Config
|
||||
Cmd *exec.Cmd
|
||||
}
|
||||
@@ -47,7 +48,7 @@ func (p *Program) Run() {
|
||||
p.settingsWindow()
|
||||
})
|
||||
|
||||
runCheck := widget.NewCheck("Run", func(b bool) {
|
||||
p.RunCheck = widget.NewCheck("Run", func(b bool) {
|
||||
if b {
|
||||
log("Run enabled")
|
||||
p.olcrtcRun()
|
||||
@@ -59,7 +60,7 @@ func (p *Program) Run() {
|
||||
|
||||
w.SetContent(container.NewBorder(
|
||||
settingsBtn,
|
||||
runCheck, nil, nil,
|
||||
p.RunCheck, nil, nil,
|
||||
))
|
||||
log("Window created and running...")
|
||||
w.ShowAndRun()
|
||||
|
||||
@@ -12,6 +12,7 @@ func (p *Program) olcrtcRun() {
|
||||
if p.RunString == "" {
|
||||
log("ERROR: Run string is empty. Please configure settings first.")
|
||||
p.showError(fmt.Errorf("run string is empty - please configure settings"))
|
||||
p.MarkUncheck()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -21,12 +22,14 @@ func (p *Program) olcrtcRun() {
|
||||
log("ERROR: Failed to start olcrtc: %v", err)
|
||||
p.showError(err)
|
||||
p.Cmd = nil
|
||||
p.MarkUncheck()
|
||||
} else {
|
||||
log("olcrtc process started (PID: %d)", p.Cmd.Process.Pid)
|
||||
go func() {
|
||||
err := p.Cmd.Wait()
|
||||
err = p.Cmd.Wait()
|
||||
if err != nil {
|
||||
log("olcrtc process exited with error: %v", err)
|
||||
p.MarkUncheck()
|
||||
} else {
|
||||
log("olcrtc process exited successfully")
|
||||
}
|
||||
|
||||
8
ui/ui.go
8
ui/ui.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
@@ -68,3 +69,10 @@ func (p *Program) buildRunString(conferenceId, encryptionKey, socksPort, dns str
|
||||
func (p *Program) showError(err error) {
|
||||
dialog.ShowError(err, p.ParentWindow)
|
||||
}
|
||||
|
||||
// fyne.Do used here to execute function in the main context frame
|
||||
// we can just paste p.RunCheck.SetChecked(false) and that'll work. but if so
|
||||
// there'll be a bunch of warnings(thread safety)
|
||||
func (p *Program) MarkUncheck() {
|
||||
fyne.Do(func() { p.RunCheck.SetChecked(false) })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user