diff options
author | António Fernandes <antoniof@gnome.org> | 2023-01-08 00:09:43 +0000 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2023-01-07 20:20:09 -0500 |
commit | c0653d5376bac27dc80720218b56ede05d277236 (patch) | |
tree | 690cbfb3319224d9ef1d7cf987ae6433cde57050 /src/nautilus-grid-cell.c | |
parent | ed2f06707613cea9fa6da482ef3a056f55d2615e (diff) | |
download | nautilus-c0653d5376bac27dc80720218b56ede05d277236.tar.gz |
grid-cell: Show tooltip for ellipsized names
The old canvas expanded filename over the next row when the item was
selected. This is impossible to replicate in GtkGridView due to the
next row getting drawn after (== on top of) the previous one.
This is perceived as a feature regression. So, let's aleviate it
using tooltips when the filename is ellipsized.
(cherry picked from commit beeb2da98f4213a1e225291ae6b6c379f85398d4)
Diffstat (limited to 'src/nautilus-grid-cell.c')
-rw-r--r-- | src/nautilus-grid-cell.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c index 475d84990..e2d1724fe 100644 --- a/src/nautilus-grid-cell.c +++ b/src/nautilus-grid-cell.c @@ -169,6 +169,25 @@ on_item_is_cut_changed (NautilusGridCell *self) } } +static gboolean +on_label_query_tooltip (GtkWidget *widget, + int x, + int y, + gboolean keyboard_tip, + GtkTooltip *tooltip, + gpointer user_data) +{ + GtkLabel *label = GTK_LABEL (widget); + + if (pango_layout_is_ellipsized (gtk_label_get_layout (label))) + { + gtk_tooltip_set_markup (tooltip, gtk_label_get_label (label)); + return TRUE; + } + + return FALSE; +} + static void finalize (GObject *object) { @@ -204,6 +223,9 @@ nautilus_grid_cell_init (NautilusGridCell *self) { gtk_widget_init_template (GTK_WIDGET (self)); + g_signal_connect (self->label, "query-tooltip", + G_CALLBACK (on_label_query_tooltip), NULL); + /* Connect automatically to an item. */ self->item_signal_group = g_signal_group_new (NAUTILUS_TYPE_VIEW_ITEM); g_signal_group_connect_swapped (self->item_signal_group, "notify::icon-size", |