App launcher view
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
|
||||
use wgui::{
|
||||
assets::AssetPath,
|
||||
globals::WguiGlobals,
|
||||
i18n::Translation,
|
||||
layout::{Layout, WidgetID},
|
||||
parser::{ParseDocumentParams, ParserState},
|
||||
parser::{Fetchable, ParseDocumentParams, ParserState},
|
||||
widget::label::WidgetLabel,
|
||||
};
|
||||
|
||||
use crate::util::desktop_finder::DesktopEntry;
|
||||
@@ -10,8 +14,7 @@ use crate::util::desktop_finder::DesktopEntry;
|
||||
pub struct View {
|
||||
#[allow(dead_code)]
|
||||
pub state: ParserState,
|
||||
|
||||
entry: DesktopEntry,
|
||||
//entry: DesktopEntry,
|
||||
}
|
||||
|
||||
pub struct Params<'a> {
|
||||
@@ -30,9 +33,30 @@ impl View {
|
||||
};
|
||||
|
||||
let mut state = wgui::parser::parse_from_assets(doc_params, params.layout, params.parent_id)?;
|
||||
let id_icon_parent = state.get_widget_id("icon_parent")?;
|
||||
|
||||
// app icon
|
||||
if let Some(icon_path) = ¶ms.entry.icon_path {
|
||||
let mut template_params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
||||
template_params.insert("path".into(), icon_path.as_str().into());
|
||||
state.instantiate_template(
|
||||
doc_params,
|
||||
"ApplicationIcon",
|
||||
params.layout,
|
||||
id_icon_parent,
|
||||
template_params,
|
||||
)?;
|
||||
}
|
||||
|
||||
let mut label_title = state.fetch_widget_as::<WidgetLabel>(¶ms.layout.state, "label_title")?;
|
||||
|
||||
label_title.set_text_simple(
|
||||
&mut params.globals.get(),
|
||||
Translation::from_raw_text(¶ms.entry.app_name),
|
||||
);
|
||||
|
||||
Ok(Self {
|
||||
entry: params.entry,
|
||||
//entry: params.entry,
|
||||
state,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user