aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/main.go b/main.go
index ce6ae8e..41d69c8 100644
--- a/main.go
+++ b/main.go
@@ -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("")
}()
}
})