icon-loader

Crates.ioicon-loader
lib.rsicon-loader
version0.4.0
sourcesrc
created_at2020-06-17 20:13:46.415798
updated_at2023-06-15 14:39:52.397072
descriptionCrate to load and cache themed icons in 100% safe rust.
homepage
repositoryhttps://gitlab.com/Maldela/rust-icon-loader
max_upload_size
id255018
size43,418
Malte Veerman (Maldela)

documentation

README

unsafe forbidden License

Rust Icon Loader

A crate that loads and caches themed icons in 100% safe rust.

Usage

Just add it to your cargo.toml file like this:

[dependencies]
icon-loader = "0.4"

Cargo-Features

Standard Features

  • kde: Feature that lets you read the default system theme name from '~/.config/kdeglobals'.
  • gtk: Feature that lets you read the default system theme name from '~/.config/gtk-3.0/settings.ini'.

Additional Features

  • theme_error_log: Feature that uses the log crate to log errors that occur while parsing icon themes.

Examples

  • Using a global IconLoader object to load icons from the systems hicolor 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();

if let Some(icon) = loader.load_icon("icon_name") {
    let path = icon.file_for_size(32).path();
}

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Commit count: 64

cargo fmt