From c15b089ab85de53e002407f8826e6df91f42cdc8 Mon Sep 17 00:00:00 2001 From: Kamil Jarosz Date: Fri, 6 Sep 2024 09:55:58 +0200 Subject: [PATCH] Support files without an extension in XDG portal filters Due to the glob being used ("*.{file_extension}"), there was no possibility to include files without a dot in their name when using filters. The glob "*" is now used when an empty filter ("") or a match-all filter ("*") is specified, which replaces globs "*." and "*.*" respectively. The glob "*." did not make sense, as it matched files ending with a dot, and "*.*" did not match files without an extension (which are quite popular on Linux). --- CHANGELOG.md | 17 +++++++++-------- src/backend/xdg_desktop_portal.rs | 6 +++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf516a7..a75bd95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Make `set_parent` require `HasWindowHandle + HasDisplayHandle` - Add support for `set_parent` in XDG Portals - Update `ashpd` to 0.9. +- Add support for files without an extension in XDG Portal filters ## 0.14.0 - i18n for GTK and XDG Portal @@ -29,18 +30,18 @@ - Fix `FileHandle::inner` (under feature `file-handle-inner`) on wasm ## 0.12.0 -- Add title support for WASM (#132) +- Add title support for WASM (#132) - Add Create folder button to `pick_folder` on macOS (#127) - Add support for Yes/No/Cancel buttons (#123) -- Change a string method signatures #117 +- Change a string method signatures #117 - WASM `save_file` (#134) - Update `gtk-sys` to `0.18` (#143) - Update `ashpd` to `0.6` (#133) -- Replace windows with `windows-sys` (#118) +- Replace windows with `windows-sys` (#118) - Make zenity related deps optional (#141) ## 0.11.3 -- Zenity message dialogs for xdg portal backend +- Zenity message dialogs for xdg portal backend ## 0.10.1 - Update `gtk-sys` to `0.16` and `windows-rs` to `0.44` @@ -53,8 +54,8 @@ - feat: Add support for selecting multiple folders, fixes #73 ## 0.8.4 -- XDG: decode URI before converting to PathBuf #70 - +- XDG: decode URI before converting to PathBuf #70 + ## 0.8.3 - Windows-rs update 0.37 @@ -67,7 +68,7 @@ ## 0.8.0 - `parent` feature was removed, it is always on now -- New feature `xdg-portal` +- New feature `xdg-portal` - Now you have to choose one of the features `gtk3` or `xdg-portal`, gtk is on by default - `window` crate got updated to 0.32 @@ -79,7 +80,7 @@ - Update `windows` crate to 0.30. ## 0.6.2 -- Strip Win32 namespaces from directory paths +- Strip Win32 namespaces from directory paths ## 0.6.0 - FreeBSD support diff --git a/src/backend/xdg_desktop_portal.rs b/src/backend/xdg_desktop_portal.rs index 4d6b358..51bb5de 100644 --- a/src/backend/xdg_desktop_portal.rs +++ b/src/backend/xdg_desktop_portal.rs @@ -28,7 +28,11 @@ impl From<&Filter> for FileFilter { fn from(filter: &Filter) -> Self { let mut ashpd_filter = FileFilter::new(&filter.name); for file_extension in &filter.extensions { - ashpd_filter = ashpd_filter.glob(&format!("*.{file_extension}")); + if file_extension == "*" || file_extension == "" { + ashpd_filter = ashpd_filter.glob("*"); + } else { + ashpd_filter = ashpd_filter.glob(&format!("*.{file_extension}")); + } } ashpd_filter }