forked from f0cii/ngui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
manifest.go
92 lines (74 loc) · 1.89 KB
/
manifest.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
86
87
88
89
90
91
92
package ngui
import (
"encoding/json"
//"fmt"
"io/ioutil"
"path"
)
const (
manifest_filename = `manifest.json`
first_page = `first_page`
application_title = `application_title`
locale = `locale`
cache_path = `cache_path`
style = `style`
width = `width`
height = `height`
form_fixed = `form_fixed`
enable_transparent = `enable_transparent`
browser_subprocess_path = `browser_subprocess_path`
WindowStyleNormal = 0
WindowStyleCaptionLess = 1
)
type Manifest struct {
manifest revManifest
}
type revManifest map[string]interface{}
func (a *Manifest) BrowserSubprocessPath() string {
return a.Get(browser_subprocess_path).(string)
}
func (a *Manifest) FirstPage() string {
return a.Get(first_page).(string)
}
func (a *Manifest) ApplicationTitle() string {
return a.Get(application_title).(string)
}
func (a *Manifest) Locale() string {
return a.Get(locale).(string)
}
func (a *Manifest) CachePath() string {
return a.Get(cache_path).(string)
}
func (a *Manifest) FormFixed() bool {
return a.Get(form_fixed).(bool)
}
func (a *Manifest) EnableTransparent() bool {
return a.Get(enable_transparent).(bool)
}
func (a *Manifest) Style() int32 {
return int32(a.Get(style).(float64))
}
func (a *Manifest) Width() int32 {
return int32(a.Get(width).(float64))
}
func (a *Manifest) Height() int32 {
return int32(a.Get(height).(float64))
}
func (a *Manifest) Get(key string) interface{} {
v, _ := a.manifest[key]
return v
}
func (a *Manifest) Load() *Manifest {
manifestPath := path.Join(a.Path(), manifest_filename)
//fmt.Printf("manifestPath=%v\n", manifestPath)
data, err := ioutil.ReadFile(manifestPath)
if err != nil {
panic("Load Manifest")
}
//fmt.Println(err)
json.Unmarshal(data, &a.manifest)
return a
}
func (a Manifest) Path() string {
return ExePath()
}