GTK3: GtkIconView scrolling issue

Hi,

I am having scrolling issues with GtkIconView in GNOME Activity Journal:

https://gitlab.gnome.org/crvi/gnome-activity-journal/-/commits/master

GNOME Activity Journal has 3 view modes. One of them is a ThumbView which uses GtkIconView to render thumbnails of events.

Please refer to the following 2 screenshots:

Smaller Thumbnails - No scrolling needed case:

Larger Thumbnails - Scrolling needed case:

There are 3 GtkIconView objects above - one for morning, afternoon and evening events.

The issue here is, GtkIconView doesn’t wrap around and use the vertical space in the second image ( morning and afternoon icon views ) , even when there is enough vertical space available for the thumbnails. When the vertical allocated space gets more and more ( much more than actually required ), at some point GtkIconView wraps around to render thumbnails in the second row.

When GtkScrolledWindow is added to each GtkIconView, the vertical space is properly utilized, as soon as enough vertical space is available. But, that’s not what we want here. The idea here is to add a single GtkScrolledWindow for all 3 GtkIconView objects, so they fully expand to their minimum required sizes, rather than having individual scrollbars for each GtkIconView.

Below is the rough python3 pseudo-code:

class ThumbViewContainer(Gtk.VBox):
    def __init__(self):
        self.scrolledwindow = Gtk.ScrolledWindow()
        self.view = ThumbView()
        self.scrolledwindow.add(self.view)

class ThumbView(Gtk.VBox):
    def __init__(self):
        for text in (morning, afternoon, evening):
            label = Gtk.Label()
            label.set_markup(text)
            self.views.append(ThumbIconView())
            self.labels.append(label)
            self.pack_start(label, False, False, 0)
            self.pack_start(self.views[-1], True, True, 0)

class ThumbIconView(Gtk.IconView):
    def __init__(self):
         self.show_thumbnails()

Full code at:

https://gitlab.gnome.org/crvi/gnome-activity-journal/-/blob/master/src/activity_widgets.py

Thanks!

1 Like

Sounds like you want FlowBox instead.

Or maybe you’ve ruled that out already?

1 Like

GtkIconView renders based on a model.

FlowBox from what I see, is plain widget flowing ?

Thanks!

It works either way, you can use it as a simple container or you can bind a model to it.

1 Like

Seems like https://gitlab.gnome.org/GNOME/gtk/-/issues/553

The issue got fixed after switching 'Gtk.VBox' to 'Gtk.Grid' with 'vertical' orientation.

Larger Thumbnails - Scrolling needed case ( fixed ):

Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.