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

GTK4 Support

btzy opened this issue · comments

GTK4 has been released, we should eventually support it.

Most of the work has been done in #38 , but the major blocking issue is this. In summary, it is not possible to hide non-local files in the GTK4 file chooser (non-local files are those that do not have filepaths, such as resources on the Internet). We either have to filter the response and show an error message if non-local files are selected, or implement a shim to download those non-local files (not sure if this might be out of scope for NFD?).

Opinions on this issue are welcome.

Sorry for interruption, but GTK is NOT "the" native Linux thing, and its file chooser is terrible (an example reason is that it doesn't have thumbnails for 18 years).

There is a new GtkFileChooserNative which can let users use to actual Native file choosers based on their own choice (like Dolphin for KDE, thundar for Xfce, or any file chooser for any desktop).

https://developer.gnome.org/gtk4/stable/GtkFileChooserNative.html

(If a popular application, which can runs on Linux, user your library, someday, someone will bother about it eventually.)

Indeed it is not the native thing on some Linuxes, but it is a de-facto standard on the most common ones. The GTK3 implementation is based on the one in https://github.com/mlabbe/nativefiledialog. It appears that there is a workaround to make GTK open the KDE dialogs, by doing GTK_USE_PORTAL=1 when launching the application, though I'm not sure if it requires GtkFileChooserNative.

There is probably also another way, following mlabbe/nativefiledialog#40.

In any case, this should be a separate issue. I do not intend this GTK4 backend to work differently from the current GTK3 backend, though it may be possible to add some compilation flag in the future to use the native backend.

I noticed this was linked to nativefiledialog project and I left a post about the proper way to handle this, see it at: mlabbe/nativefiledialog#40 (comment)

but it is a de-facto standard on the most common ones

Absolutely not.

by doing GTK_USE_PORTAL=1 when launching the application, though I'm not sure if it requires GtkFileChooserNative

That option, if enabled in that gtk build, just makes it call out to that same listed dbus endpoint as in the above link instead of calling it natively. Best to just cut out the middleman and do it correctly so it works on all places properly everywhere for all DE's and you won't need to link to anything odd like kde or gtk or anything.