mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
reorganize widget modules
This commit is contained in:
parent
b9b226cc54
commit
4903968309
47 changed files with 352 additions and 786 deletions
|
|
@ -1,24 +1,36 @@
|
|||
mod widget;
|
||||
use gtk::{pango::EllipsizeMode, Label};
|
||||
|
||||
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
|
||||
|
||||
pub struct Title {
|
||||
widget: widget::Title,
|
||||
widget: Label,
|
||||
}
|
||||
|
||||
impl Title {
|
||||
// Construct
|
||||
pub fn new() -> Title {
|
||||
Self {
|
||||
widget: widget::Title::new(),
|
||||
}
|
||||
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: &str) {
|
||||
self.widget.update(text);
|
||||
if text.is_empty() {
|
||||
self.widget.set_text(DEFAULT_TEXT);
|
||||
} else {
|
||||
self.widget
|
||||
.set_text(&format!("{} - {}", text, DEFAULT_TEXT));
|
||||
}
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn widget(&self) -> &widget::Title {
|
||||
pub fn widget(&self) -> &Label {
|
||||
&self.widget
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue