-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
76 lines (60 loc) · 2.16 KB
/
main.go
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
76
// Copyright 2022 Adam Chalkley
//
// https://github.com/atc0005/safelinks
//
// Licensed under the MIT License. See LICENSE file in the project root for
// full license information.
//go:generate go-winres make --product-version=git-tag --file-version=git-tag
package main
import (
"log"
"os"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
)
func main() {
// use io.Discard for normal operation
// switch to os.Stderr for debugging
debugLoggingOut := os.Stderr
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
log.SetOutput(debugLoggingOut)
// Help this tool stand out from the dslg app unless explicitly requested
// otherwise.
// if os.Getenv("FYNE_THEME") == "" {
// if err := os.Setenv("FYNE_THEME", "light"); err != nil {
// log.Println("Failed to set fyne toolkit theme")
// }
// }
// NOTE: This is deprecated and set to be removed in v3.0.
// fyne.CurrentApp().Settings().SetTheme(theme.LightTheme())
a := app.New()
w := a.NewWindow("Create faux encoded Microsoft Defender Safe Links")
input := NewInputTextField()
errorOutput := NewErrorOutputTextField()
output := NewOutputTextLabel()
copyButton := newCopyButton(w, output)
encodeAllButton := newEncodeButton(false, input, copyButton, errorOutput, output)
encodeRandomButton := newEncodeButton(true, input, copyButton, errorOutput, output)
queryEscapeAllButton := newQueryEscapeButton(false, input, copyButton, errorOutput, output)
queryEscapeRandomButton := newQueryEscapeButton(true, input, copyButton, errorOutput, output)
resetButton := newResetButton(w, input, copyButton, errorOutput, output)
aboutButton := newAboutButton(w, input, copyButton, errorOutput, output)
exitButton := newExitButton(a)
buttonRowContainer := NewButtonRowContainer(
encodeAllButton,
encodeRandomButton,
queryEscapeAllButton,
queryEscapeRandomButton,
copyButton,
resetButton,
aboutButton,
exitButton,
)
outputContainer := NewOutputContainer(errorOutput, output)
mainAppContainer := NewMainAppContainer(input, buttonRowContainer, outputContainer)
w.SetContent(mainAppContainer)
w.Resize(fyne.NewSize(windowSizeHeight, windowSizeWidth))
w.CenterOnScreen()
w.SetFixedSize(false)
w.ShowAndRun()
}