diff src/layout.c @ 2808:1d43d9582f36

Tooltip for path entry The current path entry can be partially obscured if the vertical divider is pushed too far to the left. This commit shows the current path as the tooltip.
author Colin Clark <colin.clark@cclark.uk>
date Thu, 02 Aug 2018 20:15:36 +0100
parents bcd52f7517c7
children e9e8e8b2afce
line wrap: on
line diff
--- a/src/layout.c	Thu Aug 02 14:28:17 2018 +0100
+++ b/src/layout.c	Thu Aug 02 20:15:36 2018 +0100
@@ -287,6 +287,24 @@
 	gtk_widget_set_sensitive(lw->back_button, (n > 1));
 }
 
+static gboolean path_entry_tooltip_cb(GtkWidget *widget, gpointer data)
+{
+	LayoutWindow *lw = data;
+	GList *box_child_list;
+	GtkComboBox *path_entry;
+	gchar *current_path;
+
+	box_child_list = gtk_container_get_children(GTK_CONTAINER(widget));
+	path_entry = box_child_list->data;
+	current_path = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(path_entry));
+	gtk_widget_set_tooltip_text(GTK_WIDGET(widget), current_path);
+
+	g_free(current_path);
+	g_list_free(box_child_list);
+
+	return FALSE;
+}
+
 static GtkWidget *layout_tool_setup(LayoutWindow *lw)
 {
 	GtkWidget *box;
@@ -311,6 +329,8 @@
 	tab_completion_add_append_func(lw->path_entry, layout_path_entry_tab_append_cb, lw);
 	gtk_box_pack_start(GTK_BOX(box), tabcomp, FALSE, FALSE, 0);
 	gtk_widget_show(tabcomp);
+	gtk_widget_set_has_tooltip(GTK_WIDGET(tabcomp), TRUE);
+	g_signal_connect(G_OBJECT(tabcomp), "query_tooltip", G_CALLBACK(path_entry_tooltip_cb), lw);
 
 #if GTK_CHECK_VERSION(3,20,0)
 	g_signal_connect(G_OBJECT(gtk_widget_get_parent(gtk_widget_get_parent(lw->path_entry))), "changed",