-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use File chooser portal #1887
Comments
As a quick and dirty proof of concept:
Doing it for real one would want to know when to attempt to call zenity - I don't know what exists for flatpak detection but I wouldn't do it just because zenity was available. Maybe as a cmake argument if there's no good way to detect at runtime. Anyway, I'm open to it. Edit: changed diff to not explode on 'Cancel' |
Nice! To detect if the program is running in a Flatpak, it is possible to check if the file Since the file chooser is called in different places (first startup, options, folders options), I'd maybe look into adding a |
There's also the |
What feature or enhancement would you like to add?
Use the File chooser portal to improve the privacy of the Flatpak.
The theory
As you know, CorsixTH is now distributed as a Flatpak. Flatpaks run in a sandboxed environment, and this creates an issue for programs that need to access the host filesystem.
To allow CorsixTH users to choose their game data nonetheless, the Flatpak requires read access to the whole home directory. This is the easiest solution because it doesn't require any change from in the program, but some users have privacy concerns over this.
It is possible, however, to plug this hole and use portals to get access to the host. The File chooser portal spawns a system file chooser dialog on the host, and when the user selects files, they are mounted within the sandbox so the program can access them.
In practice
The program needs to make DBus calls to use the portals. However, as this is not the most practical, GUI toolkits have widgets that use these portals transparently.
Because CorsixTH doesn't use a GUI toolkit, there is another solution: spawn another program that will in turn call the portal and give back the result to CorsixTH. Such a program would be
zenity
, and this is what OpenRCT2 uses for its file dialogs.To not make
zenity
a dependency of CorsixTH, it is possible to only use it if it is already installed and/or the game detects it is in a Flatpak, and fall back to the current in-game file chooser.There are two downsides:
Conclusion
Although not mandatory for the Flatpak, using the File chooser portal would be a nice convenience and comfort users about the privacy of their data. If that is something you are interested in seeing in CorsixTH, I can look into working on it, even if I'm not familiar with the code base and haven't written Lua in a while!
The text was updated successfully, but these errors were encountered: