From 4be473dcea016c7b5dcad7eddfa8aa6768da91ab Mon Sep 17 00:00:00 2001 From: ZephOne Date: Fri, 26 Apr 2019 17:05:27 +0100 Subject: [PATCH] utils: use generic image when a show has no cover When an episode from a show that has a cover is played. Switching to an episode of a show that has no cover does not load the generic image in the player. utils::set_image_from_path implementation does not deal with DownloadError::NoImageLocation utils::set_image_from_path deals with DownloadError::NoImageLocation, this generic is set in this case. https://gitlab.gnome.org/World/podcasts/issues/114 --- podcasts-gtk/src/utils.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/podcasts-gtk/src/utils.rs b/podcasts-gtk/src/utils.rs index 4fd0b0e..93e6872 100644 --- a/podcasts-gtk/src/utils.rs +++ b/podcasts-gtk/src/utils.rs @@ -17,7 +17,6 @@ // // SPDX-License-Identifier: GPL-3.0-or-later - #![cfg_attr(feature = "cargo-clippy", allow(type_complexity))] use gdk::FrameClockExt; @@ -43,6 +42,7 @@ use podcasts_data::pipeline; use podcasts_data::utils::checkup; use podcasts_data::Source; use podcasts_downloader::downloader; +use podcasts_downloader::errors::DownloadError; use std::collections::{HashMap, HashSet}; use std::sync::{Arc, Mutex, RwLock}; @@ -337,13 +337,23 @@ pub(crate) fn set_image_from_path( Err(TryRecvError::Empty) => glib::Continue(true), Err(TryRecvError::Disconnected) => glib::Continue(false), Ok(path) => { - if let Ok(path) = path { - if let Ok(px) = Pixbuf::new_from_file_at_scale(&path, s, s, true) { - if let Ok(mut hashmap) = CACHED_PIXBUFS.write() { - hashmap.insert((show_id, size), Mutex::new(Fragile::new(px.clone()))); - image.set_from_pixbuf(&px); + match path { + Ok(path) => { + if let Ok(px) = Pixbuf::new_from_file_at_scale(&path, s, s, true) { + if let Ok(mut hashmap) = CACHED_PIXBUFS.write() { + hashmap + .insert((show_id, size), Mutex::new(Fragile::new(px.clone()))); + image.set_from_pixbuf(&px); + } } } + Err(DownloadError::NoImageLocation) => { + image.set_from_icon_name( + "image-x-generic-symbolic", + gtk::IconSize::__Unknown(s), + ); + } + _ => {} } glib::Continue(false) }