forked from lxn/walk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.go
85 lines (68 loc) · 1.68 KB
/
application.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
83
84
85
// Copyright 2010 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package walk
import (
"time"
)
import (
"github.com/lxn/win"
)
type Settings interface {
Get(key string) (string, bool)
Timestamp(key string) (time.Time, bool)
Put(key, value string) error
PutExpiring(key, value string) error
Remove(key string) error
ExpireDuration() time.Duration
SetExpireDuration(expireDuration time.Duration)
Load() error
Save() error
}
type Persistable interface {
Persistent() bool
SetPersistent(value bool)
SaveState() error
RestoreState() error
}
type Application struct {
organizationName string
productName string
settings Settings
exiting bool
exitCode int
panickingPublisher ErrorEventPublisher
}
var appSingleton *Application = new(Application)
func App() *Application {
return appSingleton
}
func (app *Application) OrganizationName() string {
return app.organizationName
}
func (app *Application) SetOrganizationName(value string) {
app.organizationName = value
}
func (app *Application) ProductName() string {
return app.productName
}
func (app *Application) SetProductName(value string) {
app.productName = value
}
func (app *Application) Settings() Settings {
return app.settings
}
func (app *Application) SetSettings(value Settings) {
app.settings = value
}
func (app *Application) Exit(exitCode int) {
app.exiting = true
app.exitCode = exitCode
win.PostQuitMessage(int32(exitCode))
}
func (app *Application) ExitCode() int {
return app.exitCode
}
func (app *Application) Panicking() *ErrorEvent {
return app.panickingPublisher.Event()
}