hook custom themes up to Settings dialog

This commit is contained in:
Drew Weymouth
2023-06-20 18:33:37 -07:00
parent 4a399c51b7
commit 02cac23d9a
5 changed files with 57 additions and 32 deletions
+5 -5
View File
@@ -48,8 +48,8 @@ type MyTheme struct {
var _ fyne.Theme = (*MyTheme)(nil)
func NewMyTheme(config *backend.ThemeConfig) *MyTheme {
m := &MyTheme{config: config}
func NewMyTheme(config *backend.ThemeConfig, themeFileDir string) *MyTheme {
m := &MyTheme{config: config, themeFileDir: themeFileDir}
m.defaultThemeFile, _ = DecodeThemeFile(bytes.NewReader(res.ResDefaultToml.StaticContent))
m.createThemeIcons()
return m
@@ -142,9 +142,9 @@ func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
func (m *MyTheme) ListThemeFiles() map[string]string {
files, _ := filepath.Glob(m.themeFileDir + "/*.toml")
result := make(map[string]string)
for _, filename := range files {
if themeFile, err := ReadThemeFile(path.Join(m.themeFileDir, filename)); err == nil {
result[filename] = themeFile.SupersonicTheme.Name
for _, filepath := range files {
if themeFile, err := ReadThemeFile(filepath); err == nil {
result[path.Base(filepath)] = themeFile.SupersonicTheme.Name
}
}
return result