btzy / nativefiledialog-extended

Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.
zlib License
700 stars 96 forks source link

OpenDialog with portal backend allows folders to be picked #129

Closed hazeycode closed 9 months ago

hazeycode commented 9 months ago

I am using NFD_OpenDialog with the intention of only allowing single files matching the filterlist to be picked. Unfortunately, it is possible to pick a folder using nativefiledialog-extended v1.1.1 with the portal backend on Ubuntu Budgie 22.04.

btzy commented 9 months ago

If the portal backend still allows you to select folders, I think it is probably a bug in their implementation. NFDe calls the OpenFile() method documented here: https://docs.flatpak.org/en/latest/portal-api-reference.html#gdbus-method-org-freedesktop-portal-FileChooser.OpenFile. It doesn't set directory for NFD_OpenDialog() (which makes it default to selecting files), and sets directory to true for NFD_PickFolder().

You can try using D-Feet to call the OpenFile() portal method manually, and see if you can find a way to make the dialog only allow files to be picked (but I doubt so).