Fixed #1. Though it's an ugly hack for now.

This commit is contained in:
Jordan Petridis
2017-11-04 17:57:50 +02:00
parent 456134ab41
commit a31dc069de
6 changed files with 33 additions and 12 deletions
+11 -5
View File
@@ -24,10 +24,6 @@ fn populate_flowbox(db: &Database, stack: &gtk::Stack, flowbox: &gtk::FlowBox) {
if let Ok(pds) = podcasts {
pds.iter().for_each(|parent| {
let f = create_flowbox_child(db, parent);
f.connect_activate(clone!(db, stack, parent => move |_| {
on_flowbox_child_activate(&db, &stack, &parent);
}));
flowbox.add(&f);
});
} else {
@@ -50,8 +46,18 @@ fn setup_podcasts_grid(db: &Database, stack: &gtk::Stack) {
stack.set_visible_child(&grid);
// Adapted copy of the way gnome-music does albumview
// FIXME: flowbox childs activate with space/enter but not with clicks.
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
// TODO: handle unwraps.
flowbox.connect_child_activated(clone!(db, stack => move |_, child| {
// This is such an ugly hack...
let id = child.get_name().unwrap().parse::<i32>().unwrap();
let parent = {
let tempdb = db.lock().unwrap();
dbqueries::get_podcast_from_id(&tempdb, id).unwrap()
};
on_flowbox_child_activate(&db, &stack, &parent);
}));
// Populate the flowbox with the Podcasts.
populate_flowbox(db, stack, &flowbox);
}