[−][src]Struct icon_loader::IconLoader
The central icon loader struct.
It lets you load and cache named theme icons from system themes as well as custom themes.
Implementations
impl IconLoader
[src]
pub fn new() -> Self
[src]
Creates a new IconLoader
.
pub fn load_icon(&self, icon_name: impl AsRef<str>) -> Result<Arc<Icon>>
[src]
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.
pub fn theme_name(&self) -> &str
[src]
Returns the currently used theme name.
See also update_theme_name
.
pub fn fallback_theme_name(&self) -> &str
[src]
Returns the currently used fallback theme name.
See also set_fallback_theme_name
.
pub fn search_paths(&self) -> Cow<'_, [PathBuf]>
[src]
Returns the paths that are searched for icon themes.
pub fn set_search_paths(&mut self, search_paths: impl Into<SearchPaths>)
[src]
Sets the paths where to search for icon themes.
Arguments
search_paths
- The paths where to look for icon themes. Anything that implementsIntoIterator<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.
pub fn set_theme_name_provider(
&mut self,
theme_name_provider: impl Into<ThemeNameProvider>
)
[src]
&mut self,
theme_name_provider: impl Into<ThemeNameProvider>
)
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 implementsInto<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);
update_theme_name
needs to be called after setting a new theme name provider.
pub fn update_theme_name(&mut self) -> Result<()>
[src]
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 set_theme_name_provider
.
pub fn set_fallback_theme_name(
&mut self,
fallback_theme_name: impl Into<String>
)
[src]
&mut self,
fallback_theme_name: impl Into<String>
)
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'.
pub fn theme_exists(&self, theme_name: impl AsRef<str>) -> bool
[src]
Returns whether a theme with the name theme_name
exists in the current search paths.
Trait Implementations
impl Debug for IconLoader
[src]
impl Default for IconLoader
[src]
Auto Trait Implementations
impl !RefUnwindSafe for IconLoader
impl Send for IconLoader
impl Sync for IconLoader
impl Unpin for IconLoader
impl !UnwindSafe for IconLoader
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,