[nautilus/gnome-42] pathbar: Avoid excessive minimum label width



commit d6f958056afa4e0a6a609eddc6bcdaf095259c43
Author: António Fernandes <antoniojpfernandes gmail com>
Date:   Mon Mar 28 08:59:00 2022 +0000

    pathbar: Avoid excessive minimum label width
    
    We set a minimum width in characters for the labels in the pathbar not
    to collapse into a single ellipsis. Labels under this threshold are
    excluded because in that case we just set them not to ellipsize and let
    GtkLabel take care of the sizing.
    
    However, the width in characters metric fails for variable-width fonts,
    such that in some cases we still set a wider label width than what the
    label text occupies.
    
    So, raise the ellipsizing threshold further, and do it proportionally.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/-/issues/2202
    
    (cherry picked from commit aa4a6a963d6bd0d27ce47bcecbd8160794586e51)

 src/nautilus-pathbar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 8266ec8ed..1ae389153 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -841,9 +841,9 @@ nautilus_path_bar_update_button_appearance (ButtonData *button_data,
          *
          * Due to variable width fonts, labels can be shorter than the space
          * that would be reserved by setting a minimum amount of characters.
-         * Compensate for this with a tolerance of +1 characters.
+         * Compensate for this with a tolerance of +50% characters.
          */
-        if (g_utf8_strlen (dir_name, -1) > min_chars + 1)
+        if (g_utf8_strlen (dir_name, -1) > min_chars * 1.5)
         {
             gtk_label_set_width_chars (GTK_LABEL (button_data->label), min_chars);
             gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_MIDDLE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]