Currently Thunar does not truncate filenames. This can lead to absurdly large item spacing in both icon and compact view as files with long filenames have their names displayed in full length, occupying a large amount of space.
Thunar should limit the length of filenames and truncate them by inserting ellipsis where necessary like most other file managers do.
This patch addresses the issue by adding filename truncation using ellipsis insertion. It introduces the following 3 new xfconf values and respective default values:
icon-view-text-lines: maximum amount of lines for filenames in icon view (default: 4)
compact-view-text-width: maximum pixel width for filenames in compact view (default: 300)
misc-truncate-filenames: boolean toggling the new truncate/ellipsize behavior for filenames (default: TRUE)
I propose the variables to be kept as hidden settings.
I chose to not put the ellipsis at the end of the filenames as many other file managers do it, but in the center. This will keep the file extension readable in most cases which I find quite handy.
However if you deem this unsuitable, feel free to replace the occurences of "PANGO_ELLIPSIZE_MIDDLE" with "PANGO_ELLIPSIZE_END" which will result in the ellipsis being appended at the end instead.
For thunar/gtk3 (master) the complete thunar-text-renderer was removed, GtkCellRendererText is used instead.
For GtkCellRendererText it seems not to be possible to pass "wrap-mode" and "ellipsize" together in a meaningfull way.
According to https://wiki.gnome.org/HowDoI/Labels one needs to adjust gtk_label_set_lines as well. Not sure where this can be done. In exo ?
thunar_fixed_width_final.patch and thunar_truncate_final.patch from [Thunar-dev] how to tell thunar never to increase space between icons? worked with GTK2 (I used up to thunar-1.6.18), but doesn't seem to work with GTK3. If this gets attention of kind developers. A permanent configuration option or some unofficial patch.
Alexander Schwinnchanged title from [enh] Truncate filenames by inserting ellipsis in icon and compact view to Use consistent vertical item spacing in icon view (e.g. truncate filenames by inserting ellipsis)
changed title from [enh] Truncate filenames by inserting ellipsis in icon and compact view to Use consistent vertical item spacing in icon view (e.g. truncate filenames by inserting ellipsis)
Alexander Schwinnchanged title from Use consistent vertical item spacing in icon view (e.g. truncate filenames by inserting ellipsis) to Use consistent vertical item spacing in icon view
changed title from Use consistent vertical item spacing in icon view (e.g. truncate filenames by inserting ellipsis) to Use consistent vertical item spacing in icon view
I have the same issue. When I drag n drop this URL from Firefox into Thunar when in compact view then the margin of all file names looks ugly. The reason is not only the long file name but also the line break Thunar is inserting for long file names. The bigger height of the icon with the long file name then suddenly applies to all other items.
Fixing this now (for ThunarIconView) will require the ThunarTextRenderer that was dropped in 81e645d8 during the port to GTK3 in 2015. It will also need code from Markus's 2017 patches on Thunar-dev, or some workalike. I'm going to attach them here just in case they become inaccessible in the future.
This patch addresses the issue of varying horizontal spacing in iconview by using a fixed width (= maximum width) for the columns of thegrid layout.The patch introduces the following xfconf variable: misc-fixed-item-width: toggles the fixed item width on (TRUE) or off (FALSE); default: TRUEThe patch only affects icon view and the new behavior only appliesto views with text below items.
The appended patch addresses the issue of huge filename labels byadding filename truncation using ellipsis insertion and introduces 3new xfconf values: icon-view-text-lines: maximum amount of lines for filenames in icon view (default: 4) compact-view-text-width: maximum pixel width for filenames in compact view (default: 300) misc-truncate-filenames: boolean toggling the new truncate/ellipsize behavior for filenames (default: TRUE)I chose to not put the ellipsis at the end of the filenames as manyother file managers do it, but in the center. This will keep thefile extension readable in most cases which I find quite handy.However if you deem this unsuitable, feel free to replace theoccurences of "PANGO_ELLIPSIZE_MIDDLE" with "PANGO_ELLIPSIZE_END"which will result in the ellipsis being at the end.
The reason fixing this with the old patches needs a custom GtkCellRendererText is that it needs a rather direct way of setting the Pango layout's height (and width, I guess) along with the ellipsize property. I have tried using gtk_cell_renderer_text_set_fixed_height_from_font() in #811 (closed), but for some reason this doesn't seem to work. Also, setting the ellipsize property alone causes the cell to be drawn with only one line of text at minimum size, which with an ellipsis is ususally unreadable.
If anyone knows a better way of prodding the PangoLayout with a plain GtkCellRendererText, let me know. As far as I can see, GCRT doesn't even expose the PL. If we could see it, we might be able to make a minimally derived ThunarCellRendererText with overrides for get_request_mode(), get_preferred_width(), get_preferred_height_for_width() etc.
Hello! I was just going to create an issue about this problem before finding this thread. I would just like to state that I face the same problem as well, and have switched to "compact view" because of it. Here is how it looks on my system, should it help:
Don't know if this is worth a new bug report or can be attached here, but since the 4.18 update the selection height is not adjusted to the selected item but rather is equal for all items in a row. Looks a bit weird with long filenames, I think, the selection height was variable in 4.16 which makes more sense to me:
That selection frame is only used if file highlight is enabled, it's not directly related to consistent vertical spacing. (So just disable file highlight to get back the old behavior)
File highlight draws a shape on the complete background, not only on the filename-label. We had a discussion on it on !226 (merged) ... if you read through it, maybe you have an idea on what would be doable and would look better.
It gets worse. At higher zoom levels, the height is much greater than even the longest file name (up to double that height). See the empty space below the longest name here:
It's 4.18 on Debian 12 but again it only happens at high zoom levels. The zoom level on your screenshot is too low for that to happen.
There shouldn't be any steps required from the "factory" XFCE settings, other than zooming with Ctrl+, though you have to make sure the file name still takes many lines after zooming.
Note: I also have a machine with Thunar 4.16.8 and this issue is there too, so it's actually a long standing one rather than a regression as I first thought: