[gtk/wip/otte/for-master: 28/30] boxlayout: Don't listen to comments




commit afe94e303a797381daa5e5175de4c3c3d3b55104
Author: Benjamin Otte <otte redhat com>
Date:   Mon Nov 8 17:49:15 2021 +0100

    boxlayout: Don't listen to comments
    
    ... when they are wrong.
    
    Instead, remove them.
    
    Or in other words: GTK4 does not have a fill child property anymore, so
    we don't need to run the measuring loop above to determine the size.

 gtk/gtkboxlayout.c | 76 ++++++++++++++++++++++++++----------------------------
 1 file changed, 36 insertions(+), 40 deletions(-)
---
diff --git a/gtk/gtkboxlayout.c b/gtk/gtkboxlayout.c
index 20b462eb40..d942167a3d 100644
--- a/gtk/gtkboxlayout.c
+++ b/gtk/gtkboxlayout.c
@@ -322,53 +322,49 @@ gtk_box_layout_compute_opposite_size_for_size (GtkBoxLayout *self,
   sizes = g_newa (GtkRequestedSize, nvis_children);
   extra_space = MAX (0, for_size - (nvis_children - 1) * spacing);
 
-  /* Retrieve desired size for visible children */
-  for (i = 0, child = _gtk_widget_get_first_child (widget);
-       child != NULL;
-       child = _gtk_widget_get_next_sibling (child))
-    {
-      int min_opposite, nat_for_min;
-
-      if (!gtk_widget_should_layout (child))
-        continue;
-
-      gtk_widget_measure (child,
-                          self->orientation,
-                          -1,
-                          &sizes[i].minimum_size, &sizes[i].natural_size,
-                          NULL, NULL);
-      /* Don't just use the natural size as the max size,
-       * the natural size is the ideal size, not necessarily
-       * the maximum size.
-       * Also check the nat size for opposite min size.
-       */
-      gtk_widget_measure (child,
-                          OPPOSITE_ORIENTATION (self->orientation),
-                          -1,
-                          &min_opposite, NULL,
-                          NULL, NULL);
-      gtk_widget_measure (child,
-                          self->orientation,
-                          min_opposite,
-                          NULL, &nat_for_min,
-                          NULL, NULL);
-      sizes[i].natural_size = MAX (sizes[i].natural_size, nat_for_min);
-
-      children_minimum_size += sizes[i].minimum_size;
-      i += 1;
-    }
-
   if (self->homogeneous)
     {
-      /* We still need to run the above loop to populate the minimum sizes for
-       * children that aren't going to fill.
-       */
-
       size_given_to_child = extra_space / nvis_children;
       n_extra_widgets = extra_space % nvis_children;
     }
   else
     {
+      /* Retrieve desired size for visible children */
+      for (i = 0, child = _gtk_widget_get_first_child (widget);
+           child != NULL;
+           child = _gtk_widget_get_next_sibling (child))
+        {
+          int min_opposite, nat_for_min;
+
+          if (!gtk_widget_should_layout (child))
+            continue;
+
+          gtk_widget_measure (child,
+                              self->orientation,
+                              -1,
+                              &sizes[i].minimum_size, &sizes[i].natural_size,
+                              NULL, NULL);
+          /* Don't just use the natural size as the max size,
+           * the natural size is the ideal size, not necessarily
+           * the maximum size.
+           * Also check the nat size for opposite min size.
+           */
+          gtk_widget_measure (child,
+                              OPPOSITE_ORIENTATION (self->orientation),
+                              -1,
+                              &min_opposite, NULL,
+                              NULL, NULL);
+          gtk_widget_measure (child,
+                              self->orientation,
+                              min_opposite,
+                              NULL, &nat_for_min,
+                              NULL, NULL);
+          sizes[i].natural_size = MAX (sizes[i].natural_size, nat_for_min);
+
+          children_minimum_size += sizes[i].minimum_size;
+          i += 1;
+        }
+
       /* Bring children up to size first */
       extra_space -= children_minimum_size;
       extra_space = MAX (0, extra_space);


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