//go:build gui
/*
  StreamGoose UI — Go reference implementation
 
  Created by Luxferre in 2024, released into public domain
*/
package main

import (
  "fmt"
  "centrifuge.hectabit.org/HectaBit/webview_go" /* for UI launch */
)

/* override GUI entry point */
func init() {
  goose_start_gui = func(config map[string]interface{}) {
    /* target server listening address */
    target_addr := fmt.Sprintf("%s:%d", config["server_listen_ip"].(string), int(config["server_port"].(float64)))

    /* start the GUI */
    debug := false
    if _, ok := config["debug"]; ok && config["debug"].(bool) == true {
      debug = true
    }
    bro := webview.New(debug) /* create a browser instance */
    bro.SetSize(320, 720, webview.HintNone)
    defer bro.Destroy()
    bro.SetTitle("StreamGoose")
    bro.Navigate("http://" + target_addr)
    bro.Run()
  }
}
