-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
82 lines (67 loc) · 1.72 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 (
"fmt"
"log"
"net/http"
"os"
_ "net/http/pprof"
"github.com/gotk3/gotk3/gdk"
"github.com/gotk3/gotk3/glib"
"github.com/gotk3/gotk3/gtk"
"github.com/swampapp/swamp/internal/config"
"github.com/swampapp/swamp/internal/credentials"
"github.com/swampapp/swamp/internal/logger"
"github.com/swampapp/swamp/internal/paths"
"github.com/swampapp/swamp/internal/resources"
"github.com/swampapp/swamp/internal/ui/assistant"
"github.com/swampapp/swamp/internal/ui/mainwindow"
"github.com/swampapp/swamp/internal/version"
)
func main() {
logger.Init(logger.DebugLevel, "swamp")
for _, a := range os.Args {
if a == "-v" || a == "--version" {
fmt.Printf("Swamp v%s (%s)\n", version.APP_VERSION, version.GIT_SHA)
os.Exit(0)
}
}
go func() {
log.Println(http.ListenAndServe("localhost:6061", nil))
}()
err := paths.Initialize()
if err != nil {
panic(fmt.Errorf("error initializing paths: %w", err))
}
_, err = config.Init()
if err != nil {
panic(fmt.Errorf("error initializing configuration: %w", err))
}
resources.InitResources()
logger.Print("starting app")
gtk.Init(nil)
app, _ := gtk.ApplicationNew("com.github.rubiojr.swamp", glib.APPLICATION_FLAGS_NONE)
screen, _ := gdk.ScreenGetDefault()
gtk.AddProviderForScreen(screen, resources.CSS(), gtk.STYLE_PROVIDER_PRIORITY_USER)
app.Connect("activate", func() {
if credentials.FirstBoot() {
a := assistant.New()
app.AddWindow(a)
a.ShowAll()
a.WhenDone(func() {
activate(app)
})
} else {
activate(app)
}
})
if exitCode := app.Run(os.Args); exitCode > 0 {
os.Exit(exitCode)
}
}
func activate(app *gtk.Application) {
w, _ := mainwindow.New(app)
w.ShowAll()
app.AddWindow(w)
w.Connect("destroy", func() {
})
}