EpisodesStack: Implemnt the transition between empty and populated.

This commit is contained in:
Jordan Petridis 2017-12-20 21:25:00 +02:00
parent db59bed69d
commit 336846f6dd
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 34 additions and 4 deletions

View File

@ -173,15 +173,17 @@ impl EpisodeStack {
}
fn update(&self) {
// FIXME: figure out if it should switch to empty view
let vis = self.stack.get_visible_child_name().unwrap();
let old = self.stack.get_child_by_name("episodes").unwrap();
let eps = EpisodesView::new();
self.stack.remove(&old);
self.stack.add_named(&eps.container, "episodes");
self.stack.set_visible_child_name(&vis);
if eps.is_empty() {
self.stack.set_visible_child_name("empty");
} else {
self.stack.set_visible_child_name("episodes");
}
old.destroy();
}

View File

@ -163,6 +163,34 @@ impl EpisodesView {
view.container.show_all();
Rc::new(view)
}
pub fn is_empty(&self) -> bool {
if !self.today_list.get_children().is_empty() {
return false;
}
if !self.yday_list.get_children().is_empty() {
return false;
}
if !self.week_list.get_children().is_empty() {
return false;
}
if !self.month_list.get_children().is_empty() {
return false;
}
if !self.year_list.get_children().is_empty() {
return false;
}
if !self.rest_list.get_children().is_empty() {
return false;
}
true
}
}
// TODO: Avoid epoch calculations, use chrono instead.