Icons and styles use xyz.holanet.Nasin config
This commit is contained in:
+32
-4
@@ -144,15 +144,43 @@ func RunApplication (application Application) {
|
||||
}
|
||||
flag.Parse()
|
||||
|
||||
// open config
|
||||
globalConfig, err := ApplicationConfig(GlobalApplicationDescription())
|
||||
if err != nil { log.Fatalln("nasin: could not open config:", err) }
|
||||
defer globalConfig.Close()
|
||||
styleConfigKey := "Style"
|
||||
iconSetConfigKey := "IconSet"
|
||||
|
||||
// registry
|
||||
// TODO: rebuild registry around the config
|
||||
reg := new(registrar.Registrar)
|
||||
backend, err := reg.SetBackend()
|
||||
if err != nil { log.Fatalln("nasin: could not register backend:", err) }
|
||||
err = reg.SetTheme()
|
||||
if err != nil { log.Fatalln("nasin: could not set theme:", err) }
|
||||
err = reg.SetIconSet()
|
||||
if err != nil { log.Fatalln("nasin: could not set icon set:", err) }
|
||||
err = reg.SetFaceSet()
|
||||
if err != nil { log.Fatalln("nasin: could not set face set:", err) }
|
||||
updateStyle := func () {
|
||||
value, err := globalConfig.GetString(styleConfigKey, "")
|
||||
if err != nil { log.Fatalln("nasin: could not set theme:", err) }
|
||||
err = reg.SetStyle(value)
|
||||
if err != nil { log.Fatalln("nasin: could not set theme:", err) }
|
||||
}
|
||||
updateIconSet := func () {
|
||||
value, err := globalConfig.GetString(iconSetConfigKey, "")
|
||||
if err != nil { log.Fatalln("nasin: could not set icon set:", err) }
|
||||
err = reg.SetIconSet(value)
|
||||
if err != nil { log.Fatalln("nasin: could not set icon set:", err) }
|
||||
}
|
||||
updateStyle()
|
||||
updateIconSet()
|
||||
|
||||
globalConfig.OnChange(func (key string) {
|
||||
switch key {
|
||||
case styleConfigKey: updateStyle()
|
||||
case iconSetConfigKey: updateIconSet()
|
||||
}
|
||||
})
|
||||
|
||||
// init application
|
||||
err = application.Init()
|
||||
if err != nil { log.Fatalln("nasin: could not run application:", err) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user