GNOME Bugzilla – Bug 129318
Add "visible_rows" property to GtkTreeView.
Last modified: 2018-02-10 03:24:13 UTC
If you embed a GtkTreeView into a GtkScrolledWindow the requested height of the scrolled window is only computed by the requested sizes of the scrollbars. It should be possible to define the count of visible rows. There should be a "visible_rows" property (the number of visible rows in a tree view which is embedded in a scrolled window) for the GtkTreeView widget to solve this problem.
Created attachment 22437 [details] [review] This patch implements the visible_rows property.
kris and jrb don't like a visible rows solution. I agree that there are problems to find a solution, which doesn't fail at small/large displays and at small/large fonts. So i started to look at other UI toolkits: - Fox: numVisible - Java (AWT): Use native toolkit - Java (Swing): visibleRowCount - OSX: ? - Motif: visibleItemCount - Qt: 10 rows visible and between 40 and 200 pixels - tk: height (= visible rows) - Windows: ? As you can see they don't have other (working) solutions. It would be really nice if someone have an idea how to solve this problem (or can look at the solutions of OSX, windows or any other UI toolkit).
I'm going to put this in the 'future' milestone. We should have a minimum size requisition and a preferred size requisition.
I implemented a similar functionality for kiwi; def set_visible_rows(self, rows): treeview = self._treeview if treeview.get_headers_visible(): treeview_column = treeview.get_column(0) button = self._get_column_button(treeview_column) treeview.realize() alloc = button.get_allocation() header_h = alloc.height else: header_h = 0 column = treeview.get_columns()[0] h = column.cell_get_size()[-1] focus_padding = treeview.style_get_property('focus-line-width') * 2 treeview.set_size_request(-1, header_h + (rows * (h + focus_padding))) Which seems to do the right thing (as in pixel perfect height), I have only tested it with the default ubuntu theme though, so it might be some variations with other themes.
*** Bug 654236 has been marked as a duplicate of this bug. ***
We're moving to gitlab! As part of this move, we are closing bugs that haven't seen activity in more than 5 years. If this issue is still imporant to you and still relevant with GTK+ 3.22 or master, please consider creating a gitlab issue for it.