Some checks failed
Security Scan / security (push) Failing after 24s
New stub files: - browser_manager.go, browser_window.go (95 methods, full Window interface) - clipboard.go, context_menu.go, dialog.go (33 dialog methods) - environment.go, events.go, keybinding.go - menuitem.go, screen.go, services.go - webview_window_options.go (574 lines, all platform types) - window.go (Window interface ~50 methods) - window_manager_expanded.go (Get, GetByID) - application_options.go (Options, platform options, iOS/Android) App struct expanded with all manager fields. WebviewWindow and BrowserWindow both satisfy Window interface. GetAll() returns []Window (was []any). All stubs compile clean: GOWORK=off go build ./... Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
85 lines
2 KiB
Go
85 lines
2 KiB
Go
package application
|
|
|
|
import "sync"
|
|
|
|
// EnvironmentInfo holds information about the host environment.
|
|
//
|
|
// info := manager.Info()
|
|
// if info.IsDarkMode { applyDarkTheme() }
|
|
type EnvironmentInfo struct {
|
|
OS string
|
|
Arch string
|
|
Debug bool
|
|
IsDarkMode bool
|
|
AccentColour string
|
|
PlatformInfo map[string]any
|
|
}
|
|
|
|
// EnvironmentManager tracks environment state in-memory.
|
|
//
|
|
// manager := &EnvironmentManager{}
|
|
// manager.SetDarkMode(true)
|
|
// dark := manager.IsDarkMode() // true
|
|
type EnvironmentManager struct {
|
|
mu sync.RWMutex
|
|
darkMode bool
|
|
accentColour string
|
|
operatingSystem string
|
|
architecture string
|
|
debugMode bool
|
|
}
|
|
|
|
// SetDarkMode sets the dark mode state used by IsDarkMode.
|
|
//
|
|
// manager.SetDarkMode(true)
|
|
func (em *EnvironmentManager) SetDarkMode(darkMode bool) {
|
|
em.mu.Lock()
|
|
em.darkMode = darkMode
|
|
em.mu.Unlock()
|
|
}
|
|
|
|
// IsDarkMode returns true when the environment is in dark mode.
|
|
//
|
|
// if manager.IsDarkMode() { applyDarkTheme() }
|
|
func (em *EnvironmentManager) IsDarkMode() bool {
|
|
em.mu.RLock()
|
|
defer em.mu.RUnlock()
|
|
return em.darkMode
|
|
}
|
|
|
|
// SetAccentColour sets the accent colour returned by GetAccentColor.
|
|
//
|
|
// manager.SetAccentColour("rgb(0,122,255)")
|
|
func (em *EnvironmentManager) SetAccentColour(colour string) {
|
|
em.mu.Lock()
|
|
em.accentColour = colour
|
|
em.mu.Unlock()
|
|
}
|
|
|
|
// GetAccentColor returns the stored accent colour, or the default blue if unset.
|
|
//
|
|
// colour := manager.GetAccentColor() // "rgb(0,122,255)"
|
|
func (em *EnvironmentManager) GetAccentColor() string {
|
|
em.mu.RLock()
|
|
defer em.mu.RUnlock()
|
|
if em.accentColour == "" {
|
|
return "rgb(0,122,255)"
|
|
}
|
|
return em.accentColour
|
|
}
|
|
|
|
// Info returns a snapshot of the current environment state.
|
|
//
|
|
// info := manager.Info()
|
|
// _ = info.OS // e.g. "linux"
|
|
func (em *EnvironmentManager) Info() EnvironmentInfo {
|
|
em.mu.RLock()
|
|
defer em.mu.RUnlock()
|
|
return EnvironmentInfo{
|
|
OS: em.operatingSystem,
|
|
Arch: em.architecture,
|
|
Debug: em.debugMode,
|
|
IsDarkMode: em.darkMode,
|
|
AccentColour: em.accentColour,
|
|
}
|
|
}
|