I wrote patches for this a while back. I'll attach them to this mail,
maybe they'll prove useful for you. I can't exactly remember which
version I wrote them against but I think it should be the 4.12's Thunar
already. Here's a short overview (I'm citing my notes from when I wrote
those patches):
thunar_fixed_width_final.patch
This patch addresses the issue of varying horizontal spacing in icon
view by using a fixed width (= maximum width) for the columns of the
grid layout.
The patch introduces the following xfconf variable:
misc-fixed-item-width: toggles the fixed item width on (TRUE) or
off (FALSE); default: TRUE
The patch only affects icon view and the new behavior only applies
to views with text below items.
thunar_truncate_final.patch
The appended patch addresses the issue of huge filename labels by
adding filename truncation using ellipsis insertion and introduces 3
new 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 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 at the end.
_______________________________
The first patch is essentially what you are looking for. I added a
second as a bonus since it complements the first one beautifully by
limiting the size of item labels. This guarantees fixed horizontal
spacing as well as limited vertical spacing when using text below icons.
The truncation should still apply to text besides icons as well. Use the
xfconf editor to set the introduced settings values.
Be aware that I wrote those patches a long time ago. I currently can't
check whether they are still working but they should point you into the
right direction at least!
Cheers!
Markus.
> This is a cosmetic issue but it's driving me bonkers.
>
> I only use Thunar with the option to "View as Icons". I'd like the spacing
> between icons in Thunar to be constant, but Thunar insists on increasing the
> spacing between icons when long filenames are detected (e.g., when I press
> Control+H in my home folder and hidden files with long names show up).
>
> A user perplexed by this same issue documented it here, with screenshots:
> https://bbs.archlinux.org/viewtopic.php?id=199121
>
> If I put something like this in my ~/.gtkrc-2.0 to increase the
> baseline/initial distance between icons...
>
> style "thunar-spaced-out-icons"
> {
> ThunarIconView::column-spacing = 70
> ThunarIconView::row-spacing = 70
> }
> class "ThunarIconView" style "thunar-spaced-out-icons"
>
> ...Thunar increases the distance between icons even more when long file names
> are detected.
>
> Is there a setting that tells Thunar to NOT change the distance between
> icons? If there is no such setting, I'd like to recompile Thunar without this
> "feature". I grepped the source code for "column-spacing" and didn't find an
> obvious culprit, so the offending function must change a variable of some
> other name. Please help.
> _______________________________________________
> Thunar-dev mailing list
> [email protected]
> https://mail.xfce.org/mailman/listinfo/thunar-dev
diff -rup thunar-1.6.10-orig/thunar/thunar-icon-view.c thunar-1.6.10/thunar/thunar-icon-view.c
--- thunar-1.6.10-orig/thunar/thunar-icon-view.c 2015-08-06 13:45:15.209184902 +0200
+++ thunar-1.6.10/thunar/thunar-icon-view.c 2015-08-08 11:07:58.586438128 +0200
@@ -23,7 +23,7 @@
#include <thunar/thunar-icon-view.h>
#include <thunar/thunar-private.h>
-
+#include <thunar/thunar-preferences.h>
/* Property identifiers */
@@ -31,6 +31,7 @@ enum
{
PROP_0,
PROP_TEXT_BESIDE_ICONS,
+ PROP_FIXED_ITEM_WIDTH
};
@@ -52,6 +53,8 @@ struct _ThunarIconViewClass
struct _ThunarIconView
{
ThunarAbstractIconView __parent__;
+ gboolean fixed_width;
+ gboolean text_beside_icons;
};
@@ -89,6 +92,22 @@ thunar_icon_view_class_init (ThunarIconV
"text-beside-icons",
FALSE,
EXO_PARAM_WRITABLE));
+
+ /**
+ * ThunarIconView:fixed-item-width:
+ *
+ * Whether the icon a view should always use the maximum width
+ * (= wrap width) for items displayed so that the grid layout
+ * stays the same between folders with either long or short file
+ * names
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_FIXED_ITEM_WIDTH,
+ g_param_spec_boolean ("fixed-item-width",
+ "fixed-item-width",
+ "fixed-item-width",
+ FALSE,
+ EXO_PARAM_WRITABLE));
}
@@ -108,7 +127,10 @@ thunar_icon_view_init (ThunarIconView *i
/* synchronize the "text-beside-icons" property with the global preference */
exo_binding_new (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->preferences), "misc-text-beside-icons", G_OBJECT (icon_view), "text-beside-icons");
-}
+
+ /* synchronize the "fixed-item-width" property with the global preference */
+ exo_binding_new (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->preferences), "misc-fixed-item-width", G_OBJECT (icon_view), "fixed-item-width");
+ }
@@ -119,20 +141,27 @@ thunar_icon_view_set_property (GObject
GParamSpec *pspec)
{
ThunarStandardView *standard_view = THUNAR_STANDARD_VIEW (object);
+ ThunarIconView *icon_view = THUNAR_ICON_VIEW(standard_view);
switch (prop_id)
{
case PROP_TEXT_BESIDE_ICONS:
if (G_UNLIKELY (g_value_get_boolean (value)))
{
+ icon_view->text_beside_icons = TRUE;
+
+ /* reset item width to automatic in case it has been modified via the fixed-width property */
+ exo_icon_view_set_item_width (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), -1);
+
exo_icon_view_set_orientation (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), GTK_ORIENTATION_HORIZONTAL);
g_object_set (G_OBJECT (standard_view->name_renderer), "wrap-width", 128, "yalign", 0.5f, "alignment", PANGO_ALIGN_LEFT, NULL);
-
+
/* disconnect the "zoom-level" signal handler, since we're using a fixed wrap-width here */
g_signal_handlers_disconnect_by_func (object, thunar_icon_view_zoom_level_changed, NULL);
}
else
{
+ icon_view->text_beside_icons = FALSE;
exo_icon_view_set_orientation (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), GTK_ORIENTATION_VERTICAL);
g_object_set (G_OBJECT (standard_view->name_renderer), "yalign", 0.0f, "alignment", PANGO_ALIGN_CENTER, NULL);
@@ -142,6 +171,16 @@ thunar_icon_view_set_property (GObject
}
break;
+ case PROP_FIXED_ITEM_WIDTH:
+ icon_view->fixed_width = g_value_get_boolean (value);
+
+ /* only refresh item display and manipulate wrap-width when text is below icons (default) */
+ if (G_LIKELY (!icon_view->text_beside_icons))
+ {
+ thunar_icon_view_zoom_level_changed (standard_view);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -176,6 +215,8 @@ thunar_icon_view_zoom_level_changed (Thu
{
gint wrap_width;
+ ThunarIconView *icon_view = THUNAR_ICON_VIEW(standard_view);
+
_thunar_return_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view));
/* determine the "wrap-width" depending on the "zoom-level" */
@@ -202,10 +243,15 @@ thunar_icon_view_zoom_level_changed (Thu
break;
}
+ if (icon_view->fixed_width && !icon_view->text_beside_icons)
+ {
+ exo_icon_view_set_item_width (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), wrap_width);
+ }
+ else
+ {
+ exo_icon_view_set_item_width (EXO_ICON_VIEW (GTK_BIN (standard_view)->child), -1);
+ }
+
/* set the new "wrap-width" for the text renderer */
g_object_set (G_OBJECT (standard_view->name_renderer), "wrap-width", wrap_width, NULL);
-}
-
-
-
-
+}
\ Kein Zeilenumbruch am Dateiende.
Nur in thunar-1.6.10/thunar: thunar-icon-view.c.orig.
Nur in thunar-1.6.10/thunar: thunar-icon-view.c.rej.
diff -rup thunar-1.6.10-orig/thunar/thunar-preferences.c thunar-1.6.10/thunar/thunar-preferences.c
--- thunar-1.6.10-orig/thunar/thunar-preferences.c 2015-08-06 13:45:15.217184902 +0200
+++ thunar-1.6.10/thunar/thunar-preferences.c 2015-08-08 11:02:27.106452068 +0200
@@ -89,6 +89,7 @@ enum
PROP_MISC_SMALL_TOOLBAR_ICONS,
PROP_MISC_TAB_CLOSE_MIDDLE_CLICK,
PROP_MISC_TEXT_BESIDE_ICONS,
+ PROP_MISC_FIXED_ITEM_WIDTH,
PROP_MISC_THUMBNAIL_MODE,
PROP_MISC_FILE_SIZE_BINARY,
PROP_SHORTCUTS_ICON_EMBLEMS,
@@ -679,6 +680,21 @@ thunar_preferences_class_init (ThunarPre
NULL,
FALSE,
EXO_PARAM_READWRITE);
+
+ /**
+ * ThunarPreferences:misc-fixed-item-width:
+ *
+ * Whether the icon view should always use the maximum width
+ * (= wrap width) for items displayed so that the grid layout
+ * stays the same between folders with either long or short file
+ * names
+ **/
+ preferences_props[PROP_MISC_FIXED_ITEM_WIDTH] =
+ g_param_spec_boolean ("misc-fixed-item-width",
+ "MiscFixedItemWidth",
+ NULL,
+ FALSE,
+ EXO_PARAM_READWRITE);
/**
* ThunarPreferences:misc-thumbnail-mode:
diff -rup thunar-1.6.10-orig/thunar/thunar-compact-view.c thunar-1.6.10/thunar/thunar-compact-view.c
--- thunar-1.6.10-orig/thunar/thunar-compact-view.c 2015-08-06 13:45:15.221184901 +0200
+++ thunar-1.6.10/thunar/thunar-compact-view.c 2015-08-07 22:25:46.378310555 +0200
@@ -67,7 +67,10 @@ thunar_compact_view_class_init (ThunarCo
static void
thunar_compact_view_init (ThunarCompactView *compact_view)
{
- /* initialize the icon view properties */
+ gboolean truncate_filenames;
+ guint wrap_width;
+
+ /* initialize the icon view properties */
exo_icon_view_set_margin (EXO_ICON_VIEW (GTK_BIN (compact_view)->child), 3);
exo_icon_view_set_layout_mode (EXO_ICON_VIEW (GTK_BIN (compact_view)->child), EXO_ICON_VIEW_LAYOUT_COLS);
exo_icon_view_set_orientation (EXO_ICON_VIEW (GTK_BIN (compact_view)->child), GTK_ORIENTATION_HORIZONTAL);
@@ -77,13 +80,22 @@ thunar_compact_view_init (ThunarCompactV
"ypad", 2u,
NULL);
+
+ g_object_get (THUNAR_STANDARD_VIEW (compact_view)->preferences, "misc-truncate-filenames", &truncate_filenames, NULL);
+ g_object_get (THUNAR_STANDARD_VIEW (compact_view)->preferences, "compact-view-text-width", &wrap_width, NULL);
+
+ /* use default value if truncation is disabled */
+ wrap_width = (truncate_filenames) ? wrap_width : 1280;
+
/* setup the name renderer (wrap only very long names) */
g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (compact_view)->name_renderer),
"wrap-mode", PANGO_WRAP_WORD_CHAR,
- "wrap-width", 1280,
+ "ellipsize-mode", (truncate_filenames ? PANGO_ELLIPSIZE_MIDDLE : PANGO_ELLIPSIZE_NONE),
+ "wrap-width", wrap_width,
"xalign", 0.0f,
"yalign", 0.5f,
NULL);
+
}
diff -rup thunar-1.6.10-orig/thunar/thunar-icon-view.c thunar-1.6.10/thunar/thunar-icon-view.c
--- thunar-1.6.10-orig/thunar/thunar-icon-view.c 2015-08-06 13:45:15.209184902 +0200
+++ thunar-1.6.10/thunar/thunar-icon-view.c 2015-08-07 22:25:53.206310268 +0200
@@ -96,14 +96,23 @@ thunar_icon_view_class_init (ThunarIconV
static void
thunar_icon_view_init (ThunarIconView *icon_view)
{
+ gboolean truncate_filenames;
+ guint text_lines;
+
/* setup the icon renderer */
g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->icon_renderer),
"ypad", 3u,
NULL);
+
+ g_object_get (THUNAR_STANDARD_VIEW (icon_view)->preferences, "misc-truncate-filenames", &truncate_filenames, NULL);
+ g_object_get (THUNAR_STANDARD_VIEW (icon_view)->preferences, "icon-view-text-lines", &text_lines, NULL);
+
/* setup the name renderer */
g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (icon_view)->name_renderer),
"wrap-mode", PANGO_WRAP_WORD_CHAR,
+ "ellipsize-mode", (truncate_filenames ? PANGO_ELLIPSIZE_MIDDLE : PANGO_ELLIPSIZE_NONE),
+ "text-lines", text_lines,
NULL);
/* synchronize the "text-beside-icons" property with the global preference */
Nur in thunar-1.6.10/thunar: thunar-main.o.
diff -rup thunar-1.6.10-orig/thunar/thunar-preferences.c thunar-1.6.10/thunar/thunar-preferences.c
--- thunar-1.6.10-orig/thunar/thunar-preferences.c 2015-08-06 13:45:15.217184902 +0200
+++ thunar-1.6.10/thunar/thunar-preferences.c 2015-08-07 21:58:01.170380585 +0200
@@ -95,6 +95,9 @@ enum
PROP_SHORTCUTS_ICON_SIZE,
PROP_TREE_ICON_EMBLEMS,
PROP_TREE_ICON_SIZE,
+ PROP_ICON_VIEW_TEXT_LINES,
+ PROP_COMPACT_VIEW_TEXT_WIDTH,
+ PROP_MISC_TRUNCATE_FILENAMES,
N_PROPERTIES,
};
@@ -759,6 +762,46 @@ thunar_preferences_class_init (ThunarPre
THUNAR_ICON_SIZE_SMALLEST,
EXO_PARAM_READWRITE);
+ /**
+ * ThunarPreferences:icon-view-text-lines:
+ *
+ * Maximum number of text lines displayed for icon
+ * labels in icon view. Only applicable if filename
+ * truncation is enabled.
+ **/
+ preferences_props[PROP_ICON_VIEW_TEXT_LINES] =
+ g_param_spec_uint ("icon-view-text-lines",
+ "IconViewTextLines",
+ NULL,
+ 1u, G_MAXUINT, 4u,
+ EXO_PARAM_READWRITE);
+
+ /**
+ * ThunarPreferences:compact-view-text-width:
+ *
+ * Maximum width of item labels in compact view.
+ * Only applicable if filename truncation is enabled.
+ **/
+ preferences_props[PROP_COMPACT_VIEW_TEXT_WIDTH] =
+ g_param_spec_uint ("compact-view-text-width",
+ "CompactViewTextWidth",
+ NULL,
+ 100u, G_MAXUINT, 300u,
+ EXO_PARAM_READWRITE);
+
+ /**
+ * ThunarPreferences:misc-truncate-filenames:
+ *
+ * Whether to truncate (ellipsize) filenames
+ * in icon and compact view.
+ **/
+ preferences_props[PROP_MISC_TRUNCATE_FILENAMES] =
+ g_param_spec_boolean ("misc-truncate-filenames",
+ "MiscTruncateFilenames",
+ NULL,
+ TRUE,
+ EXO_PARAM_READWRITE);
+
/* install all properties */
g_object_class_install_properties (gobject_class, N_PROPERTIES, preferences_props);
}
Nur in thunar-1.6.10/thunar: thunar-settings.desktop.
diff -rup thunar-1.6.10-orig/thunar/thunar-text-renderer.c thunar-1.6.10/thunar/thunar-text-renderer.c
--- thunar-1.6.10-orig/thunar/thunar-text-renderer.c 2015-08-06 13:45:15.221184901 +0200
+++ thunar-1.6.10/thunar/thunar-text-renderer.c 2015-08-07 22:43:53.938264819 +0200
@@ -47,6 +47,8 @@ enum
PROP_TEXT,
PROP_WRAP_MODE,
PROP_WRAP_WIDTH,
+ PROP_ELLIPSIZE_MODE,
+ PROP_LINES,
N_PROPERTIES
};
@@ -130,6 +132,8 @@ struct _ThunarTextRenderer
gint char_height;
PangoWrapMode wrap_mode;
gint wrap_width;
+ PangoEllipsizeMode ellipsize_mode;
+ gint fixed_text_lines;
guint follow_state : 1;
gint focus_width;;
PangoAlignment alignment;
@@ -252,6 +256,35 @@ thunar_text_renderer_class_init (ThunarT
-1, G_MAXINT, -1,
EXO_PARAM_READWRITE);
+ /**
+ * ThunarTextRenderer:ellipsize-mode:
+ *
+ * Specifies whether to break the string into multiple lines or
+ * to shorten the line, if the cell renderer does not have enough room
+ * to display the entire string. This property has
+ * no effect unless the wrap-width property is set.
+ **/
+ text_renderer_props[PROP_ELLIPSIZE_MODE] =
+ g_param_spec_enum ("ellipsize-mode",
+ "ellipsize-mode",
+ "ellipsize-mode",
+ PANGO_TYPE_ELLIPSIZE_MODE,
+ PANGO_ELLIPSIZE_NONE,
+ EXO_PARAM_READWRITE);
+
+ /**
+ * ThunarTextRenderer:text-lines:
+ *
+ * Specifies then amount of lines that are allowed in total.
+ * If the text would exceed this amount, it will get ellipsized.
+ **/
+ text_renderer_props[PROP_LINES] =
+ g_param_spec_uint ("text-lines",
+ "text-lines",
+ "text-lines",
+ 0, G_MAXUINT, 1,
+ EXO_PARAM_READWRITE);
+
/* install properties */
g_object_class_install_properties (gobject_class, N_PROPERTIES, text_renderer_props);
@@ -336,6 +369,14 @@ thunar_text_renderer_get_property (GObje
g_value_set_int (value, text_renderer->wrap_width);
break;
+ case PROP_LINES:
+ g_value_set_uint (value, text_renderer->fixed_text_lines);
+ break;
+
+ case PROP_ELLIPSIZE_MODE:
+ g_value_set_enum (value, text_renderer->ellipsize_mode);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -389,6 +430,14 @@ thunar_text_renderer_set_property (GObje
gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, -1);
break;
+ case PROP_ELLIPSIZE_MODE:
+ text_renderer->ellipsize_mode = g_value_get_enum (value);
+ break;
+
+ case PROP_LINES:
+ text_renderer->fixed_text_lines = g_value_get_uint (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -432,6 +481,8 @@ thunar_text_renderer_get_size (GtkCellRe
/* calculate the real text dimension */
pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE);
pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode);
+ pango_layout_set_ellipsize (text_renderer->layout, text_renderer->ellipsize_mode);
+ pango_layout_set_height(text_renderer->layout, -text_renderer->fixed_text_lines);
pango_layout_set_text (text_renderer->layout, text_renderer->text, -1);
pango_layout_get_pixel_size (text_renderer->layout, &text_width, &text_height);
}
_______________________________________________
Thunar-dev mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/thunar-dev