summaryrefslogtreecommitdiff
path: root/doGui.go
blob: 24ec444621a73a851b240ca53c01acfc57d3d935 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

// An app to submit patches for the 30 GO GUI repos

import (
	"time"

	"go.wit.com/gui"
	"go.wit.com/lib/fhelp"
	"go.wit.com/lib/gadgets"
	"go.wit.com/lib/gui/shell"
	"go.wit.com/log"
)

func debug() {
	defer func() {
		if r := recover(); r != nil {
			gui.Crash(r, "forge debug()")
		}
	}()
	time.Sleep(2 * time.Second)
	for {
		now := time.Now()

		doList()

		log.Printf("finished a scan here in (%s)\n", shell.FormatDuration(time.Since(now)))
		time.Sleep(90 * time.Second)
	}
}

func doGui() {
	if me.forge.Config.GetDefaultGui() == "" {
		me.forge.Config.DefaultGui = "gocui"
		me.forge.ConfigSave()
	}
	me.myGui = gui.New()
	me.myGui.InitEmbed(resources)
	me.myGui.SetAppDefaultPlugin(me.forge.Config.DefaultGui) // sets the default GUI plugin to use
	if pname, err := me.myGui.Default(); err != nil {
		if !fhelp.BuildPlugin("gocui") {
			log.Info("You can't run the forge GUI since the plugins did not build", pname)
			okExit("")
		} else {
			if err := me.myGui.LoadToolkitNew("gocui"); err != nil {
				log.Info("The plugins built, but still failed to load", pname)
				badExit(err)
			}
			log.Info("The plugins built and loaded!", pname)
		}
	}

	mainWindow := gadgets.NewGenericWindow("forged: forge.wit.com", "Current Settings")
	mainWindow.Custom = func() {
		log.Warn("MAIN WINDOW CLOSE")
		now := time.Now()
		log.Printf("rill repos.Reload() took (%s)\n", shell.FormatDuration(time.Since(now)))
		okExit("")
	}
	drawWindow(mainWindow)

	// sits here forever
	debug()
}

func drawWindow(win *gadgets.GenericWindow) {
	grid := win.Group.RawGrid()

	grid.NewButton("stats", func() {
		doList()
	})
}