create parental app mod

This commit is contained in:
yggverse 2024-10-02 02:14:00 +03:00
parent 2461f2a0fb
commit b2aa3af46a
37 changed files with 176 additions and 111 deletions

View file

@ -0,0 +1,35 @@
use gtk::glib::GString;
use gtk::prelude::WidgetExt;
use gtk::{pango::EllipsizeMode, Label};
pub struct Description {
widget: Label,
}
impl Description {
// Construct
pub fn new() -> Self {
let widget = Label::builder()
.css_classes(["subtitle"])
.single_line_mode(true)
.ellipsize(EllipsizeMode::End)
.visible(false)
.build();
Self { widget }
}
// Actions
pub fn update(&self, text: Option<GString>) {
match text {
Some(value) => self.widget.set_text(&value),
None => self.widget.set_text(""), // @TODO
};
self.widget.set_visible(!self.widget.text().is_empty());
}
// Getters
pub fn widget(&self) -> &Label {
&self.widget
}
}

View file

@ -0,0 +1,41 @@
use gtk::{glib::GString, pango::EllipsizeMode, Label};
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
pub struct Title {
widget: Label,
}
impl Title {
// Construct
pub fn new() -> Self {
let widget = gtk::Label::builder()
.css_classes(["title"])
.single_line_mode(true)
.ellipsize(EllipsizeMode::End)
.label(DEFAULT_TEXT)
.build();
Self { widget }
}
// Actions
pub fn update(&self, text: Option<GString>) {
let mut name = Vec::new();
if let Some(value) = text {
if !value.is_empty() {
name.push(value);
}
}
name.push(GString::from(DEFAULT_TEXT));
self.widget.set_text(&name.join(" - "));
}
// Getters
pub fn widget(&self) -> &Label {
&self.widget
}
}