libcosmic/src/icon_theme.rs

27 lines
711 B
Rust
Raw Normal View History

2023-08-02 11:54:07 +02:00
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
2023-08-15 10:51:59 +02:00
//! Select the preferred icon theme.
use std::borrow::Cow;
use std::sync::Mutex;
2023-08-02 11:54:07 +02:00
2024-03-19 16:09:52 -04:00
pub const COSMIC: &str = "Cosmic";
pub(crate) static DEFAULT: Mutex<Cow<'static, str>> = Mutex::new(Cow::Borrowed(COSMIC));
2023-08-02 11:54:07 +02:00
/// The fallback icon theme to search if no icon theme was specified.
#[must_use]
#[allow(clippy::missing_panics_doc)]
#[inline]
2023-08-02 11:54:07 +02:00
pub fn default() -> String {
DEFAULT.lock().unwrap().to_string()
2023-08-02 11:54:07 +02:00
}
/// Set the fallback icon theme to search when loading system icons.
#[allow(clippy::missing_panics_doc)]
#[cold]
pub fn set_default(name: impl Into<Cow<'static, str>>) {
*DEFAULT.lock().unwrap() = name.into();
2023-08-02 11:54:07 +02:00
}