Skip to main content

load_icon_from_theme

Function load_icon_from_theme 

Source
pub fn load_icon_from_theme(
    role: IconRole,
    set: IconSet,
    preferred_theme: &str,
) -> Option<IconData>
Expand description

Load an icon using a specific freedesktop icon theme instead of the system default.

For IconSet::Freedesktop, loads from the preferred_theme directory (e.g. "Adwaita", "breeze"). For bundled icon sets (IconSet::Material, IconSet::Lucide), preferred_theme is ignored — the icons are compiled in and always available.

Use is_freedesktop_theme_available() first to check whether the theme is installed. If the theme is not installed, freedesktop lookups will fall through to hicolor and may return unexpected icons.

§Examples

use native_theme::{load_icon_from_theme, IconRole, IconSet};

// Bundled sets ignore the theme parameter
let icon = load_icon_from_theme(IconRole::ActionCopy, IconSet::Material, "anything");
assert!(icon.is_some());