Return error if icon theme could not be found
This commit is contained in:
parent
d82e802563
commit
bc7b9c58a8
@ -14,6 +14,8 @@ type iconThemeError string
|
|||||||
func (err iconThemeError) Error () string { return string(err) }
|
func (err iconThemeError) Error () string { return string(err) }
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// ErrThemeNotFound indicates that a theme could not be found.
|
||||||
|
ErrThemeNotFound = iconThemeError("theme not found")
|
||||||
// ErrGroupMissing indicates that a required group was not found in an
|
// ErrGroupMissing indicates that a required group was not found in an
|
||||||
// index.theme file.
|
// index.theme file.
|
||||||
ErrGroupMissing = iconThemeError("group missing")
|
ErrGroupMissing = iconThemeError("group missing")
|
||||||
@ -82,7 +84,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if path == nil {
|
if len(path) == 0 {
|
||||||
themeDirs, err := ThemeDirs()
|
themeDirs, err := ThemeDirs()
|
||||||
if err != nil { return Theme { }, nil }
|
if err != nil { return Theme { }, nil }
|
||||||
path = themeDirs
|
path = themeDirs
|
||||||
@ -102,6 +104,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(instances) == 0 { return Theme { }, ErrThemeNotFound }
|
||||||
|
|
||||||
// find an index.theme
|
// find an index.theme
|
||||||
var lastParseErr error
|
var lastParseErr error
|
||||||
@ -149,7 +152,7 @@ func findTheme (name string, trail []string, warn bool, path ...string) (Theme,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no parents were successfuly parsed, inherit from hicolor
|
// if no parents were successfuly parsed, inherit from hicolor
|
||||||
if theme.Inherits == nil && name != "hicolor" {
|
if len(theme.Inherits) == 0 && name != "hicolor" {
|
||||||
hicolor, err := findTheme("hicolor", trail, warn, path...)
|
hicolor, err := findTheme("hicolor", trail, warn, path...)
|
||||||
if err != nil { return Theme { }, err }
|
if err != nil { return Theme { }, err }
|
||||||
theme.Inherits = []Theme { hicolor }
|
theme.Inherits = []Theme { hicolor }
|
||||||
|
Loading…
Reference in New Issue
Block a user