summaryrefslogtreecommitdiff
path: root/libcaja-private
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2019-11-22 21:29:30 +0100
committerraveit65 <[email protected]>2019-11-22 21:29:30 +0100
commitea81a5e3bd1cc8e9ba2b92ced9db1ebae803e24d (patch)
tree23472009e1e9bcdd6b04a9450bcd12d0cecb4e0b /libcaja-private
parent8c07068221e5702372affbbbbdb57ce0ba33d22b (diff)
downloadcaja-ea81a5e3bd1cc8e9ba2b92ced9db1ebae803e24d.tar.bz2
caja-ea81a5e3bd1cc8e9ba2b92ced9db1ebae803e24d.tar.xz
canvas-item: Don't hyphenate filenames
fixes https://github.com/mate-desktop/caja/issues/1284 Pango 1.44 got the ability to automatically hyphenate on line breaks, which is on by default, but can be set off by a new attribute. As a result, we now hyphenate filenames, which is confusing, because a filename may already include hyphens. To restore the previous behavior, let's not insert hyphens when breaking filenames in multiple lines. Inspired by https://gitlab.gnome.org/GNOME/nautilus/commit/9738d85
Diffstat (limited to 'libcaja-private')
-rw-r--r--libcaja-private/caja-icon-canvas-item.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c
index 71d56fc3..cb2d8316 100644
--- a/libcaja-private/caja-icon-canvas-item.c
+++ b/libcaja-private/caja-icon-canvas-item.c
@@ -60,6 +60,14 @@
#define MAX_TEXT_WIDTH_BESIDE 90
#define MAX_TEXT_WIDTH_BESIDE_TOP_TO_BOTTOM 150
+#ifndef PANGO_CHECK_VERSION
+#define PANGO_CHECK_VERSION(major, minor, micro) \
+ (PANGO_VERSION_MAJOR > (major) || \
+ (PANGO_VERSION_MAJOR == (major) && PANGO_VERSION_MINOR > (minor)) || \
+ (PANGO_VERSION_MAJOR == (major) && PANGO_VERSION_MINOR == (minor) && \
+ PANGO_VERSION_MICRO >= (micro)))
+#endif
+
/* special text height handling
* each item has three text height variables:
* + text_height: actual height of the displayed (i.e. on-screen) PangoLayout.
@@ -1967,12 +1975,18 @@ create_label_layout (CajaIconCanvasItem *item,
GString *str;
char *zeroified_text;
const char *p;
+ #if PANGO_CHECK_VERSION (1, 44, 0)
+ PangoAttrList *attr_list;
+ #endif
canvas_item = EEL_CANVAS_ITEM (item);
container = CAJA_ICON_CONTAINER (canvas_item->canvas);
context = gtk_widget_get_pango_context (GTK_WIDGET (canvas_item->canvas));
layout = pango_layout_new (context);
+ #if PANGO_CHECK_VERSION (1, 44, 0)
+ attr_list = pango_attr_list_new ();
+ #endif
zeroified_text = NULL;
@@ -2019,6 +2033,11 @@ create_label_layout (CajaIconCanvasItem *item,
pango_layout_set_spacing (layout, LABEL_LINE_SPACING);
pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);
+ #if PANGO_CHECK_VERSION (1, 44, 0)
+ pango_attr_list_insert (attr_list, pango_attr_insert_hyphens_new (FALSE));
+ pango_layout_set_attributes (layout, attr_list);
+ #endif
+
/* Create a font description */
if (container->details->font)
{
@@ -2034,6 +2053,9 @@ create_label_layout (CajaIconCanvasItem *item,
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
g_free (zeroified_text);
+ #if PANGO_CHECK_VERSION (1, 44, 0)
+ pango_attr_list_unref (attr_list);
+ #endif
return layout;
}