Modifica la forma de identificar temas y módulos

Cada módulo y cada tema requerirá a partir de ahora un identificador que
debería ser único y con alguna sintaxis particular aún por definir (por
ejemplo, admitiendo sólo minúsculas y sin espacios).
This commit is contained in:
Manuel Cillero 2022-02-26 21:48:39 +01:00
parent 3764f707da
commit 83fd12b5cc
16 changed files with 65 additions and 30 deletions

View file

@ -5,6 +5,8 @@ use crate::base::component::Chunck;
/// Los temas deben implementar este "trait".
pub trait Theme: Send + Sync {
fn id(&self) -> &'static str;
fn name(&self) -> String;
fn description(&self) -> String {

View file

@ -9,9 +9,9 @@ pub fn register_theme(t: &'static (dyn Theme + 'static)) {
THEMES.write().unwrap().push(t);
}
pub fn find_theme(name: &str) -> Option<&'static (dyn Theme + 'static)> {
pub fn find_theme(id: &str) -> Option<&'static (dyn Theme + 'static)> {
let themes = THEMES.write().unwrap();
match themes.iter().find(|t| t.name() == name) {
match themes.iter().find(|t| t.id() == id) {
Some(theme) => Some(*theme),
_ => None,
}