From 6ae5a966ffced0cfa0e4538d23bd2b8209fe297c Mon Sep 17 00:00:00 2001 From: David Bliss Date: Sat, 30 Mar 2024 17:56:32 +0000 Subject: [PATCH] Show missing picture image --- data/icons/image-missing-symbolic.svg | 4 ++++ data/resources/resources.gresource.xml | 1 + src/app/components/all_photos.rs | 12 +++++++++--- src/app/components/month_photos.rs | 6 +++++- src/app/components/year_photos.rs | 6 +++++- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 data/icons/image-missing-symbolic.svg diff --git a/data/icons/image-missing-symbolic.svg b/data/icons/image-missing-symbolic.svg new file mode 100644 index 00000000..4cbeb530 --- /dev/null +++ b/data/icons/image-missing-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/data/resources/resources.gresource.xml b/data/resources/resources.gresource.xml index 23c2b511..e8fce935 100644 --- a/data/resources/resources.gresource.xml +++ b/data/resources/resources.gresource.xml @@ -17,5 +17,6 @@ SPDX-License-Identifier: GPL-3.0-or-later ../icons/month-symbolic.svg ../icons/year-symbolic.svg ../icons/playlist-infinite-symbolic.svg + ../icons/image-missing-symbolic.svg diff --git a/src/app/components/all_photos.rs b/src/app/components/all_photos.rs index fb520d1d..a2ffea32 100644 --- a/src/app/components/all_photos.rs +++ b/src/app/components/all_photos.rs @@ -63,9 +63,15 @@ impl RelmGridItem for PhotoGridItem { } fn bind(&mut self, widgets: &mut Self::Widgets, _root: &mut Self::Root) { - widgets - .picture - .set_filename(self.picture.square_preview_path.clone()); + if self.picture.square_preview_path.as_ref().is_some_and(|f|f.exists()) { + widgets + .picture + .set_filename(self.picture.square_preview_path.clone()); + } else { + widgets + .picture + .set_resource(Some("/dev/romantics/Photos/icons/image-missing-symbolic.svg")); + } } fn unbind(&mut self, widgets: &mut Self::Widgets, _root: &mut Self::Root) { diff --git a/src/app/components/month_photos.rs b/src/app/components/month_photos.rs index 14ac47fa..5384be44 100644 --- a/src/app/components/month_photos.rs +++ b/src/app/components/month_photos.rs @@ -80,10 +80,14 @@ impl RelmGridItem for PhotoGridItem { .label .set_label(format!("{} {}", ym.month().name(), ym.year()).as_str()); - if widgets.picture.file().is_none() { + if self.picture.square_preview_path.as_ref().is_some_and(|f|f.exists()) { widgets .picture .set_filename(self.picture.square_preview_path.clone()); + } else { + widgets + .picture + .set_resource(Some("/dev/romantics/Photos/icons/image-missing-symbolic.svg")); } } diff --git a/src/app/components/year_photos.rs b/src/app/components/year_photos.rs index 5971c5a2..16d7f3c8 100644 --- a/src/app/components/year_photos.rs +++ b/src/app/components/year_photos.rs @@ -75,10 +75,14 @@ impl RelmGridItem for PhotoGridItem { .label .set_label(format!("{}", self.picture.year()).as_str()); - if widgets.picture.file().is_none() { + if self.picture.square_preview_path.as_ref().is_some_and(|f|f.exists()) { widgets .picture .set_filename(self.picture.square_preview_path.clone()); + } else { + widgets + .picture + .set_resource(Some("/dev/romantics/Photos/icons/image-missing-symbolic.svg")); } }