The upcoming release of xdg-portal will introduce the GetHostPaths interface for getting the original file path, instead of the sandboxed one.
This is pretty interesting for displaying the real file paths in GUIs.
The host paths will also be available as xattr, it seems (not sure what it means concretely).
That would be IMHO really nice to be able to get this using Gio.FileInfo attributes. I’m interested to try implementing that. Which components should be involved? GLib, gvfs?
Let’s assume you are going to add this information to the file returned by GtkFileDialog, because that’s likely going to be the most common case (nobody uses the document portal directly).
In theory, you could add a new G_FILE_ATTRIBUTE_UNIX_HOST_PATH attribute string that causes a query on the extended attributes of a file when calling g_file_query_info(); for that you’ll need to call getxattr() and make sure to deserialise the xattr string to check for the appropriate attribute.
The other option is to call the GetHostPaths D-Bus method, but that is very complicated to do inside a GFileInfo, especially asynchronously and with proper error handling.
I’ll check that once the new portal is available. Maybe querying the attribute xattr::host-path (or similar) will do the trick?
That’s indeed not suitable for Gio.FileInfo.
Maybe from Gtk.FileDialog, but then no idea how to properly pass the info back to the async results… Doesn’t sound like a good lead to me.