GNOME Bugzilla – Bug 744721
RFE: Automatically add intermediate viewport when adding non-scrollable widget to a scrolled window
Last modified: 2018-03-26 15:45:39 UTC
It is currently impossible, in glade, to add a ListBox to a ScrolledWindow without a Viewport in the middle. The resulting listbox is not able to scroll when using keyboard navigation. It is possible to add a ListBox directly to a ScrolledWindow, and in that case scrolling by selecting off-screen widgets via the keyboard works fine. The problem is only that glade does not know this is possible. Please make glade know that this is possible.
But the end result is the same - if you add the listbox directly to the scrolledwindow, the scrolledwindow helpfully inserts a viewport itself. So, what is different ?
Created attachment 297130 [details] ListBox in a ScrolledWindow without an explicit Viewport This ListBox, where the ListBox is added directly to a ScrolledWindow, works fine.
Created attachment 297131 [details] ListBox in a ScrolledWindow with an explicit Viewport This version, where the ListBox is added to an intermediate Viewport, and which is what glade requires me to do, does not work.
Looking at gtk_scrolled_window_add, the relevant difference is that it sets up the focus adjustments on the viewport: scrollable_child = gtk_viewport_new (hadj, vadj); gtk_container_set_focus_hadjustment (GTK_CONTAINER (scrollable_child), gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (scrolled_window))); gtk_container_set_focus_vadjustment (GTK_CONTAINER (scrollable_child), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window))); glade should do that too. It should also allow you to add a listbox directly to a scrolled window, probably.
Updating the bug title to reflect this. As a side note, the reason we dont allow adding non-scrollables to scrolled windows is because of the intermediate viewport that scrolled-window sneaks into the hierarchy - Glade cannot function in a case where gtk_widget_get_parent() does not returrn the GtkContainer which the said widget was added to, because we rely on consistency in the widget hierarchy. That said, automatically adding an intermediate viewport with some added adjustments should be possible, however Glade would *also* have to add the adjustments to the project as well and set them both as the focus adjustments of the viewport, and the adjustments of the scrolled window. As the scrolled window itself normally configures those adjustments, I'm not 100% sure that that will work out well.
It might be possible to work around this is I were able to set the focus adjustments on the listbox (or other unscrollable child) from glade, but I can't do that either.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glade/issues/197.