Fix empty view.

This commit is contained in:
Jordan Petridis
2017-12-01 06:00:06 +02:00
parent 3fca086d14
commit fb6fc68d23
3 changed files with 14 additions and 12 deletions
+13 -6
View File
@@ -11,12 +11,20 @@ use views::empty::EmptyView;
#[derive(Debug)]
pub struct Content {
pub stack: gtk::Stack,
pub state: ContentState,
widget: PodcastWidget,
pub podcasts: PopulatedView,
podcasts: PopulatedView,
empty: EmptyView,
}
// #[derive(Debug)]
// pub struct Content {
// pub stack: gtk::Stack,
// pub state: ContentState,
// widget: PodcastWidget,
// pub podcasts: PopulatedView,
// empty: EmptyView,
// }
#[derive(Debug)]
#[allow(dead_code)]
// TODO: find a way to wrap gtk::Stack into a State machine.
@@ -32,12 +40,9 @@ impl Content {
let widget = PodcastWidget::new();
let pop = PopulatedView::new();
let empty = EmptyView::new();
// TODO: Avoid cloning
let state = ContentState::Populated(pop.clone());
let content = Content {
stack,
state,
widget,
empty,
podcasts: pop,
@@ -55,12 +60,14 @@ impl Content {
self.stack.add_named(&self.podcasts.container, "podcasts");
self.stack.add_named(&self.empty.container, "empty");
// FIXME: needs actuall logic
self.stack.set_visible_child_name("podcasts")
}
fn init(&self) {
self.setup_stack();
self.podcasts.init(&self.stack);
if self.podcasts.flowbox.get_children().is_empty() {
self.stack.set_visible_child_name("empty");
}
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ use utils::get_pixbuf_from_path;
#[derive(Debug, Clone)]
pub struct PopulatedView {
pub container: gtk::Box,
flowbox: gtk::FlowBox,
pub flowbox: gtk::FlowBox,
viewport: gtk::Viewport,
}