diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2021-11-22 16:34:20 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2021-11-22 16:34:50 +0100 |
commit | a3855e8f1235ab71dc52a7729a08c83740fd47a1 (patch) | |
tree | 13e651a614be1dc924d964abad371e8f79ffd84a | |
parent | e239aca6f41ac98bfc6e871fd3bad9384254eac1 (diff) | |
download | fiv-a3855e8f1235ab71dc52a7729a08c83740fd47a1.tar.gz fiv-a3855e8f1235ab71dc52a7729a08c83740fd47a1.tar.xz fiv-a3855e8f1235ab71dc52a7729a08c83740fd47a1.zip |
Add a tooltip to ellipsized directory labels
-rw-r--r-- | fastiv-sidebar.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fastiv-sidebar.c b/fastiv-sidebar.c index 44e98bf..57ef40d 100644 --- a/fastiv-sidebar.c +++ b/fastiv-sidebar.c @@ -67,6 +67,19 @@ fastiv_sidebar_class_init(FastivSidebarClass *klass) NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_FILE); } +static gboolean +on_rowlabel_query_tooltip(GtkWidget *widget, + G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y, + G_GNUC_UNUSED gboolean keyboard_tooltip, GtkTooltip *tooltip) +{ + GtkLabel *label = GTK_LABEL(widget); + if (!pango_layout_is_ellipsized(gtk_label_get_layout(label))) + return FALSE; + + gtk_tooltip_set_text(tooltip, gtk_label_get_text(label)); + return TRUE; +} + static GtkWidget * create_row(GFile *file, const char *icon_name) { @@ -88,6 +101,9 @@ create_row(GFile *file, const char *icon_name) GtkWidget *rowlabel = gtk_label_new(name); gtk_label_set_ellipsize(GTK_LABEL(rowlabel), PANGO_ELLIPSIZE_END); + gtk_widget_set_has_tooltip(rowlabel, TRUE); + g_signal_connect(rowlabel, "query-tooltip", + G_CALLBACK(on_rowlabel_query_tooltip), NULL); gtk_style_context_add_class( gtk_widget_get_style_context(rowlabel), "sidebar-label"); gtk_container_add(GTK_CONTAINER(rowbox), rowlabel); |