Fixed #1. Though it's an ugly hack for now.
This commit is contained in:
parent
456134ab41
commit
a31dc069de
2
TODO.md
2
TODO.md
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
**FIXME:**
|
**FIXME:**
|
||||||
|
|
||||||
- [ ] Fix Flowbox child activation. [#1](https://gitlab.gnome.org/alatiera/Hammond/issues/1)
|
- [x] Fix Flowbox child activation. [#1](https://gitlab.gnome.org/alatiera/Hammond/issues/1)
|
||||||
- [ ] Fix Etag/Last-modified implementation. [#2](https://gitlab.gnome.org/alatiera/Hammond/issues/2)
|
- [ ] Fix Etag/Last-modified implementation. [#2](https://gitlab.gnome.org/alatiera/Hammond/issues/2)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,9 +73,9 @@ pub fn get_episodes_with_limit(con: &SqliteConnection, limit: u32) -> QueryResul
|
|||||||
eps
|
eps
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_podcast(con: &SqliteConnection, parent: &Source) -> QueryResult<Vec<Podcast>> {
|
pub fn get_podcast_from_id(con: &SqliteConnection, pid: i32) -> QueryResult<Podcast> {
|
||||||
let pd = Podcast::belonging_to(parent).load::<Podcast>(con);
|
use schema::podcast::dsl::*;
|
||||||
// debug!("Returned Podcasts:\n{:?}", pds);
|
let pd = podcast.filter(id.eq(pid)).get_result::<Podcast>(con);
|
||||||
pd
|
pd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,8 @@
|
|||||||
<property name="homogeneous">True</property>
|
<property name="homogeneous">True</property>
|
||||||
<property name="column_spacing">5</property>
|
<property name="column_spacing">5</property>
|
||||||
<property name="row_spacing">5</property>
|
<property name="row_spacing">5</property>
|
||||||
<property name="max_children_per_line">25</property>
|
<property name="max_children_per_line">20</property>
|
||||||
|
<property name="selection_mode">none</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@ -74,6 +74,20 @@ fn build_ui(app: >k::Application) {
|
|||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// let builder = gtk::Builder::new_from_string(include_str!("../gtk/foo.glade"));
|
||||||
|
// let boxx: gtk::Box = builder.get_object("box").unwrap();
|
||||||
|
// let child: gtk::Box = builder.get_object("child").unwrap();
|
||||||
|
// let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
|
||||||
|
// window.add(&boxx);
|
||||||
|
|
||||||
|
// let fbc = gtk::FlowBoxChild::new();
|
||||||
|
// fbc.add(&child);
|
||||||
|
// flowbox.connect_child_activated(move |_, f| {
|
||||||
|
// println!("Hello world");
|
||||||
|
// println!("child activated: {:?}", f);
|
||||||
|
// });
|
||||||
|
// flowbox.add(&fbc);
|
||||||
|
|
||||||
// Setup quit in the app menu since default is overwritten.
|
// Setup quit in the app menu since default is overwritten.
|
||||||
let quit = gio::SimpleAction::new("quit", None);
|
let quit = gio::SimpleAction::new("quit", None);
|
||||||
let window2 = window.clone();
|
let window2 = window.clone();
|
||||||
@ -97,7 +111,6 @@ fn build_ui(app: >k::Application) {
|
|||||||
|
|
||||||
// Get the headerbar
|
// Get the headerbar
|
||||||
let header = headerbar::get_headerbar(&db, &stack);
|
let header = headerbar::get_headerbar(&db, &stack);
|
||||||
|
|
||||||
window.set_titlebar(&header);
|
window.set_titlebar(&header);
|
||||||
|
|
||||||
window.show_all();
|
window.show_all();
|
||||||
|
|||||||
@ -24,10 +24,6 @@ fn populate_flowbox(db: &Database, stack: >k::Stack, flowbox: >k::FlowBox) {
|
|||||||
if let Ok(pds) = podcasts {
|
if let Ok(pds) = podcasts {
|
||||||
pds.iter().for_each(|parent| {
|
pds.iter().for_each(|parent| {
|
||||||
let f = create_flowbox_child(db, 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);
|
flowbox.add(&f);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -50,8 +46,18 @@ fn setup_podcasts_grid(db: &Database, stack: >k::Stack) {
|
|||||||
stack.set_visible_child(&grid);
|
stack.set_visible_child(&grid);
|
||||||
|
|
||||||
// Adapted copy of the way gnome-music does albumview
|
// 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();
|
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 the flowbox with the Podcasts.
|
||||||
populate_flowbox(db, stack, &flowbox);
|
populate_flowbox(db, stack, &flowbox);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,8 +121,9 @@ pub fn create_flowbox_child(db: &Database, pd: &Podcast) -> gtk::FlowBoxChild {
|
|||||||
configure_banner(db, pd, &banner, &banner_title);
|
configure_banner(db, pd, &banner, &banner_title);
|
||||||
|
|
||||||
let fbc = gtk::FlowBoxChild::new();
|
let fbc = gtk::FlowBoxChild::new();
|
||||||
|
// There's probably a better way to store the id somewhere.
|
||||||
|
fbc.set_name(&pd.id().to_string());
|
||||||
fbc.add(&box_);
|
fbc.add(&box_);
|
||||||
// info!("flowbox child created");
|
|
||||||
fbc
|
fbc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user