btzy / nativefiledialog-extended

Cross platform (Windows, Mac, Linux) native file dialog library with C and C++ bindings, based on mlabbe/nativefiledialog.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenDialog with portal backend allows folders to be picked

hazeycode opened this issue · comments

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.

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).