fix(ui): address Copilot review for adw color scheme handling
- commit
- 930797099ae5cb4925fc424f8bd0a86ad935a4a5
- author
- bnema · · 2025-12-29 18:45 UTC
- parent
- e7d5aff
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
1 file · +8 -8
M internal/ui/app.go +8 -8
| @@ -156,6 +156,10 @@ func (a *App) Run(ctx context.Context, args []string) int { | |||
| 156 | 156 | log := logging.FromContext(ctx) | |
| 157 | 157 | log.Debug().Msg("creating GTK application") | |
| 158 | 158 | ||
| 159 | + | // Initialize libadwaita once (required before using StyleManager). | |
| 160 | + | // This also initializes GTK implicitly. | |
| 161 | + | adw.Init() | |
| 162 | + | ||
| 159 | 163 | // TODO: Use AppID once puregotk GC bug is fixed (nullable-string-gc-memory-corruption) | |
| 160 | 164 | a.gtkApp = gtk.NewApplication(nil, gio.GApplicationFlagsNoneValue) | |
| 161 | 165 | if a.gtkApp == nil { | |
| @@ -218,12 +222,8 @@ func (a *App) onActivate(ctx context.Context) { | |||
| 218 | 222 | func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | |
| 219 | 223 | log := logging.FromContext(ctx) | |
| 220 | 224 | ||
| 221 | - | // Initialize libadwaita (required before using StyleManager). | |
| 222 | - | // This also initializes GTK implicitly. | |
| 223 | - | adw.Init() | |
| 224 | - | ||
| 225 | - | // Get the config color scheme preference | |
| 226 | - | scheme := "system" | |
| 225 | + | // Get the config color scheme preference (default follows system theme) | |
| 226 | + | scheme := "default" | |
| 227 | 227 | if a.deps != nil && a.deps.Config != nil && a.deps.Config.Appearance.ColorScheme != "" { | |
| 228 | 228 | scheme = a.deps.Config.Appearance.ColorScheme | |
| 229 | 229 | } | |
| @@ -244,8 +244,8 @@ func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | |||
| 244 | 244 | case "light", "prefer-light": | |
| 245 | 245 | adwScheme = adw.ColorSchemeForceLightValue | |
| 246 | 246 | default: | |
| 247 | - | // "system" or empty - follow system preference | |
| 248 | - | adwScheme = adw.ColorSchemePreferLightValue | |
| 247 | + | // "default" or empty - follow system preference | |
| 248 | + | adwScheme = adw.ColorSchemeDefaultValue | |
| 249 | 249 | } | |
| 250 | 250 | ||
| 251 | 251 | styleMgr.SetColorScheme(adwScheme) | |
| @@ -156,6 +156,10 @@ func (a *App) Run(ctx context.Context, args []string) int { | |||||
| 156 | log := logging.FromContext(ctx) | 156 | log := logging.FromContext(ctx) | ||
| 157 | log.Debug().Msg("creating GTK application") | 157 | log.Debug().Msg("creating GTK application") | ||
| 158 | 158 | ||||
| 159 | + | // Initialize libadwaita once (required before using StyleManager). | |||
| 160 | + | // This also initializes GTK implicitly. | |||
| 161 | + | adw.Init() | |||
| 162 | + | ||||
| 159 | // TODO: Use AppID once puregotk GC bug is fixed (nullable-string-gc-memory-corruption) | 163 | // TODO: Use AppID once puregotk GC bug is fixed (nullable-string-gc-memory-corruption) | ||
| 160 | a.gtkApp = gtk.NewApplication(nil, gio.GApplicationFlagsNoneValue) | 164 | a.gtkApp = gtk.NewApplication(nil, gio.GApplicationFlagsNoneValue) | ||
| 161 | if a.gtkApp == nil { | 165 | if a.gtkApp == nil { | ||
| @@ -218,12 +222,8 @@ func (a *App) onActivate(ctx context.Context) { | |||||
| 218 | func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | 222 | func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | ||
| 219 | log := logging.FromContext(ctx) | 223 | log := logging.FromContext(ctx) | ||
| 220 | 224 | ||||
| 221 | - | // Initialize libadwaita (required before using StyleManager). | 225 | + | // Get the config color scheme preference (default follows system theme) |
| 222 | - | // This also initializes GTK implicitly. | 226 | + | scheme := "default" |
| 223 | - | adw.Init() | |||
| 224 | - | ||||
| 225 | - | // Get the config color scheme preference | |||
| 226 | - | scheme := "system" | |||
| 227 | if a.deps != nil && a.deps.Config != nil && a.deps.Config.Appearance.ColorScheme != "" { | 227 | if a.deps != nil && a.deps.Config != nil && a.deps.Config.Appearance.ColorScheme != "" { | ||
| 228 | scheme = a.deps.Config.Appearance.ColorScheme | 228 | scheme = a.deps.Config.Appearance.ColorScheme | ||
| 229 | } | 229 | } | ||
| @@ -244,8 +244,8 @@ func (a *App) applyGTKColorSchemePreference(ctx context.Context) { | |||||
| 244 | case "light", "prefer-light": | 244 | case "light", "prefer-light": | ||
| 245 | adwScheme = adw.ColorSchemeForceLightValue | 245 | adwScheme = adw.ColorSchemeForceLightValue | ||
| 246 | default: | 246 | default: | ||
| 247 | - | // "system" or empty - follow system preference | 247 | + | // "default" or empty - follow system preference |
| 248 | - | adwScheme = adw.ColorSchemePreferLightValue | 248 | + | adwScheme = adw.ColorSchemeDefaultValue |
| 249 | } | 249 | } | ||
| 250 | 250 | ||||
| 251 | styleMgr.SetColorScheme(adwScheme) | 251 | styleMgr.SetColorScheme(adwScheme) | ||