summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2023-01-08 00:09:43 +0000
committerAntónio Fernandes <antoniof@gnome.org>2023-01-08 00:28:49 +0000
commitbeeb2da98f4213a1e225291ae6b6c379f85398d4 (patch)
tree2c587f4eb65130ce07b2e0e1756765be2a8a1d41
parent755cfdce38312dfc6572839a6fdbb1b39e1b4fe6 (diff)
downloadnautilus-beeb2da98f4213a1e225291ae6b6c379f85398d4.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.
-rw-r--r--src/nautilus-grid-cell.c22
-rw-r--r--src/resources/ui/nautilus-grid-cell.ui1
2 files changed, 23 insertions, 0 deletions
diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c
index 878673211..d95985e9f 100644
--- a/src/nautilus-grid-cell.c
+++ b/src/nautilus-grid-cell.c
@@ -167,6 +167,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)
{
@@ -202,6 +221,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",
diff --git a/src/resources/ui/nautilus-grid-cell.ui b/src/resources/ui/nautilus-grid-cell.ui
index cfc0ced89..1a9204050 100644
--- a/src/resources/ui/nautilus-grid-cell.ui
+++ b/src/resources/ui/nautilus-grid-cell.ui
@@ -51,6 +51,7 @@
</style>
<child>
<object class="GtkLabel" id="label">
+ <property name="has-tooltip">true</property>
<property name="ellipsize">middle</property>
<property name="justify">center</property>
<property name="lines">3</property>