Groupd stack manipulation functions into content module.
This commit is contained in:
@@ -6,9 +6,10 @@ use diesel::associations::Identifiable;
|
||||
use hammond_data::dbqueries;
|
||||
use hammond_data::Podcast;
|
||||
|
||||
use widgets::podcast::*;
|
||||
use utils::get_pixbuf_from_path;
|
||||
|
||||
use content;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PopulatedView {
|
||||
pub container: gtk::Box,
|
||||
@@ -139,39 +140,5 @@ impl PodcastChild {
|
||||
}
|
||||
|
||||
fn on_flowbox_child_activate(stack: >k::Stack, parent: &Podcast) {
|
||||
let old = stack.get_child_by_name("widget").unwrap();
|
||||
let pdw = PodcastWidget::new();
|
||||
pdw.init(stack, parent);
|
||||
|
||||
stack.remove(&old);
|
||||
stack.add_named(&pdw.container, "widget");
|
||||
stack.set_visible_child_full("widget", gtk::StackTransitionType::SlideLeft);
|
||||
|
||||
// aggresive memory cleanup
|
||||
// probably not needed
|
||||
old.destroy();
|
||||
}
|
||||
|
||||
pub fn update_podcasts_view(stack: >k::Stack) {
|
||||
let vis = stack.get_visible_child_name().unwrap();
|
||||
let old = stack.get_child_by_name("podcasts").unwrap();
|
||||
stack.remove(&old);
|
||||
|
||||
let pdw = PopulatedView::new();
|
||||
pdw.init(stack);
|
||||
stack.add_named(&pdw.container, "podcasts");
|
||||
let flowbox = &pdw.flowbox;
|
||||
|
||||
if vis == "empty" && !flowbox.get_children().is_empty() {
|
||||
stack.set_visible_child_name("podcasts");
|
||||
} else if vis == "podcasts" && flowbox.get_children().is_empty() {
|
||||
stack.set_visible_child_name("empty");
|
||||
} else {
|
||||
// preserve the visible widget
|
||||
stack.set_visible_child_name(&vis);
|
||||
};
|
||||
|
||||
// aggresive memory cleanup
|
||||
// probably not needed
|
||||
old.destroy();
|
||||
content::on_podcasts_child_activate(stack, parent)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user