Bug 410561 - When Text Files preview is enabled, .directory files should still show their icon instead of their text contents (i.e. behave like .desktop files)
Summary: When Text Files preview is enabled, .directory files should still show their ...
Status: RESOLVED FIXED
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Thumbnails and previews (show other bugs)
Version: 19.04.0
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2019-08-04 08:17 UTC by Alexander M.
Modified: 2019-08-08 14:00 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 19.08.0


Attachments
Text Files preview disabled (17.27 KB, image/png)
2019-08-04 08:18 UTC, Alexander M.
Details
Text Files preview enabled (18.62 KB, image/png)
2019-08-04 08:18 UTC, Alexander M.
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander M. 2019-08-04 08:17:52 UTC
Just like '.desktop' files (henceforth: Desktop) '.directory' (Directory) and '.flatpakref' (Flatpak) files are also special text files and should be treated as such, which means they should not generate a content thumbnail when Text Files preview is enabled in Dolphin, like they do currently, but instead should keep showing their designated icon.

This issue was affecting Desktop files as well up until very recently (November 2018), but was "mysteriously" fixed in (I presume) KDE Frameworks 5.52, as can be seen in the closing comments of https://bugs.kde.org/show_bug.cgi?id=220330

Unfortunately, as far a I can tell, the solution to this problem was not reached through manipulating e.g. the file type but by simply hard-coding the '.desktop' file extension as special.

My "evidence" for that:

- Directory files are the exact same file type as Desktop files (desktop configuration file) yet they do generate text thumbnails.

- If a Desktop file's '.desktop' extension is changed to something else (e.g. '.deskto'), then the Desktop file behaves as a normal text file and erroneously generates a content preview.

- And of course, if a Directory file's extension is changed from '.directory' to '.desktop', it properly shows its icon just as if it were a Desktop file (this won't work for Flatpak files though, since they're a separate mime type).


STEPS TO REPRODUCE

1. Go to Dolphin -> Configure Dolphin -> General -> Previews and disable "Text Files".
2. Directory & Flatpak files display their icon as they should (see 1st screenshot)

3. Go to Dolphin -> Configure Dolphin -> General -> Previews and enable "Text Files".
4. Directory & Flatpak files display their text contents instead of their icons (see 2nd screenshot)

5. Desktop files are unaffected by the whole process unless their file extension is changed, as already mentioned.


EXPECTED RESULT

Directory files (found in e.g. ~/.local/share/desktop-directories) and Flatpak files should both be treated as special text files, just like Desktop files are, and always show their icons instead of their text contents.

Additionally, all three of these files could/should be completely decoupled from the Text Files preview option and instead be included in separate preview entries: Desktop & Directory files in e.g. "Desktop Launchers", and Flatpak files in "Flatpak" (exactly like Appimage files).


ADDITIONAL INFO:

- The issue with Flatpak files has previously been reported in https://bugs.kde.org/show_bug.cgi?id=400201, but the bug report has gone stale.
Comment 1 Alexander M. 2019-08-04 08:18:32 UTC
Created attachment 121925 [details]
Text Files preview disabled
Comment 2 Alexander M. 2019-08-04 08:18:51 UTC
Created attachment 121926 [details]
Text Files preview enabled
Comment 3 Patrick Silva 2019-08-04 12:31:17 UTC
.flatpakref issue already reported as bug 400201
Comment 4 Nate Graham 2019-08-04 23:42:55 UTC
Submitted a patch: https://phabricator.kde.org/D22936
Comment 5 Nate Graham 2019-08-08 14:00:48 UTC
Git commit df85d47c7242aeb7b713de48049891628254a67d by Nate Graham.
Committed on 08/08/2019 at 14:00.
Pushed by ngraham into branch 'Applications/19.08'.

[Text thumbnailer] Don't show text preview for .directory and .flatpakref files

Summary:
The text thumbnailer currently excludes .directory files from receiving text file
thumbnails, but does not do the same for .directory and .flatpakref files which are
the same things (actually text files that don't look, feel, or behave like text files).

This patch extends the same logic to those types of files as well, making them not
receive text previews and instead show their base mimetype or icon (if defined in the
file).
Related: bug 400201
FIXED-IN: 19.08.0

Test Plan: {F7161776, size=full}

Reviewers: #vdg, #frameworks, broulik

Reviewed By: broulik

Subscribers: kde-frameworks-devel, kfm-devel

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D22936

M  +6    -2    thumbnail/textcreator.cpp

https://commits.kde.org/kio-extras/df85d47c7242aeb7b713de48049891628254a67d