[nautilus/wip/antoniof/new-pathbar: 3/5] ellispize
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-pathbar: 3/5] ellispize
- Date: Fri, 26 Nov 2021 16:17:04 +0000 (UTC)
commit aeecca7aa774b02b95afd2c55fc22f53d3663950
Author: António Fernandes <antoniof gnome org>
Date: Fri Nov 26 13:43:12 2021 +0000
ellispize
src/nautilus-pathbar.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 69ff216b2..15aea58fe 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -58,6 +58,8 @@ typedef enum
static guint path_bar_signals[LAST_SIGNAL] = { 0 };
+#define NAUTILUS_PATH_BAR_BUTTON_ELLISPIZE_MINIMUM_CHARS 7
+
typedef struct
{
GtkWidget *button;
@@ -810,9 +812,26 @@ nautilus_path_bar_update_button_appearance (ButtonData *button_data,
if (button_data->label != NULL)
{
+ gint min_chars = NAUTILUS_PATH_BAR_BUTTON_ELLISPIZE_MINIMUM_CHARS;
+
+ if (current_dir)
+ {
+ min_chars = 3 * min_chars;
+ }
+
gtk_label_set_text (GTK_LABEL (button_data->label), dir_name);
- }
+ if (g_utf8_strlen (dir_name, -1) > min_chars + 1)
+ {
+ gtk_label_set_width_chars (GTK_LABEL (button_data->label), min_chars);
+ gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_MIDDLE);
+ }
+ else
+ {
+ gtk_label_set_width_chars (GTK_LABEL (button_data->label), -1);
+ gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_NONE);
+ }
+ }
icon = get_gicon (button_data);
if (icon != NULL)
{
@@ -1114,7 +1133,6 @@ make_button_data (NautilusPathBar *self,
if (button_data->label != NULL)
{
- gtk_label_set_ellipsize (GTK_LABEL (button_data->label), PANGO_ELLIPSIZE_MIDDLE);
gtk_label_set_single_line_mode (GTK_LABEL (button_data->label), TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]