mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
use default label text on value is empty
This commit is contained in:
parent
3d2bca138e
commit
814c513743
1 changed files with 4 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
use gtk::{glib::GString, pango::EllipsizeMode, Label};
|
use gtk::{glib::GString, pango::EllipsizeMode, Label};
|
||||||
|
|
||||||
|
const DEFAULT_LABEL_TEXT: &str = "New page";
|
||||||
|
|
||||||
pub struct Title {
|
pub struct Title {
|
||||||
widget: Label,
|
widget: Label,
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +11,7 @@ impl Title {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
widget: Label::builder()
|
widget: Label::builder()
|
||||||
.label("New page")
|
.label(DEFAULT_LABEL_TEXT)
|
||||||
.ellipsize(EllipsizeMode::End)
|
.ellipsize(EllipsizeMode::End)
|
||||||
.width_chars(16)
|
.width_chars(16)
|
||||||
.single_line_mode(true)
|
.single_line_mode(true)
|
||||||
|
|
@ -21,7 +23,7 @@ impl Title {
|
||||||
pub fn update(&self, title: Option<&GString>) {
|
pub fn update(&self, title: Option<&GString>) {
|
||||||
match title {
|
match title {
|
||||||
Some(title) => self.widget.set_text(title),
|
Some(title) => self.widget.set_text(title),
|
||||||
None => self.widget.set_text(""), // @TODO None/false option
|
None => self.widget.set_text(DEFAULT_LABEL_TEXT),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue