After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 660654 - GtkScrolledWindow ignores natural width for child widget
GtkScrolledWindow ignores natural width for child widget
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-10-01 21:30 UTC by Timo Kluck
Modified: 2017-02-17 17:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A test case for this bug (950 bytes, text/plain)
2011-10-01 21:30 UTC, Timo Kluck
Details
Test case with propagate-natural-width/height set, fixing this (1.14 KB, text/plain)
2017-02-17 17:36 UTC, Daniel Boles
Details

Description Timo Kluck 2011-10-01 21:30:01 UTC
Created attachment 197984 [details]
A test case for this bug

GtkScrolledWindow ignores the natural width of its child widget, unless the scrollbar policy is GTK_POLICY_NEVER. I would expect that a GtkScrolledWindow's natural size is given by

child_natural_size + size_of_scrollbars

but instead, min_content_width seems to be used.

I've attached demonstration code. Compile with

    valac --pkg gtk+-3.0 scrolledwindowbugtest.vala 

It also includes a naive subclass that overrides get_preferred_width. When you use that subclass, it works as expected. This is evidence that the problem is in GtkScrolledWindow and not elsewhere.

This old bug looks similar, but is probably not relevant anymore since Gtk3 has entirely different layout management:
https://bugzilla.gnome.org/show_bug.cgi?id=352594
Comment 1 Daniel Boles 2017-02-17 17:36:31 UTC
Created attachment 346099 [details]
Test case with propagate-natural-width/height set, fixing this

This appears to be resolved, now that we have properties propagate-natural-(width|height) from 3.20 onwards.

See the attachment, which converts your code to C (this or a .ui file is preferable for test cases), just adds code to set those properties to TRUE, and seems to do what you wanted.