Summary: | NotShowIn/OnlyShowIn overrides the user-selected apps saved in mimeapps.list | ||
---|---|---|---|
Product: | [Frameworks and Libraries] frameworks-kservice | Reporter: | Martin <spleefer90> |
Component: | general | Assignee: | David Faure <faure> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | alexander.lohnau, kdelibs-bugs, meven29, nate, uhhadd |
Priority: | NOR | ||
Version: | 5.74.0 | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | https://invent.kde.org/frameworks/kservice/commit/ade2064b971cbfdb76476d2ca8807dca2da29cb1 | Version Fixed In: | 5.76 |
Attachments: |
~/.config/mimeapps.list
Working entry - /usr/share/applications/kindlecomicconverter.desktop Broken entry - /usr/share/applications/org.gnome.FileRoller.desktop unittest |
Description
Martin
2020-10-09 00:56:07 UTC
Created attachment 132226 [details]
Working entry - /usr/share/applications/kindlecomicconverter.desktop
Created attachment 132227 [details]
Broken entry - /usr/share/applications/org.gnome.FileRoller.desktop
Very good bug report, thanks. Detailed, and down to command-line calls. That makes me want to fix it :-) It's tricky though. We read both mimeapps.list and desktop files, write out an ordered list into the cache (ksycoca), then when it's time to find an app for a mimetype, we read that list from the cache and filter out services that shouldn't be shown in the current desktop (applyFilter() in kapplicationtrader.cpp). At that point we don't really know if the app is in the list because of mimeapps.list or because it was just a .desktop file being there (but not specifically chosen by the user) when we created the cache. And we can't filter out based on current desktop at the time of creating the cache, because, well, technically the current desktop could change between the time of creating the cache and the time of using it. The easy way out would be to say: NotShowIn is *only* about whether the app should be displayed in the K menu, it shouldn't prevent an application from being selected (even without user intervention) when clicking on a file. But I believe this would introduce unwanted behavior in some cases (let's say, like FileRoller being started for directories in Plasma, by default). OK, so it's tricky indeed. Well, at least tonight I wrote the unittest for this (which also breaks if blindly removing the showInCurrentDesktop() check in applyFilter, i.e. it checks that nobody took the "easy way out" from the previous paragraph). TDD methodology: unittest written, next step is to come up with a fix. Created attachment 132645 [details]
unittest
OK, actually, if I read NotShowIn/OnlyShowIn at cache creation time (but ignore it for things listed in mimeapps.list)... then I have a hard time coming up with a buggy corner case related to switching desktop environments. One would have to install an app with OnlyShowIn=KDE while in Gnome, run some KDE code there (so ksycoca gets updated while the current desktop isn't Plasma), switch to Plasma, do nothing that touches the mime configuration, and the KDE app is still ignored for the purpose of file associations. And if that ever happens, there are easy workarounds (running kbuildsycoca5, installing/removing any other app, changing any file associations...). A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kservice/-/merge_requests/19 Git commit ade2064b971cbfdb76476d2ca8807dca2da29cb1 by David Faure. Committed on 28/10/2020 at 19:07. Pushed by dfaure into branch 'master'. Allow NotShowIn=KDE apps, listed in mimeapps.list, to be used It was unexpected for users that selecting e.g. Gnome FileRoller in mimeapps.list for a given mimetype would still not make it associated to that mimetype when in Plasma. NotShowIn is documented to be about "displaying" applications (in the K menu and context menus), not about completely forbidding users from associating such apps with a given mimetype. Note that if one wants different file associations per desktop, that's supported with gnome-mimeapps.list and kde-mimeapps.list. The fix is to check showInCurrentDesktop() at cache creation time when collecting .desktop files, but to not check it for mimeapps.list entries. The trick to make this work was that we still need to process ONE servicetype for such "hidden" desktop files: the "Application" servicetype (internal detail which can hopefully go away in KF6). FIXED-IN: 5.76 M +31 -0 autotests/kmimeassociationstest.cpp M +1 -1 src/services/kapplicationtrader.cpp M +2 -2 src/services/kservicefactory.cpp M +10 -0 src/services/kserviceoffer.cpp M +2 -0 src/services/kserviceoffer.h M +6 -0 src/sycoca/kbuildservicefactory.cpp https://invent.kde.org/frameworks/kservice/commit/ade2064b971cbfdb76476d2ca8807dca2da29cb1 |