From 8a3c25ca66e7c2a4e1575fdf10ef0bb1cf66f846 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 13 Mar 2016 23:05:54 -0400 Subject: [PATCH] path bar: Stop mishandling slider buttons We must call get_preferred_width/height on the slider buttons before allocating them, otherwise the layout machinery spews warnings. --- gtk/gtkpathbar.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c index 416786c7b9..83396a03d9 100644 --- a/gtk/gtkpathbar.c +++ b/gtk/gtkpathbar.c @@ -368,12 +368,23 @@ gtk_path_bar_get_preferred_width (GtkWidget *widget, /* Theoretically, the slider could be bigger than the other button. But we're * not going to worry about that now. */ - path_bar->priv->slider_width = MIN (height * 2 / 3 + 5, height); + path_bar->priv->slider_width = 0; + + gtk_widget_get_preferred_width (path_bar->priv->up_slider_button, &child_min, &child_nat); if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL) { - *minimum += path_bar->priv->slider_width * 2; - *natural += path_bar->priv->slider_width * 2; + *minimum += child_min; + *natural += child_nat; } + path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min); + + gtk_widget_get_preferred_width (path_bar->priv->down_slider_button, &child_min, &child_nat); + if (path_bar->priv->button_list && path_bar->priv->button_list->next != NULL) + { + *minimum += child_min; + *natural += child_nat; + } + path_bar->priv->slider_width = MAX (path_bar->priv->slider_width, child_min); } static void @@ -398,6 +409,14 @@ gtk_path_bar_get_preferred_height (GtkWidget *widget, *minimum = MAX (*minimum, child_min); *natural = MAX (*natural, child_nat); } + + gtk_widget_get_preferred_height (path_bar->priv->up_slider_button, &child_min, &child_nat); + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); + + gtk_widget_get_preferred_height (path_bar->priv->down_slider_button, &child_min, &child_nat); + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); } static void