// Package assets exposes the embedded PNG icon set under assets/icons. // Icons are exposed as raw bytes; the UI layer wraps them with Gio's // image decoder on demand. package assets import ( "embed" "fmt" "io/fs" "git.wxccs.org/iceking2nd/winauth-go/internal/global" ) //go:embed icons/*.png var iconsFS embed.FS // Icon returns the bytes of a named icon (e.g. "GoogleIcon.png"). If the // requested icon is missing, a Debug log is emitted and (nil, error) is // returned so the caller can fall back to a placeholder. func Icon(name string) ([]byte, error) { const fn = "assets.Icon" data, err := iconsFS.ReadFile("icons/" + name) if err != nil { global.Log.WithField("func", fn).WithField("name", name). Debug("icon not found") return nil, fmt.Errorf("assets: icon %q: %w", name, err) } return data, nil } // IconNames lists every embedded icon. Useful for the "choose an icon" // dialog in the UI. func IconNames() []string { const fn = "assets.IconNames" entries, err := fs.ReadDir(iconsFS, "icons") if err != nil { global.Log.WithField("func", fn).WithError(err).Warn("read embedded icons") return nil } out := make([]string, 0, len(entries)) for _, e := range entries { if !e.IsDir() { out = append(out, e.Name()) } } return out }