pub struct IconLoader { /* private fields */ }
Expand description

The central icon loader struct.

It lets you load and cache named theme icons from system themes as well as custom themes.

Implementations

Creates a new IconLoader.

Loads the icon with the name icon_name from the current icon theme. If the icon cannot be found, it will be looked for in the fallback icon theme.

Returns the currently used theme name.

See also IconLoader::update_theme_name().

Returns the currently used fallback theme name.

See also IconLoader::set_fallback_theme_name().

Returns the paths that are searched for icon themes.

Sets the paths where to search for icon themes.

Arguments
  • search_paths - The paths where to look for icon themes. Anything that implements IntoIterator<Item = Into<PathBuf>> can be used.
Examples

Custom search paths:

use icon_loader::IconLoader;

let mut loader = IconLoader::new();
loader.set_search_paths(&["/path/to/icon/themes", "/other/path/to/icon/themes"]);

System search paths:

use icon_loader::{IconLoader, SearchPaths};

let mut loader = IconLoader::new();
loader.set_search_paths(SearchPaths::System);

By default these are the system icon paths.

Sets the way in which the used theme name is determined.

Arguments
  • theme_name_provider - The provider of the default icon theme name. Anything that implements Into<ThemeNameProvider> can be used.
Examples

User defined theme name:

use icon_loader::IconLoader;

let mut loader = IconLoader::new();
loader.set_theme_name_provider("theme_name");

KDE system theme:

use icon_loader::{IconLoader, ThemeNameProvider};

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

IconLoader::update_theme_name() needs to be called after setting a new theme name provider.

Queries the set ThemeNameProvider for the theme name to be used. Returns an error, if the set ThemeNameProvider returns an error or the theme with the returned name cannot be found.

Set a theme name provider with IconLoader::set_theme_name_provider().

Sets a new fallback theme name. If an icon cannot be found in the set theme, it will be looked for in the fallback theme. The default fallback theme name is ‘hicolor’.

Returns whether a theme with the name theme_name exists in the current search paths.

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.