[gtk+] scrolledwindow: Better size requisition for GTK_SCROLL_NATURAL children



commit 096bea3f0ea8e80fe4c9a2a1a860f32c8a94cc33
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue May 17 16:28:20 2016 +0200

    scrolledwindow: Better size requisition for GTK_SCROLL_NATURAL children
    
    GtkScrolledWindow leans towards using the minimum size of its child
    widget, unless the scrollbar policy is GTK_POLICY_NEVER. This is
    probably fine for most GtkScrollable implementations out there.
    Especially when using GTK_SCROLL_MINIMUM, which is the default for all
    implementations inside gtk+.
    
    However, this is not good for GTK_SCROLL_NATURAL children. eg.,
    VteTerminal's minimum size is 1x1 and natural size is the number of
    visible rows and columns requested by the user. We really want to use
    the natural size unless the user has resized the window to change that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766569

 gtk/gtkscrolledwindow.c |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index b6100d6..69eb4ad 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1711,6 +1711,8 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
   GtkScrolledWindowPrivate *priv = scrolled_window->priv;
   GtkBin *bin = GTK_BIN (scrolled_window);
+  GtkScrollablePolicy scrollable_hpolicy = GTK_SCROLL_MINIMUM;
+  GtkScrollablePolicy scrollable_vpolicy = GTK_SCROLL_MINIMUM;
   gint extra_width;
   gint extra_height;
   gint scrollbar_spacing;
@@ -1738,7 +1740,11 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
   child = gtk_bin_get_child (bin);
 
   if (GTK_IS_SCROLLABLE (child))
-    gtk_scrollable_get_border (GTK_SCROLLABLE (child), &border);
+    {
+      gtk_scrollable_get_border (GTK_SCROLLABLE (child), &border);
+      scrollable_hpolicy = gtk_scrollable_get_hscroll_policy (GTK_SCROLLABLE (child));
+      scrollable_vpolicy = gtk_scrollable_get_vscroll_policy (GTK_SCROLLABLE (child));
+    }
 
   if (child && gtk_widget_get_visible (child))
     {
@@ -1761,6 +1767,11 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
                  natural_req.width += priv->min_content_width;
                  extra_width = -1;
                }
+              else if (scrollable_hpolicy == GTK_SCROLL_NATURAL)
+                {
+                 minimum_req.width += min_child_size;
+                 natural_req.width += nat_child_size;
+                }
              else if (policy_may_be_visible (priv->vscrollbar_policy) && !priv->use_indicators)
                {
                  minimum_req.width += vscrollbar_requisition.width;
@@ -1787,6 +1798,11 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
                  natural_req.height += priv->min_content_height;
                  extra_height = -1;
                }
+              else if (scrollable_vpolicy == GTK_SCROLL_NATURAL)
+                {
+                 minimum_req.height += min_child_size;
+                 natural_req.height += nat_child_size;
+                }
              else if (policy_may_be_visible (priv->hscrollbar_policy) && !priv->use_indicators)
                {
                  minimum_req.height += hscrollbar_requisition.height;


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