imageView: Add only viewed images to recently used

Only adding images expclicitly opened via file browser
or drag and drop. Do not add images while browsing
SlidingView to avoid spamming recently used files.

Closes #53
This commit is contained in:
Sophie Herold 2023-03-08 01:40:47 +01:00 • committed by Christopher Davis
parent 05ef429b86
commit 6a4ee11c76
2 changed files with 4 additions and 4 deletions

View file

@ -153,10 +153,6 @@ impl LpImagePage {
obj.imp().image.set_file(&file);
// This doesn't work properly for items not explicitly selected
// via the file chooser portal. I'm not sure how to make this work.
gtk::RecentManager::default().add_item(&file.uri());
spawn!(clone!(@weak obj, @strong path => async move {
let imp = obj.imp();
imp.image.load(&path).await;

View file

@ -245,6 +245,10 @@ glib::wrapper! {
#[gtk::template_callbacks]
impl LpImageView {
pub fn set_image_from_path(&self, path: &Path) {
// Add image to recently used file. Does not work in Flatpaks:
// <https://github.com/flatpak/xdg-desktop-portal/issues/215>
gtk::RecentManager::default().add_item(&dbg!(gio::File::for_path(path).uri()));
if let Err(err) = self.load_path(path) {
log::error!("Failed to load path: {err}");
self.activate_action("win.show-toast", Some(&(err.to_string(), 1).to_variant()))