Groupd stack manipulation functions into content module.

This commit is contained in:
Jordan Petridis
2017-12-02 08:58:28 +02:00
parent 7727bc5ec3
commit 8bd48a09a6
6 changed files with 97 additions and 63 deletions
+3 -36
View File
@@ -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: &gtk::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: &gtk::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)
}