Skip to content

Commit

Permalink
Show missing picture image
Browse files Browse the repository at this point in the history
  • Loading branch information
blissd committed Mar 30, 2024
1 parent d729458 commit 6ae5a96
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions data/icons/image-missing-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions data/resources/resources.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
<file alias="month-symbolic.svg" preprocess="xml-stripblanks">../icons/month-symbolic.svg</file>
<file alias="year-symbolic.svg" preprocess="xml-stripblanks">../icons/year-symbolic.svg</file>
<file alias="playlist-infinite-symbolic.svg" preprocess="xml-stripblanks">../icons/playlist-infinite-symbolic.svg</file>
<file alias="image-missing-symbolic.svg" preprocess="xml-stripblanks">../icons/image-missing-symbolic.svg</file>
</gresource>
</gresources>
12 changes: 9 additions & 3 deletions src/app/components/all_photos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 5 additions & 1 deletion src/app/components/month_photos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/app/components/year_photos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
}

Expand Down

0 comments on commit 6ae5a96

Please sign in to comment.