#icon #theme #loader

icon-loader

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

11 releases

0.3.6 Apr 7, 2022
0.3.5 May 31, 2021
0.3.4 Mar 23, 2021
0.3.3 Nov 19, 2020
0.1.0 Jun 17, 2020

#34 in Caching

Download history 25/week @ 2023-01-20 45/week @ 2023-01-27 106/week @ 2023-02-03 146/week @ 2023-02-10 117/week @ 2023-02-17 84/week @ 2023-02-24 108/week @ 2023-03-03 92/week @ 2023-03-10 56/week @ 2023-03-17 64/week @ 2023-03-24 80/week @ 2023-03-31 181/week @ 2023-04-07 118/week @ 2023-04-14 128/week @ 2023-04-21 87/week @ 2023-04-28 128/week @ 2023-05-05

481 downloads per month

MIT license

40KB
852 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.3"

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

  • Loading icons from the default icon theme set in KDE:
use icon_loader::{IconLoader, ThemeNameProvider};

let mut loader = IconLoader::new();
loader.set_theme_name_provider(ThemeNameProvider::KDE);
loader.update_theme_name().unwrap();

let icon = loader.load_icon("audio-headphones").unwrap();
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();

let icon = loader.load_icon("icon_name").unwrap();
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.2–6MB
~93K SLoC