From c74153f56a9a34094dddddca0cbca3bc79204e38 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 15 Dec 2017 18:42:49 +0200 Subject: [PATCH] Initial implementation of the new ShowWidget. --- hammond-gtk/resources/gtk/show_widget.ui | 255 ++++++++++------------- hammond-gtk/src/utils.rs | 5 + hammond-gtk/src/widgets/show.rs | 64 +++--- 3 files changed, 147 insertions(+), 177 deletions(-) diff --git a/hammond-gtk/resources/gtk/show_widget.ui b/hammond-gtk/resources/gtk/show_widget.ui index 6b30d01..cfb2207 100644 --- a/hammond-gtk/resources/gtk/show_widget.ui +++ b/hammond-gtk/resources/gtk/show_widget.ui @@ -2,191 +2,156 @@ - + True False + vertical - + True - False - center - center - 32 - 32 - 32 - 32 - 64 - 32 + True + in - + True False - center - center - vertical - 15 - - - True - False - center - start - 1 - 1 - 1 - 1 - - - False - False - 0 - - True False - center - center + vertical True False - center + center - - 50 + + True + False + 128 + image-x-generic-symbolic + + + False + True + 0 + + + + True False center - Foobar - True - center - True - 28 - False + center + vertical + + + True + False + The people behind The Intercept’s fearless reporting and incisive commentary—Jeremy Scahill, Glenn Greenwald, Betsy Reed and others—discuss the crucial issues of our time: national security, civil liberties, foreign policy, and criminal justice. Plus interviews with artists, thinkers, and newsmakers who challenge our preconceptions about the world we live in. + True + + + False + True + 5 + 0 + + + + + True + False + + + True + True + True + + + True + False + emblem-system-symbolic + + + + + False + True + 5 + 0 + + + + + Website + True + True + True + + + False + True + 5 + 1 + + + + + Unsubscribe + True + True + True + + + False + True + 5 + end + 2 + + + + + False + True + 5 + 1 + + True True - 0 + 5 + 1 False True - 5 - 1 + 10 + 0 - + True - True - True - center - center + False + vertical - - True - False - Unsubrscribe from this Podcast. -Warn: This will delete downloaded content associated with this Podcast. - user-trash-symbolic - + - False - False - 5 - end + True + True 1 - - - True - True - Mark all episodes as Played. - center - center - - - True - False - object-select-symbolic - - - - - False - False - 2 - - - - False - False - 1 - - - - - True - True - in - 200 - 200 - True - True - - - True - True - False - word-char - False - - - - - True - True - 2 - - - - - False - False - 0 - - - - - False - False - 1 - - - - - True - True - True - True - never - - - 400 - True - False - none - - @@ -194,7 +159,7 @@ Warn: This will delete downloaded content associated with this Podcast. True True - 2 + 0 diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs index 7327854..56cdc56 100644 --- a/hammond-gtk/src/utils.rs +++ b/hammond-gtk/src/utils.rs @@ -70,6 +70,11 @@ pub fn get_pixbuf_from_path(pd: &Podcast) -> Option { Pixbuf::new_from_file_at_scale(&img_path, 256, 256, true).ok() } +pub fn get_pixbuf_from_path_128(pd: &Podcast) -> Option { + let img_path = downloader::cache_image(pd)?; + Pixbuf::new_from_file_at_scale(&img_path, 128, 128, true).ok() +} + #[cfg(test)] mod tests { use hammond_data::Source; diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index 99da2b8..5aaff1a 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -9,7 +9,7 @@ use hammond_data::Podcast; use hammond_downloader::downloader; use widgets::episode::episodes_listbox; -use utils::get_pixbuf_from_path; +use utils::get_pixbuf_from_path_128; use content::ShowStack; use headerbar::Header; @@ -19,34 +19,38 @@ use std::rc::Rc; pub struct ShowWidget { pub container: gtk::Box, cover: gtk::Image, - title: gtk::Label, - description: gtk::TextView, - view: gtk::Viewport, + description: gtk::Label, + link: gtk::Button, + settings: gtk::Button, unsub: gtk::Button, - played: gtk::Button, + episodes: gtk::Box, } impl ShowWidget { pub fn new() -> ShowWidget { // Adapted from gnome-music AlbumWidget let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/show_widget.ui"); - let container: gtk::Box = builder.get_object("podcast_widget").unwrap(); + let container: gtk::Box = builder.get_object("container").unwrap(); + let episodes: gtk::Box = builder.get_object("episodes").unwrap(); let cover: gtk::Image = builder.get_object("cover").unwrap(); - let title: gtk::Label = builder.get_object("title_label").unwrap(); - let description: gtk::TextView = builder.get_object("desc_text_view").unwrap(); - let view: gtk::Viewport = builder.get_object("view").unwrap(); + let description: gtk::Label = builder.get_object("description").unwrap(); let unsub: gtk::Button = builder.get_object("unsub_button").unwrap(); - let played: gtk::Button = builder.get_object("mark_all_played_button").unwrap(); + let link: gtk::Button = builder.get_object("link_button").unwrap(); + let settings: gtk::Button = builder.get_object("settings_button").unwrap(); + + unsub + .get_style_context() + .map(|c| c.add_class("destructive-action")); ShowWidget { container, cover, - title, description, - view, unsub, - played, + link, + settings, + episodes, } } @@ -65,38 +69,34 @@ impl ShowWidget { header.switch_to_normal(); })); - self.title.set_text(pd.title()); let listbox = episodes_listbox(pd); if let Ok(l) = listbox { - self.view.add(&l); + self.episodes.add(&l); } - { - let buff = self.description.get_buffer().unwrap(); - buff.set_text(pd.description()); - } + self.description.set_text(pd.description()); - let img = get_pixbuf_from_path(pd); + let img = get_pixbuf_from_path_128(pd); if let Some(i) = img { self.cover.set_from_pixbuf(&i); } - self.played.connect_clicked(clone!(shows, pd => move |_| { - on_played_button_clicked(shows.clone(), &pd); - })); + // self.played.connect_clicked(clone!(shows, pd => move |_| { + // on_played_button_clicked(shows.clone(), &pd); + // })); - self.show_played_button(pd); + // self.show_played_button(pd); } - fn show_played_button(&self, pd: &Podcast) { - let new_episodes = dbqueries::get_pd_unplayed_episodes(pd); + // fn show_played_button(&self, pd: &Podcast) { + // let new_episodes = dbqueries::get_pd_unplayed_episodes(pd); - if let Ok(n) = new_episodes { - if !n.is_empty() { - self.played.show() - } - } - } + // if let Ok(n) = new_episodes { + // if !n.is_empty() { + // self.played.show() + // } + // } + // } } fn on_unsub_button_clicked(shows: Rc, pd: &Podcast, unsub_button: >k::Button) {