make results optional

This commit is contained in:
yggverse 2024-09-27 16:23:59 +03:00
parent 89aed28056
commit ad8ebe87e5
6 changed files with 27 additions and 23 deletions

View file

@ -1,4 +1,4 @@
use gtk::{pango::EllipsizeMode, Label};
use gtk::{glib::GString, pango::EllipsizeMode, Label};
const DEFAULT_TEXT: &str = "Yoda"; // @TODO
@ -20,13 +20,13 @@ impl Title {
}
// Actions
pub fn update(&self, text: &str) {
if text.is_empty() {
self.widget.set_text(DEFAULT_TEXT);
} else {
self.widget
.set_text(&format!("{} - {}", text, DEFAULT_TEXT));
}
pub fn update(&self, text: Option<GString>) {
match text {
Some(value) => self
.widget
.set_text(&format!("{} - {}", value, DEFAULT_TEXT)),
None => self.widget.set_text(DEFAULT_TEXT),
};
}
// Getters