Expand description
Crate to load and cache themed icons.
§Examples
- Using a global
IconLoader
object to load icons from the systemshicolor
icon theme:
use icon_loader::icon_loader_hicolor;
if let Some(icon) = icon_loader_hicolor().load_icon("audio-headphones") {
let path = icon.file_for_size(64).path();
}
- Loading icons from the default icon theme set in KDE:
use icon_loader::IconLoader;
let loader = IconLoader::new_kde().unwrap();
if let Some(icon) = loader.load_icon("audio-headphones") {
let path = icon.file_for_size(64).path();
}
- Loading icons from a custom theme in a provided folder:
use icon_loader::IconLoader;
let mut loader = IconLoader::new();
loader.set_search_paths(&["path_to_your_icon_theme"]);
loader.set_theme_name_provider("name_of_your_icon_theme");
loader.update_theme_name().unwrap();
if let Some(icon) = loader.load_icon("icon_name") {
let path = icon.file_for_size(32).path();
}
Structs§
- Icon
- Struct containing information about a themed icon.
- IconDir
- Struct that holds information about a directory containing a set of icons with a particular size.
- Icon
File - Struct containing information about a single icon file on disk.
- Icon
Loader - The central icon loader struct.
Enums§
- Error
- Error type returned by this crate.
- Icon
File Type - Enum representing the different file types an icon can be.
- Icon
Size Type - The size type of icons contained in an
IconDir
. - Provider
Error - Error type returned by
ThemeNameProvider
. - Search
Paths - Enum that provides a list of directories to
IconLoader
to search for icons in. - Theme
Name Provider - Enum that provides a theme name to
IconLoader
. It can either load the system theme name from the KDE or GTK config files or provide a fixed string or a theme name yielded by a completely customizable function. The last option allows users to load their own config files for example.
Functions§
- icon_
loader_ hicolor - This function returns a reference to a global
IconLoader
object with default settings.
Type Aliases§
- Result
- Type alias for
std::result::Result<T, Error>