propertiesView: Retrive host path via portal

This way we should always be able to get the correct folder name if
xdg-desktop-portal > 0.19.
This commit is contained in:
Sophie Herold 2024-10-08 20:53:10 +02:00
parent c38430e292
commit fa46c76af4
6 changed files with 27 additions and 8 deletions

View file

@ -190,7 +190,13 @@ mod imp {
let metadata = image.metadata();
// Folder
let has_folder = Self::update_row(&self.folder, self.folder_name());
let parent = metadata
.host_path()
.or_else(|| file.path())
.as_ref()
.and_then(|x| x.parent())
.and_then(|p| util::get_file_display_name(&gio::File::for_path(p)));
let has_folder = Self::update_row(&self.folder, parent);
// The portal only supports opening folders of files that have a path
obj.action_set_enabled("properties.open-folder", file.path().is_some());
// Only show URI if now folder available
@ -242,12 +248,6 @@ mod imp {
}
}
fn folder_name(&self) -> Option<String> {
self.file()
.and_then(|f| f.parent())
.and_then(|p| util::get_file_display_name(&p))
}
fn format_name(&self) -> Option<String> {
let image = self.image.borrow();
let metadata = image.as_ref()?.metadata();