From b7ed63ac426feccb469cafeb1d0abc6f0efeba94 Mon Sep 17 00:00:00 2001 From: Masterlocker Date: Wed, 31 Jul 2024 18:55:02 +0200 Subject: [PATCH 1/2] Windows theme fix --- ui/theme/theme.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 1f273728..41f1bc86 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -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 From e28692d7c77c82e43ec2556f63d380feddf79b2f Mon Sep 17 00:00:00 2001 From: Masterlocker Date: Thu, 1 Aug 2024 13:13:30 +0200 Subject: [PATCH 2/2] Update theme.go --- ui/theme/theme.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/theme/theme.go b/ui/theme/theme.go index 41f1bc86..761ded49 100644 --- a/ui/theme/theme.go +++ b/ui/theme/theme.go @@ -209,14 +209,13 @@ func (m *MyTheme) ListThemeFiles() map[string]string { pattern := filepath.Join(m.themeFileDir, "/*.toml") files, err := filepath.Glob(pattern) if err != nil { - log.Fatalf("Failed to glob files: %v", err) + log.Printf("Failed to glob files: %v", err) } result := make(map[string]string) 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 {