Introduction
We have winemenubuilder.exe to find program-related file associations. However, its current method has several unresolved problems:
- winemenubuilder.exe doesn't consider whether user want to add file association linked to specific program. Instead, winemenubuilder.exe builds links between file types and programs without any user interaction or acceptance by default. You can change winemenubuilder behavior via registry but this is not a straightforward and user-friendly solution. And you still can't easily control file associations for individual programs.
- Wine can really mess up with your system file associations at the moment. Once you install a Windows program, you may have bunch of unwished "Open with" entries, such as "Open with Internet Explorer" though you have never wanted your system even to suggest that alternative. I've had several times these "polluted situations" and fixing them takes considerably my valuable time.
- Once Wine has polluted your Linux file open dialogs and you want to get rid of all that stuff, the only certain solution is to remove all wine-extension entries in
- .local/share/applications/
.local/share/mime/
.local/share/icons/16x16/apps/
.local/share/icons/32x32/apps/
.local/share/icons/48x48/apps/
- .local/share/applications/
Better controlled and easier-to-manage solution is preferred. That's why I came up with an idea to merge part of winemenubuilder.exe behavior to winecfg. Yes, winecfg. Why?
Winecfg acts currently pretty much as a control center for your wineprefixes and daily Wine administration tasks. File association management is quite natural feature to be added as we think about centralized management for a wineprefix overall. And as an administrator, you want your job just to get done. Manually fixing errors that Wine has made into your system with file associations is pretty far from easy management. Actually, at the current state, configuring file associations on Wine has not management at all. It's just a pre-decided and automated arbitrary solution done ruthlessly by winemenubuilder.exe.
File Associations tab added to winecfg:
winecfg - File Association Management Menu
Generating a list of file associations - basic principle:
- Find all executables (*.exe) inside the selected wineprefix folder
- Find the executables that have file associations within them
- (Exclude all exes that don't have any file associations)
- Make a list of the executables that have file associations
- Add specific file associations to the related executable and display them on a list in winecfg (see picture below)
GUI legend/explanation:
- Tree structure with checkboxes
- "System Default" = If checked, override user current "open with" settings and set the listed program as a primary application to this file type on Linux system. If unchecked, add this file type as an alternative into "open with" dialog but do not set the Wine program as a system primary choice.
- "Reset to Defaults" = Reset all associations to winemenubuilder defaults. This also restores all programs originally listed but deleted afterwards by an user.
- "Check All" = Check all File Type checkboxes
- "Uncheck All" Uncheck all File Type checkboxes
- "Add application..." = Add an user-defined application which is not on the list -> Generate file association list to this app
- "Remove application" = Remove application from the list and delete all file associations linked to it (maybe this option should be available only to user-defined applications but not to the ones already installed in the selected prefix? Just to avoid mess-up)
- Unmark the specific file type checkbox on file association list
- Save settings in winecfg
- Find the matching png icon files in .local/usr/share/icons -> Delete
- Find the matching desktop file in .local/usr/share/applications -> Delete
- Find the matching mimetype stuff in .local/share/mime/ -> Delete
- Update .local/share/applications/mimecache.cache file
- Update linux file type associations (user priviledges)
- Mark the specific file type checkbox on file association list
- Save settings in winecfg
- Winemenubuilder: link the checked file type to the specific program and...
- ...add png icon files in .local/usr/share/icons
- ...add desktop file in .local/usr/share/applications
- ...add mimetype stuff in .local/share/mime/
- ...update .local/share/applications/mimecache.cache file
- ...update linux file type associations (user priviledges)
https://bugs.wine-staging.com/show_bug.cgi?id=122
Pictures presented in this post are photoshopped just to illustrate the idea.