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 MIME filters for file dialogs on non-Windows systems #216
Conversation
Having just tested this on Windows, this commit isn't ready in its original form. The native file dialog doesn't work for the "open file" action (regression since 2.0.2), and the MIME filter doesn't work at all. At a minimum it might be necessary to include both forms of filter, but I'll have to do some further testing to see if the lack of native dialog is caused by this commit or an earlier commit. |
Thanks for looking at this! I can also confirm that it causes the GTK dialog to be used instead of the native dialog on Windows - that seems to be intended / documented behaviour mentioned on https://docs.gtk.org/gtk3/class.FileChooserNative.html :( On macOS the mime filter also doesn't work (produces an error like |
The Windows part of this is giving me undue issues, I can't figure out if this is a result of an incorrect build environment or something else unrelated; but for the time being I'll push it back til I have some more free time. If the Windows version can't use MIME's, and the Mac version can't use MIME wildcards, then it probably makes sense to use the original logic for those environments and only bother with MIME's on Linux (and maybe BSD?). These environments have the least to gain anyway, since this change is particularly aimed for reconsidering the XDG Desktop Portals and the file saving issues associated with extension-less files.
The reason I haven't actually pushed that as a commit is because of the build issues mentioned earlier. It's a trivial code change so I presume you might be willing to try it yourself, but I've spent 2 hours today wondering why it isn't working on my end and can't get a good answer for that, weirdly... |
Yeah I think leaving the behaviour as-is on Windows would be fine 👍 |
The new commit looks fine for me on Windows/Linux. I imagine MacOS should work fine too; though I've no idea for BSD (or whether there's any recent packages for the BSD's) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just a couple small notes
I think just disabling it for Windows is fine - I'd assume the native file dialog on BSD should be similar to the situation on Linux
Looks good, thanks for working on this! |
Tested on Ubuntu 20.04
Pinta currently sets the filter for files in the file chooser dialogs based entirely on filenames. Instead, it is preferable to base this filter based on MIME types. This means that on Linux systems for example, there is no need to specify a file extension to be recognised as an image file. The identification of the file is left to the system, which can use more advanced heuristics, primarily, identifying the type based on the files binary header / magic number.
The observed effect is is that when filtering for images, Pinta will be capable of identifying image files without a file extension, whilst excluding other types of files, e.g ODT documents, that would be found with "All Files" filter.
It isn't strictly necessary to remove the file extensions filtering, the filter object can take both file extension filters and also MIME type filters concurrently. However it seems the more technically correct solution to only rely on one or the other IMO. However, it might be the more pragmatic solution to actually use both.