[gnome-builder] column-layout: respect EggColumnLayout:max-columns in width request



commit ad36a11ec24e5de0a663530174d3ca6007e79064
Author: Christian Hergert <chergert redhat com>
Date:   Sat Sep 17 21:57:31 2016 -0700

    column-layout: respect EggColumnLayout:max-columns in width request
    
    When performing get_preferred_width(), we can take into account the max
    number of columns in the column layout which helps get a more correct
    natural size.
    
    This stuff is all sort of painful due to the use case, we really need to
    get a real solver eventually.

 contrib/egg/egg-column-layout.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/contrib/egg/egg-column-layout.c b/contrib/egg/egg-column-layout.c
index 91e0056..7a3ebd2 100644
--- a/contrib/egg/egg-column-layout.c
+++ b/contrib/egg/egg-column-layout.c
@@ -211,6 +211,7 @@ egg_column_layout_get_preferred_width (GtkWidget *widget,
   EggColumnLayout *self = (EggColumnLayout *)widget;
   EggColumnLayoutPrivate *priv = egg_column_layout_get_instance_private (self);
   gint border_width;
+  gint n_columns = 3;
 
   g_assert (EGG_IS_COLUMN_LAYOUT (self));
   g_assert (min_width != NULL);
@@ -218,7 +219,16 @@ egg_column_layout_get_preferred_width (GtkWidget *widget,
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (self));
 
-  *nat_width = (priv->column_width * 3) + (priv->column_spacing * 2) + (border_width * 2);
+  /*
+   * By default we try to natural size up to 3 columns. Otherwise, we
+   * use the max_columns. It would be nice if we could deal with this
+   * in a better way, but that is going to take a bunch more solving.
+   */
+
+  if (priv->max_columns > 0)
+    n_columns = priv->max_columns;
+
+  *nat_width = (priv->column_width * n_columns) + (priv->column_spacing * (n_columns - 1)) + (border_width * 
2);
   *min_width = priv->column_width + (border_width * 2);
 }
 


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