mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 01:25:27 +00:00
make results optional
This commit is contained in:
parent
89aed28056
commit
ad8ebe87e5
6 changed files with 27 additions and 23 deletions
|
|
@ -25,7 +25,7 @@ impl Header {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, title: GString, description: GString) {
|
||||
pub fn update(&self, title: Option<GString>, description: Option<GString>) {
|
||||
self.subject.update(title, description);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use gtk::glib::GString;
|
||||
use gtk::prelude::WidgetExt;
|
||||
use gtk::{pango::EllipsizeMode, Label};
|
||||
|
||||
|
|
@ -19,9 +20,12 @@ impl Description {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, text: &str) {
|
||||
self.widget.set_text(text);
|
||||
self.widget.set_visible(!text.is_empty());
|
||||
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
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ impl Subject {
|
|||
}
|
||||
|
||||
// Actions
|
||||
pub fn update(&self, title: GString, description: GString) {
|
||||
self.title.update(&title);
|
||||
self.description.update(&description);
|
||||
pub fn update(&self, title: Option<GString>, description: Option<GString>) {
|
||||
self.title.update(title);
|
||||
self.description.update(description);
|
||||
}
|
||||
|
||||
// Getters
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue