mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 17:15:28 +00:00
create parental app mod
This commit is contained in:
parent
2461f2a0fb
commit
b2aa3af46a
37 changed files with 176 additions and 111 deletions
35
src/app/browser/header/subject/description.rs
Normal file
35
src/app/browser/header/subject/description.rs
Normal 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
|
||||
}
|
||||
}
|
||||
41
src/app/browser/header/subject/title.rs
Normal file
41
src/app/browser/header/subject/title.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue