-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
82 lines (72 loc) · 1.86 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
77
78
79
80
81
82
package main
import (
"flag"
"log"
"os"
"github.com/asticode/go-astikit"
"github.com/asticode/go-astilectron"
bootstrap "github.com/asticode/go-astilectron-bootstrap"
)
// Vars injected via ldflags by bundler
var (
AppName string
BuiltAt string
VersionAstilectron string
VersionElectron string
)
// Vars used by the program itself
var (
Window *astilectron.Window
Logger *log.Logger
fs = flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
Debug = fs.Bool("d", false, "enables the debug mode") // CTRL-D -> Dev Tools
)
func main() {
// Create Logger
Logger = log.New(log.Writer(), log.Prefix(), log.Flags())
/* Logging to a file instead
f, _ := os.OpenFile("testlogfile.txt", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
defer f.Close()
Logger.SetOutput(f)
*/
// Parse flags
fs.Parse(os.Args[1:])
//Run bootstrap
err := createWindow()
if err != nil {
Logger.Fatal(err.Error())
}
}
func createWindow() error {
err := bootstrap.Run(bootstrap.Options{
Asset: Asset,
AssetDir: AssetDir,
AstilectronOptions: astilectron.Options{
AppName: AppName,
SingleInstance: true,
VersionAstilectron: VersionAstilectron,
VersionElectron: VersionElectron,
AppIconDarwinPath: "resources/icon.icns",
AppIconDefaultPath: "resources/icon.png",
},
Debug: *Debug,
Logger: Logger,
RestoreAssets: RestoreAssets,
Windows: []*bootstrap.Window{{
Homepage: "index.html",
MessageHandler: HandleMessage,
Adapter: func(i *astilectron.Window) {
Window = i
},
Options: &astilectron.WindowOptions{
Center: astikit.BoolPtr(true),
MinHeight: astikit.IntPtr(710),
Height: astikit.IntPtr(710),
MinWidth: astikit.IntPtr(700),
Width: astikit.IntPtr(700),
AutoHideMenuBar: astikit.BoolPtr(true),
},
}},
})
return err
}