RFR: 8374630: Replace GtkFileChooserDialog with GtkFileChooserNative to allow for better Flatpak integration

Frederic Thevenet fthevenet at openjdk.org
Tue Jan 13 08:37:43 UTC 2026


On Tue, 13 Jan 2026 07:58:03 GMT, Johan Vos <jvos at openjdk.org> wrote:

>> Flatpak is a framework for distributing desktop applications across various Linux distributions, that runs each application into its own sandbox to limit its access to the host environment to the strict minimum, including access to the network, HW devices or the host file system.
>> To do so, it provides a specific set of APIs, known as "XDG Desktop Portal " that the guest application must be aware of to take full advantage of ; which is not the case for Java/JavaFX based applications.
>> 
>> Fortunately, some level of support for XDG Desktop Portal is baked into GTK3, which JavaFX could easily take advantage of.
>> One such opportunity is replace explicit uses of GtkFileChooserDialog with GtkFileChooserNative.
>> 
>> GtkFileChooserNative is an abstraction of a dialog box suitable for use with "File/Open" or "File/Save as" commands. By default, this just uses a GtkFileChooserDialog to implement the actual dialog. However, on certain platforms, such as Windows and macOS, the native platform file chooser is used instead. 
>> When the application is running in a sandboxed environment without direct filesystem access (such as Flatpak), GtkFileChooserNative may call the proper APIs (portals) to let the user choose a file and make it available to the application.
>
> I had a deeper look. All code changes look fine, and I believe it is the right thing to do (including the support for flatpak)
> We have some technical debt when using GTK, and using deprecated constants like STOCK_OPEN add to this debt. On my Ubuntu 22.04, the icons are not even shown with the existing implementation, so there is no difference for me, as far as I see.
> @fthevenet what OS/GTK version is used for the screenshot that you pasted and that does have the icons? 
> 
> I'm pretty neutral on design in general, but it seems that removing the option to show an icon next to the label is aligning us more with industry standards. Since this is about an OS/Gnome component, I believe there is no problem if this results (on some systems) in a changed UI -- other apps will probably show similar evolution.

Thanks @johanvos 

I took those screenshot on Fedora 43 (with KDE 6.5.4). The version of the bundled GTK3 libs is 3.24.51.

Another issue I've noticed with these icons is that  if I run a light color theme on my env, the icons are still there but almost invisible, as they are drawn in white on a very light grey background:

<img width="261" height="150" alt="image" src="https://github.com/user-attachments/assets/5fe0a356-77c7-471e-a88f-fcbb8c2c3a00" />

If you click the button so its background color changes, you can see the icon it still there:

<img width="261" height="150" alt="image" src="https://github.com/user-attachments/assets/0c18e1b6-cb74-437b-a455-b771552c3b87" />

Maybe this is what's happening on your machine, @johanvos ? At any rate, for all the reasons you mentioned, I believe it's not really worth investigating this particular problem further and that simply getting rid of the icons is the best way forward.

-------------

PR Comment: https://git.openjdk.org/jfx/pull/2025#issuecomment-3742838570


More information about the openjfx-dev mailing list