XDG icon theme loader now uses Wintergreen icons as fallback
This commit is contained in:
parent
fc41696b5e
commit
cf3b7ca651
@ -13,7 +13,7 @@ func Init () error {
|
||||
|
||||
iconThemeName := os.Getenv("TOMO_XDG_ICON_THEME")
|
||||
if iconThemeName != "" {
|
||||
iconTheme, err := xdgIcons.FindThemeWarn(iconThemeName)
|
||||
iconTheme, err := xdgIcons.FindThemeWarn(iconThemeName, theme.IconTheme)
|
||||
if err == nil {
|
||||
theme.IconTheme = iconTheme
|
||||
} else {
|
||||
|
@ -15,13 +15,15 @@ import "git.tebibyte.media/tomo/nasin/internal/theme"
|
||||
|
||||
type iconTheme struct {
|
||||
xdg xdgIconTheme.Theme
|
||||
fallback theme.IconTheme
|
||||
texturesSmall map[tomo.Icon] canvas.Texture
|
||||
texturesMedium map[tomo.Icon] canvas.Texture
|
||||
texturesLarge map[tomo.Icon] canvas.Texture
|
||||
}
|
||||
|
||||
func FindThemeWarn (name string, path ...string) (theme.IconTheme, error) {
|
||||
func FindThemeWarn (name string, fallback theme.IconTheme, path ...string) (theme.IconTheme, error) {
|
||||
this := &iconTheme {
|
||||
fallback: fallback,
|
||||
texturesLarge: make(map[tomo.Icon] canvas.Texture),
|
||||
texturesMedium: make(map[tomo.Icon] canvas.Texture),
|
||||
texturesSmall: make(map[tomo.Icon] canvas.Texture),
|
||||
@ -68,19 +70,33 @@ func (this *iconTheme) xdgIcon (name string, size tomo.IconSize) (canvas.Texture
|
||||
|
||||
func (this *iconTheme) Icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
|
||||
source := this.selectSource(size)
|
||||
if texture, ok := source[icon]; ok { return texture }
|
||||
texture := this.icon(icon, size)
|
||||
source[icon] = texture
|
||||
return texture
|
||||
texture, ok := source[icon]
|
||||
if !ok {
|
||||
texture = this.icon(icon, size)
|
||||
source[icon] = texture
|
||||
}
|
||||
|
||||
if texture == nil {
|
||||
return this.fallback.Icon(icon, size)
|
||||
} else {
|
||||
return texture
|
||||
}
|
||||
}
|
||||
|
||||
func (this *iconTheme) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Texture {
|
||||
icon := tomo.Icon(mime.String())
|
||||
source := this.selectSource(size)
|
||||
if texture, ok := source[icon]; ok { return texture }
|
||||
texture := this.mimeIcon(mime, size)
|
||||
source[icon] = texture
|
||||
return texture
|
||||
texture, ok := source[icon]
|
||||
if !ok {
|
||||
texture = this.mimeIcon(mime, size)
|
||||
source[icon] = texture
|
||||
}
|
||||
|
||||
if texture == nil {
|
||||
return this.fallback.MimeIcon(mime, size)
|
||||
} else {
|
||||
return texture
|
||||
}
|
||||
}
|
||||
|
||||
func (this *iconTheme) icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
|
||||
|
Loading…
Reference in New Issue
Block a user