✨ Add Kotlin/Native Linux file picker via XDG desktop portal - #636
✨ Add Kotlin/Native Linux file picker via XDG desktop portal#636Enaium wants to merge 3 commits into
Conversation
vinceglb
left a comment
There was a problem hiding this comment.
Hi @Enaium, thanks a lot for working on native Linux dialog support!
I reviewed the implementation and found three important issues to address before merging:
assemblecurrently fails on macOS because the Linux interop requirespkg-configand the D-Bus development headers from the host machine.- The
current_folderoption should contain the raw filesystem path. It currently includes afile://prefix, which can prevent the dialog from opening in the requested directory. - Percent-encoded paths should be decoded as UTF-8. The current implementation corrupts filenames containing non-ASCII characters such as
é.
Can you take a look? Thanks again!
…der, UTF-8 decoding
|
Thanks for the review! All three issues are addressed:
Verified locally: |
57ba73f to
2681176
Compare
2681176 to
d45177e
Compare
|
Publishing has been verified on both platforms without issues:
|
Summary
Adds file picker, directory picker, and file saver dialogs for Kotlin/Native Linux targets (
linuxX64,linuxArm64) tofilekit-dialogs, backed by the GNOME XDG Desktop Portal (org.freedesktop.portal.FileChooser).On GNOME desktops the portal renders the Nautilus-style GNOME file dialog (the native portal is planned to move into Nautilus itself), so this is the Nautilus/GNOME-native picking experience for native Linux apps.
What changed
filekit-dialogslinuxX64/linuxArm64targets in the module convention.src/linuxMain: platform actuals foropenFilePicker,openDirectoryPicker,openFileSaver, andopenFileWithDefaultApplication(viaxdg-open), plusFileKitDialogSettings/FileKitOpenFileSettings.src/linuxDbusMain: a libdbus cinterop client implementing the portalOpenFile/SaveFilerequests (a{sv}options:multiple,directory,filters,current_folder,current_name) and theorg.freedesktop.portal.Request.Responsesignal handling, compiled into both Linux targets (the sharedlinuxMainmetadata compilation cannot see cinterop bindings).linuxMainkeeps the protocol model and pure helpers (URI decoding, filter building, response resolution) so they are unit-testable.FileKitPickerException/FileKitDialogExceptionwithLINUX_*messages, mirroring the existing Windows/macOS conventions.Build
dbus.defcinterop withpkg-config-resolved compiler flags and a-Llink path for the distro libdir; consumers link againstlibdbus-1(present on every D-Bus enabled system).Tests
linuxTest: pure helper tests (URI decoding, filters, response resolution) and failure-mapping tests.linuxX64Test: portal response parsing regression tests using real(ua{sv})D-Bus messages (covers the read path that previously aborted ondbus_message_iter_open_container), a portal connectivity smoke test (skips when no session bus is available), and a manual picker test gated behindFILEKIT_MANUAL_PICKER_TEST=1that opens the real dialog for click-through verification.Docs
docs/installation.mdxanddocs/dialogs/setup.mdxupdated: dialogs now supported on Kotlin/Native Linux via the XDG portal.Verification
./gradlew assembleand:filekit-dialogs:checkpass.libcrypt.so.1compatibility shim (pre-existing toolchain/sysroot issue, unrelated to this change).Affected platforms
linuxX64,linuxArm64): added.filekit-dialogs-composeis unchanged: Compose Multiplatform has no Linux native artifacts yet.