Hello, I am coding a Gnome application with python, and I open a Gtk.FileDialog. I get the result, but it’s not a real path (e.g: /run/user/…), due to Flatpak sandboxing. So my question is: how can I get the real path? Libportal, Gio, libflatpak?
This is probably because this attribute is fairly new. It was introduced in version 1.19.0 of the XDG desktop portals, which is on GitHub also marked as an prerelease (I assume xdg-desktop-portal uses the versioning schema where odd numbers are previews and even numbers stable releases?).
With that being said, you probably need to wait a bit until XDG Desktop Portal is updated on your system for the information to be provided.
Also, in XDG desktop portals version 1.19, when you open a directory with portals then only the directory itself gets this xattr, but not the individual files inside.
This was fixed recently, and will be available in upcoming version 1.20.
So to handle this attribute correctly, you need to hex-unescape it, and then it is no longer guaranteed to be utf-8, so you may want to use g_filename_display_name to show it.
The “other” apps, like GNOME Text Editor, often use large filesystem permissions, like --filesystem=home or even --filesystem=host. With these permissions, files are visible under their real path, rather then provided over the proxy of the document portal.
Just note that in many cases, this should not be recommended for Flatpak apps, unless you have a good reason, which text editors and IDE’s have, but most other programs not.
For anyone who has the same problem as me, I found the solution. You have to use “–filesystem=host” as previously mentioned AND install the application (do not run it from GNOME Builder).