Fix empty view.
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user