Theme -> ThemeDescriptor

This commit is contained in:
Ridan Vandenbergh 2025-06-18 16:05:17 +02:00
parent 7cdc832b48
commit c7ee1e7cad
No known key found for this signature in database
2 changed files with 8 additions and 7 deletions

View file

@ -34,7 +34,7 @@
//! //!
//! To find icons in a theme, its `index.theme` file must be parsed to understand the directory //! To find icons in a theme, its `index.theme` file must be parsed to understand the directory
//! structure within the theme itself. //! structure within the theme itself.
//! This is handled by [Theme]. //! This is handled by [ThemeDescriptor].
//! //!
//! 3a. *Find just one icon* (oneshot): //! 3a. *Find just one icon* (oneshot):
//! //!
@ -60,7 +60,8 @@
mod icon; mod icon;
mod search_dir; mod search_dir;
mod theme; pub mod theme;
mod theme_graph;
pub use search_dir::*; pub use search_dir::*;
pub use theme::*; pub use theme::*;

View file

@ -3,11 +3,11 @@ use freedesktop_entry_parser::low_level::{EntryIter, SectionBytes};
use std::borrow::Cow; use std::borrow::Cow;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
pub type OwnedTheme = Theme<'static>; pub type OwnedThemeDescriptor = ThemeDescriptor<'static>;
pub type OwnedThemeIndex = ThemeIndex<'static>; pub type OwnedThemeIndex = ThemeIndex<'static>;
pub type OwnedDirectoryIndex = DirectoryIndex<'static>; pub type OwnedDirectoryIndex = DirectoryIndex<'static>;
pub struct Theme<'a> { pub struct ThemeDescriptor<'a> {
pub internal_name: String, pub internal_name: String,
pub base_dirs: Vec<Cow<'a, Path>>, pub base_dirs: Vec<Cow<'a, Path>>,
pub index_location: PathBuf, pub index_location: PathBuf,
@ -33,7 +33,7 @@ pub enum ThemeParseError {
ParseError(#[from] freedesktop_entry_parser::ParseError), ParseError(#[from] freedesktop_entry_parser::ParseError),
} }
impl Theme<'_> { impl ThemeDescriptor<'_> {
pub fn new_from_folders(internal_name: String, folders: Vec<PathBuf>) -> std::io::Result<Self> { pub fn new_from_folders(internal_name: String, folders: Vec<PathBuf>) -> std::io::Result<Self> {
let index_location = folders let index_location = folders
.iter() .iter()
@ -52,7 +52,7 @@ impl Theme<'_> {
} }
} }
fn theme_into_owned(theme: Theme) -> OwnedTheme { fn theme_into_owned(theme: ThemeDescriptor) -> OwnedThemeDescriptor {
let base_dirs = theme let base_dirs = theme
.base_dirs .base_dirs
.into_iter() .into_iter()
@ -61,7 +61,7 @@ fn theme_into_owned(theme: Theme) -> OwnedTheme {
.collect(); .collect();
let index = theme.index.into_owned(); let index = theme.index.into_owned();
OwnedTheme { OwnedThemeDescriptor {
base_dirs, base_dirs,
index, index,
..theme ..theme