Skip to content

Commit

Permalink
Windows theme fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Masterlocker committed Jul 31, 2024
1 parent d630822 commit b7ed63a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions ui/theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,24 @@ func (m *MyTheme) Icon(name fyne.ThemeIconName) fyne.Resource {

// Returns a map [themeFileName] -> displayName
func (m *MyTheme) ListThemeFiles() map[string]string {
files, _ := filepath.Glob(m.themeFileDir + "/*.toml")
// Use filepath.Join to create a cross-platform file path
pattern := filepath.Join(m.themeFileDir, "/*.toml")
files, err := filepath.Glob(pattern)
if err != nil {
log.Fatalf("Failed to glob files: %v", err)
}

result := make(map[string]string)
for _, filepath := range files {
if themeFile, err := ReadThemeFile(filepath); err == nil {
result[path.Base(filepath)] = themeFile.SupersonicTheme.Name
for _, filePath := range files {
// Clean the path to avoid issues with slashes
cleanPath := filepath.Clean(filePath)
log.Printf("Trying to read theme file: %s", cleanPath)

// Now read the theme file, using the cleaned path
if themeFile, err := ReadThemeFile(cleanPath); err == nil {
result[filepath.Base(cleanPath)] = themeFile.SupersonicTheme.Name
} else {
log.Printf("Failed to load theme file: %s, error: %v", cleanPath, err)
}
}
return result
Expand Down

0 comments on commit b7ed63a

Please sign in to comment.