diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 09:08:43 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-11-10 09:08:43 +0100 |
commit | 73963d6eda21fa7b45afe50cccf7b66e68fef7e6 (patch) | |
tree | d44294767fc16a48e4c5774ddbd7a317e78a2d54 /xA/xA.go | |
parent | b1ec9da0328e8a9b0dad2a3839af24b56c68ba66 (diff) | |
download | xK-73963d6eda21fa7b45afe50cccf7b66e68fef7e6.tar.gz xK-73963d6eda21fa7b45afe50cccf7b66e68fef7e6.tar.xz xK-73963d6eda21fa7b45afe50cccf7b66e68fef7e6.zip |
WIP: xA: add a connection window
Diffstat (limited to 'xA/xA.go')
-rw-r--r-- | xA/xA.go | 33 |
1 files changed, 28 insertions, 5 deletions
@@ -22,6 +22,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/app" "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/dialog" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" ) @@ -943,18 +944,16 @@ func inputSubmit(text string) bool { func main() { flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), - "Usage: %s [OPTION...] CONNECT\n\n", os.Args[0]) + "Usage: %s [OPTION...] [CONNECT]\n\n", os.Args[0]) flag.PrintDefaults() } flag.Parse() - if flag.NArg() < 1 || flag.NArg() > 1 { + if flag.NArg() > 1 { flag.Usage() os.Exit(1) } - backendAddress = flag.Arg(0) - a := app.New() a.Settings().SetTheme(&customTheme{}) wWindow = a.NewWindow(projectName) @@ -1020,7 +1019,31 @@ func main() { split.SetOffset(0.25) wWindow.SetContent(container.NewBorder(top, bottom, nil, nil, split)) - go relayRun() + connectAddress := widget.NewEntry() + connectAddress.SetPlaceHolder("host:port") + connectAddress.Validator = func(text string) error { + _, _, err := net.SplitHostPort(text) + return err + } + connectForm := dialog.NewForm("Connect to relay", "Connect", "Exit", + []*widget.FormItem{ + {Text: "Address:", Widget: connectAddress}, + }, func(ok bool) { + if !ok { + a.Quit() + } else { + backendAddress = connectAddress.Text + go relayRun() + } + }, wWindow) + + if flag.NArg() >= 1 { + backendAddress = flag.Arg(0) + connectAddress.SetText(backendAddress) + go relayRun() + } else { + connectForm.Show() + } wWindow.ShowAndRun() } |