#icons #themes #loader

icon-loader

Crate to load and cache themed icons in 100% safe rust

12 releases

0.4.0 Jun 15, 2023
0.3.6 Apr 7, 2022
0.3.5 May 31, 2021
0.3.4 Mar 23, 2021
0.3.1 Jul 27, 2020

#169 in GUI

Download history 347/week @ 2023-12-05 295/week @ 2023-12-12 535/week @ 2023-12-19 351/week @ 2023-12-26 423/week @ 2024-01-02 437/week @ 2024-01-09 473/week @ 2024-01-16 531/week @ 2024-01-23 557/week @ 2024-01-30 570/week @ 2024-02-06 713/week @ 2024-02-13 807/week @ 2024-02-20 686/week @ 2024-02-27 624/week @ 2024-03-05 600/week @ 2024-03-12 523/week @ 2024-03-19

2,567 downloads per month

MIT license

43KB
858 lines

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

Dependencies

~1.4–7.5MB
~33K SLoC