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 352594 - Setting dimensions for just the viewport of GtkScrolledWindow
Setting dimensions for just the viewport of GtkScrolledWindow
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkScrolledWindow
2.8.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2006-08-23 21:05 UTC by gbz
Modified: 2013-02-11 06:42 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
Test case in python (1.44 KB, text/x-python)
2006-08-23 22:09 UTC, gbz
Details

Description gbz 2006-08-23 21:05:18 UTC
I think there's a shortcoming when putting a widget into a GtkScrolledWindow where you do not want the latter to expand.
For example, I want to add a scrollable GtkTreeView into a GtkFrame. But since the frame is likely to be wider than the width-requisition of the treeview, it would mean that the treeview expands horizontally. But I dont want it to be any wider than its requirement.

GtkFrame
- GtkHBox
-- GtkScrolledWindow
--- GtkTreeView

So I add first a GtkHBox, and then pack the scrolledwindow with expand=false.
However, that makes the GtkScrolledWindow extremely narrow, leaving lots of unused space in the frame. I managed to solve this by listening to the "size-request" signal of the treeview, and then:

void size_request_callback (GtkWidget *widget, GtkRequisition *requisition, gpointer user_data)
{
  gtk_widget_set_size_request (widget, requisition->width, -1)
}

Anyway, this leaves the GtkScrolledWindow with a small forced horizontal scrolling, because though it gets equally wide to the child, there's the vertical scrollbar that eats from that width. It seems very awkward to let the GtkScrolledWindow be just wide enough to show its child, but still add the vertical scrollbar to the width. Sure it's possible to get the vertical scrollbar and get its width, but that is both awkward and unreliable. For example, there's also the "scrollbar-spacing" that affects, and it may change at run-time.

So there should be a way to set only the width/height of the viewport area. And then the overall width/height is automatically computed so that min requirement of scrollbars etc are added.
Alternatively, there could be a read-only property that gives the min requirements of the GtkScrolledWindow when it has no child. Which could then be used when calculating the overall width/height: width = viewport_width + scrollbars_etc_min_width.
Comment 1 gbz 2006-08-23 22:09:16 UTC
Created attachment 71495 [details]
Test case in python
Comment 2 gbz 2006-09-16 11:07:56 UTC
All that is needed is that GtkTreeView (and other widgets with native scrolling) allows a way to reach its GtkViewport, then you can set the width request for the viewport.
Comment 3 Matthias Clasen 2013-02-11 06:42:38 UTC
I think this was addressed with the min-content-size properties