Transition from (GTK) FileChooserDialog to FileChooserNative

Bug #1909807 reported by James Carroll
28
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Pinta
Fix Released
Medium
Unassigned

Bug Description

GTK3 introduced the GTKFileChooserNative class. This class wraps around GtkFileChooserDialog but allows each platform to use its own toolkit, Windows users get Windows' own file picker, MacOS gets MacOS's own filepicker.

In particular, on Linux systems in heavy containment (E.G, Snap/Flatpak), this class facilitates a way to negotiate file access safely through a sandbox, allowing arbitrary access to any location on the computer in a secure manner and without having to do any extra setup in the ideal cases. It also allows using the KDE file picker on KDE systems through the same mechanism. (XDG desktop portals)

https://developer.gnome.org/gtk3/stable/gtk3-GtkFileChooserNative.html

(I did try give this a go myself but I have zero GTK experience and it wasn't as trivial as changing the class names alone)

Tags: gtk3
Revision history for this message
Cameron White (cameronwhite91) wrote :

Thanks for the details, it sounds like we should give this a try in the GTK3 branch.
It looks like certain features that we use (e.g. a custom preview widget) might not be available in the native dialog so we'll have to see what the implications are, but those might be reasonable tradeoffs for the benefit of having the standard dialog on each platform.

tags: added: gtk3
Changed in pinta:
importance: Undecided → Medium
milestone: none → 1.8
status: New → Confirmed
Revision history for this message
Cameron White (cameronwhite91) wrote :

I've merged my changes into the GTK3 branch (https://github.com/PintaProject/Pinta/commit/cbe442238ff1cc2fff5a4785ecc7861ffb00b488).
If you're able to do some testing with a snap / flatpak package, that would be great!

The only issue I've noticed so far is that https://gitlab.gnome.org/GNOME/gtk/-/issues/1820 prevents us from detecting the selected file filter and auto-filling the extension when FileChooserNative ends up using the standard GTK dialog on Linux (not sure if this also affects the portal case). This was fixed in GTK 3.24.21, but the Ubuntu LTS is still on 3.24.18 (https://packages.ubuntu.com/focal/libgtk-3-0).
I'm going to leave this issue open so that we can check the status of this before the release of our GTK3 branch and decide if a workaround is needed.

Revision history for this message
James Carroll (james-carroll) wrote :

The native dialog works as expected in the Snap build and fixes the sandboxing issue on hosts with proper portal support, I've attached a small video so you can see it in action. I'd reasonably expect the Flatpak to work the same provided the maintainer sets the environment variable too.

Revision history for this message
Cameron White (cameronwhite91) wrote :

Great, thank you for confirming!

Revision history for this message
grofaty (grofaty) wrote :

Cameron, is there anything else that has to be done in this bug report or can we mark it as "Fix Commited"?

Revision history for this message
Cameron White (cameronwhite91) wrote :

There is just the issue I mentioned at the end of comment #2 - before the release we need to remember to check what the GTK version is for most distros, in case we need add a workaround for the bug mentioned.

Revision history for this message
Cameron White (cameronwhite91) wrote :

I've added a note to the changelog about the minimum recommended GTK version (https://github.com/PintaProject/Pinta/commit/4ab91d4b6ae15900ee36bf4e9d747a96bff59854), for the issue mentioned in comment #2.

I don't think there's too much we can do as a workaround, and it should have minimal impact since the snap and flatpak packages will have newer GTK3 versions.

Changed in pinta:
status: Confirmed → Fix Committed
Changed in pinta:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.