Skip to main content

FreedesktopLoader

Struct FreedesktopLoader 

Source
pub struct FreedesktopLoader<'a> { /* private fields */ }
Expand description

Loader for freedesktop.org icon themes (GTK / Linux).

Honors .theme() for BOTH role-based and name-based lookups — unlike the previous single-struct design, no dispatch layer can silently drop the theme override.

use native_theme::icons::FreedesktopLoader;
use native_theme::theme::IconRole;

// By role, system theme:
let _icon = FreedesktopLoader::new(IconRole::ActionCopy).load();

// By name, explicit theme + size + symbolic fg color:
let _icon = FreedesktopLoader::new("edit-copy")
    .theme("Adwaita")
    .size(48)
    .color([0, 0, 0])
    .load();

Implementations§

Source§

impl<'a> FreedesktopLoader<'a>

Source

pub fn new(id: impl Into<IconId<'a>>) -> Self

Create a freedesktop loader. Defaults: size 24, no fg_color, system theme.

Source

pub fn size(self, size: u16) -> Self

Set the requested icon size in pixels (default 24).

Source

pub fn color(self, rgb: [u8; 3]) -> Self

Set the foreground color for GTK symbolic icon colorization.

Source

pub fn color_opt(self, rgb: Option<[u8; 3]>) -> Self

Set the foreground color if Some, leave default if None.

Source

pub fn theme(self, theme: &'a str) -> Self

Override the freedesktop icon theme (e.g. “Adwaita”, “breeze”). When unset, uses the system-detected theme.

Source

pub fn load(self) -> Option<IconData>

Load the icon, returning its data.

Source

pub fn load_indicator(theme: Option<&str>) -> Option<AnimatedIcon>

Load the theme’s animated process-working spinner.

theme of None uses the system-detected theme; Some(t) overrides. Associated function (no self) — the spinner is a property of the theme, not of any particular icon id.

Trait Implementations§

Source§

impl<'a> Debug for FreedesktopLoader<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FreedesktopLoader<'a>

§

impl<'a> !Send for FreedesktopLoader<'a>

§

impl<'a> !Sync for FreedesktopLoader<'a>

§

impl<'a> !UnwindSafe for FreedesktopLoader<'a>

§

impl<'a> Freeze for FreedesktopLoader<'a>

§

impl<'a> Unpin for FreedesktopLoader<'a>

§

impl<'a> UnsafeUnpin for FreedesktopLoader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.