From 6a4ee11c761f1aba2c5a2870bac2279720042af5 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 8 Mar 2023 01:40:47 +0100 Subject: [PATCH] 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 --- src/widgets/image_page.rs | 4 ---- src/widgets/image_view.rs | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widgets/image_page.rs b/src/widgets/image_page.rs index 76d5146..8dd85ce 100644 --- a/src/widgets/image_page.rs +++ b/src/widgets/image_page.rs @@ -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; diff --git a/src/widgets/image_view.rs b/src/widgets/image_view.rs index cb6ddf9..6c2b9ee 100644 --- a/src/widgets/image_view.rs +++ b/src/widgets/image_view.rs @@ -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: + // + 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()))