diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-12-31 00:25:52 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-12-31 00:25:52 +0530 |
commit | 69543243fce9ba1e6152cd52c4bcbc7cbde8870d (patch) | |
tree | 5af208754bbd446c0fdf6e7aa422d7f226240fad | |
parent | 487ce4dc647a8aa17123acf193765bf08e2f1e2d (diff) |
setting status text when server starts/stops
-rw-r--r-- | main.go | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -8,6 +8,7 @@ import ( "github.com/gotk3/gotk3/gtk" "context" "sync" + "fmt" ) func serve(port, dir string, wg *sync.WaitGroup) *http.Server { @@ -67,6 +68,7 @@ func onActivate(app *gtk.Application) { var on = false var server *http.Server buttonSwitch.Connect("clicked", func() { + // TODO: validate dir and port port, _ := portInput.GetText() dir, _ := dirInput.GetText() @@ -77,11 +79,16 @@ func onActivate(app *gtk.Application) { killServerDone := &sync.WaitGroup{} server = serve(port, dir, killServerDone) killServerDone.Add(1) + // do this after server starts on = true buttonSwitch.SetLabel("Stop") + statusLabel.SetText(fmt.Sprintf("Serving directory '%s' on PORT %s", dir, port)) + killServerDone.Wait() + // do this after server shuts down on = false buttonSwitch.SetLabel("Start") + statusLabel.SetText("") }() } }) |