mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-03-13 06:01:21 +00:00
make results optional
This commit is contained in:
parent
89aed28056
commit
ad8ebe87e5
@ -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
|
||||
|
@ -57,11 +57,11 @@ impl Main {
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn tab_page_title(&self) -> GString {
|
||||
pub fn tab_page_title(&self) -> Option<GString> {
|
||||
self.tab.page_title()
|
||||
}
|
||||
|
||||
pub fn tab_page_description(&self) -> GString {
|
||||
pub fn tab_page_description(&self) -> Option<GString> {
|
||||
self.tab.page_description()
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ impl Tab {
|
||||
}
|
||||
|
||||
// Getters
|
||||
pub fn page_title(&self) -> GString {
|
||||
pub fn page_title(&self) -> Option<GString> {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
// Get default widget to extract it name as the ID for childs
|
||||
@ -159,15 +159,15 @@ impl Tab {
|
||||
let id = &widget.widget_name();
|
||||
// Get page by widget ID
|
||||
if let Some(page) = self.pages.borrow().get(id) {
|
||||
return page.title();
|
||||
return Some(page.title());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GString::new() // @TODO
|
||||
None
|
||||
}
|
||||
|
||||
pub fn page_description(&self) -> GString {
|
||||
pub fn page_description(&self) -> Option<GString> {
|
||||
// Get current page
|
||||
if let Some(page_number) = self.widget.current_page() {
|
||||
// Get default widget to extract it name as the ID for childs
|
||||
@ -176,12 +176,12 @@ impl Tab {
|
||||
let id = &widget.widget_name();
|
||||
// Get page by widget ID
|
||||
if let Some(page) = self.pages.borrow().get(id) {
|
||||
return page.description();
|
||||
return Some(page.description());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GString::new() // @TODO
|
||||
None
|
||||
}
|
||||
|
||||
pub fn widget(&self) -> &Notebook {
|
||||
|
Loading…
x
Reference in New Issue
Block a user