diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-07-10 14:13:35 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-07-10 14:22:59 -0400 |
commit | 4aa649e9cd9db0ae145a1ad25f63517f9baea5db (patch) | |
tree | fc6c1b60354ca482af29fb03c47c443ef18905d7 /gtk/gtktreeviewcolumn.c | |
parent | e1112dce6d624561f8a87f47e1eff38a982ac38d (diff) | |
download | gtk+-4aa649e9cd9db0ae145a1ad25f63517f9baea5db.tar.gz |
GtkTreeView: Avoid overlapping sort indicator
Hide the sort indicator when it would overlap the column title.
Diffstat (limited to 'gtk/gtktreeviewcolumn.c')
-rw-r--r-- | gtk/gtktreeviewcolumn.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c index 87fc72b4ae..af8d0b477e 100644 --- a/gtk/gtktreeviewcolumn.c +++ b/gtk/gtktreeviewcolumn.c @@ -819,6 +819,33 @@ gtk_tree_view_column_cell_layout_get_area (GtkCellLayout *cell_layout) /* Button handling code */ static void +maybe_hide_arrow (GtkWidget *arrow, + GtkAllocation *allocation, + GtkTreeViewColumn *col) +{ + GtkAllocation a; + gboolean overlap; + + gtk_widget_get_allocation (col->priv->alignment, &a); + + /* resizable columns can be shrunk all the way; in that case + * we don't want to render the sort indicator on top of the + * label, but just hide it. + */ + if ((a.x <= allocation->x && allocation->x < a.x + a.width) || + (allocation->x <= a.x && a.x < allocation->x + allocation->width)) + overlap = TRUE; + else + overlap = FALSE; + + if (col->priv->show_sort_indicator && !overlap) + gtk_widget_set_opacity (arrow, 1); + else + gtk_widget_set_opacity (arrow, 0); +} + + +static void gtk_tree_view_column_create_button (GtkTreeViewColumn *tree_column) { GtkTreeViewColumnPrivate *priv = tree_column->priv; @@ -878,6 +905,9 @@ G_GNUC_END_IGNORE_DEPRECATIONS gtk_container_add (GTK_CONTAINER (priv->alignment), child); gtk_container_add (GTK_CONTAINER (priv->button), hbox); + g_signal_connect (priv->arrow, "size-allocate", + G_CALLBACK (maybe_hide_arrow), tree_column); + gtk_widget_show (hbox); gtk_widget_show (priv->alignment); gtk_tree_view_column_update_button (tree_column); |