Crappy and ugly prototype of an episode banner prototype.
This commit is contained in:
parent
300fe86dc5
commit
422e3fc638
4
TODO.md
4
TODO.md
@ -10,12 +10,14 @@
|
||||
|
||||
**Would be nice:**
|
||||
|
||||
- [ ] Use GResource for assets like the banner.png etc, instead of hardcoded paths.
|
||||
- [x] Possibly Convert description labels to textview.
|
||||
- [ ] Make Podcast cover fetchng and loading not block the execution of the program at startup.
|
||||
- [ ] Re-design EpisodeWidget.
|
||||
- [ ] Lazy evaluate episode loading based on the podcast_widget's view scrolling.
|
||||
- [ ] Headerbar back button and stack switching
|
||||
- [ ] New episode notifier on podcast_flowbox_child, like the one vocal has
|
||||
- [x] New episode notifier on podcast_flowbox_child, like the one vocal has
|
||||
- [ ] Polish the flowbox_child banner.
|
||||
|
||||
|
||||
**Unhack stuff:**
|
||||
|
||||
BIN
assets/banner.png
Normal file
BIN
assets/banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@ -15,23 +15,44 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEventBox" id="events">
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child type="overlay">
|
||||
<object class="GtkImage" id="pd_cover">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="visible_window">False</property>
|
||||
<property name="above_child">True</property>
|
||||
<child>
|
||||
<object class="GtkImage" id="pd_cover">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
<property name="use_fallback">True</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
</child>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
<property name="use_fallback">True</property>
|
||||
<property name="icon_size">6</property>
|
||||
</object>
|
||||
</child>
|
||||
<child type="overlay">
|
||||
<object class="GtkImage" id="banner">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="no_show_all">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="stock">gtk-missing-image</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="index">-1</property>
|
||||
<property name="index">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child type="overlay">
|
||||
<object class="GtkLabel" id="banner_label">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="no_show_all">True</property>
|
||||
<property name="label" translatable="yes">Num</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">center</property>
|
||||
<property name="track_visited_links">False</property>
|
||||
<property name="xalign">0.87999999523162842</property>
|
||||
<property name="yalign">0.14000000059604645</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="index">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@ -42,7 +42,7 @@ fn populate_flowbox(db: &Database, stack: >k::Stack, flowbox: >k::FlowBox) {
|
||||
|
||||
if let Ok(pds) = podcasts {
|
||||
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);
|
||||
|
||||
@ -30,7 +30,7 @@ macro_rules! clone {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn podcast_widget(db: &Database, stack: >k::Stack, pd: &Podcast) -> gtk::Box {
|
||||
fn podcast_widget(db: &Database, stack: >k::Stack, pd: &Podcast) -> gtk::Box {
|
||||
// Adapted from gnome-music AlbumWidget
|
||||
let pd_widget_source = include_str!("../../gtk/podcast_widget.ui");
|
||||
let pd_widget_buidler = gtk::Builder::new_from_string(pd_widget_source);
|
||||
@ -123,11 +123,7 @@ fn show_played_button(db: &Database, pd: &Podcast, played_button: >k::Button)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add something that displays the amount of unplayed episodes on each Podcast.
|
||||
// Look into the vocal implementation.
|
||||
// https://github.com/needle-and-thread/\
|
||||
// vocal/blob/bced2e23cedb25b5edd0626e5f9361ceace683c9/src/Widgets/CoverArt.vala#L50
|
||||
pub fn create_flowbox_child(_db: &Database, pd: &Podcast) -> gtk::FlowBoxChild {
|
||||
pub fn create_flowbox_child(db: &Database, pd: &Podcast) -> gtk::FlowBoxChild {
|
||||
let build_src = include_str!("../../gtk/podcasts_child.ui");
|
||||
let builder = gtk::Builder::new_from_string(build_src);
|
||||
|
||||
@ -135,27 +131,44 @@ pub fn create_flowbox_child(_db: &Database, pd: &Podcast) -> gtk::FlowBoxChild {
|
||||
let box_: gtk::Box = builder.get_object("fb_child").unwrap();
|
||||
let pd_title: gtk::Label = builder.get_object("pd_title").unwrap();
|
||||
let pd_cover: gtk::Image = builder.get_object("pd_cover").unwrap();
|
||||
let events: gtk::EventBox = builder.get_object("events").unwrap();
|
||||
|
||||
// GDK.TOUCH_MASK
|
||||
// https://developer.gnome.org/gdk3/stable/gdk3-Events.html#GDK-TOUCH-MASK:CAPS
|
||||
// http://gtk-rs.org/docs/gdk/constant.TOUCH_MASK.html
|
||||
events.add_events(4_194_304);
|
||||
let banner: gtk::Image = builder.get_object("banner").unwrap();
|
||||
let banner_title: gtk::Label = builder.get_object("banner_label").unwrap();
|
||||
|
||||
pd_title.set_text(pd.title());
|
||||
|
||||
let cover = get_pixbuf_from_path(pd.image_uri(), pd.title());
|
||||
|
||||
if let Some(img) = cover {
|
||||
pd_cover.set_from_pixbuf(&img);
|
||||
};
|
||||
|
||||
configure_banner(db, pd, &banner, &banner_title);
|
||||
|
||||
let fbc = gtk::FlowBoxChild::new();
|
||||
fbc.add(&box_);
|
||||
// info!("flowbox child created");
|
||||
fbc
|
||||
}
|
||||
|
||||
fn configure_banner(db: &Database, pd: &Podcast, banner: >k::Image, banner_title: >k::Label) {
|
||||
let bann = Pixbuf::new_from_file_at_scale("assets/banner.png", 100, 100, true);
|
||||
if let Ok(b) = bann {
|
||||
banner.set_from_pixbuf(&b);
|
||||
|
||||
let new_episodes = {
|
||||
let tempdb = db.lock().unwrap();
|
||||
dbqueries::get_pd_unplayed_episodes(&tempdb, pd)
|
||||
};
|
||||
|
||||
if let Ok(n) = new_episodes {
|
||||
if !n.is_empty() {
|
||||
banner_title.set_text(&n.len().to_string());
|
||||
banner.show();
|
||||
banner_title.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_flowbox_child_activate(db: &Database, stack: >k::Stack, parent: &Podcast) {
|
||||
let old = stack.get_child_by_name("pdw").unwrap();
|
||||
let pdw = podcast_widget(db, stack, parent);
|
||||
@ -170,7 +183,7 @@ pub fn on_flowbox_child_activate(db: &Database, stack: >k::Stack, parent: &Pod
|
||||
println!("Hello World!, child activated");
|
||||
}
|
||||
|
||||
pub fn get_pixbuf_from_path(img_path: Option<&str>, pd_title: &str) -> Option<Pixbuf> {
|
||||
fn get_pixbuf_from_path(img_path: Option<&str>, pd_title: &str) -> Option<Pixbuf> {
|
||||
let img_path = downloader::cache_image(pd_title, img_path);
|
||||
if let Some(i) = img_path {
|
||||
Pixbuf::new_from_file_at_scale(&i, 200, 200, true).ok()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user