[gtk+] path bar: Stop mishandling slider buttons



commit 8a3c25ca66e7c2a4e1575fdf10ef0bb1cf66f846
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 13 23:05:54 2016 -0400

    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 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 416786c..83396a0 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]