package main

import (
	"os"
	"time"

	"go.wit.com/log"
	"go.wit.com/gui/gui"
	"go.wit.com/gui/gadgets"
	"github.com/gobuffalo/packr"
)

// origlog "log"
// "git.wit.org/jcarr/log"
//	"github.com/davecgh/go-spew/spew"

var GITCOMMIT string // this is passed in as an ldflag
var GOVERSION string // this is passed in as an ldflag
var VERSION string   // this is passed in as an ldflag
var BUILDTIME string // this is passed in as an ldflag

var closed bool = false
var loopsleep time.Duration = 100 // in tenths of seconds
var username string
var hostname string
var geom string = "120x30+500+500"

var debugTest bool = false

// var xterm 		= []string{"nohup", "xterm", "-geometry", geom}
var useFirefox bool = true
var firefox = []string{"firefox", "--new-window"}
var packrBox *packr.Box

var myGui *gui.Node

func customExit(n *gui.Node) {
	log.Println("Should Exit Here")
	closed = true
	log.Println("")
	log.Println("CLEAN EXIT")
	log.Println("")
	os.Exit(0)
}

type game struct {
	w, h int

	levelNum int
}

func main() {
	g := &game{
		w: 5,
		h: 20,
	}

	parseFlags(g)

	// This puts all the files in that directory in the binary
	// This directory includes the default config file if there is not already one
	packrBox = packr.NewBox("./resources")

	// runs the GO profiler in a goroutine
	go pprofMain()

	myGui = gui.New().Default()

	log.Warn("Starting window")
	gadgets.NewBasicWindow(myGui, "Debian SID Mate Control Panel " + VERSION)

	tabResets()
	windowAddWWW()
	golangDebug()

	time.Sleep(2 * time.Second)
	delayedTabs()
	go systrayMain()

	watchWindows()
}

func delayedTabs() {
	log.Println("delayedTabs() could have added a tab here\n")
	// jcarrWindow.AddTab("delayed tab", nil)
}