Skip to content

Commit c32bb20

Browse files
authored
Wrap ListView and GridView in ScrolledWindow (#120)
The demo did not work correctly: when creating more than 200 widgets and scrolling down, widgets are not dynamically created. Each `Gtk.ListView` or `Gtk.GridView` should be placed in `Gtk.ScrolledWindow` without intermediaries (Scrolling from `Adw.StatusPage` will not work)
1 parent 5bcbfb3 commit c32bb20

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

src/List View Widgets/main.blp

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,26 @@ Adw.StatusPage {
6767
child: Frame {
6868
valign: start;
6969

70-
ListView list_view {
71-
enable-rubberband: true;
72-
73-
factory: BuilderListItemFactory {
74-
template ListItem {
75-
child: Gtk.Box {
76-
Gtk.Label {
77-
label: bind template.item as <StringObject>.string;
78-
height-request: 50;
79-
margin-start: 12;
80-
margin-end: 12;
81-
}
82-
};
83-
}
84-
};
70+
ScrolledWindow {
71+
hscrollbar-policy: never;
72+
propagate-natural-height: true;
73+
74+
ListView list_view {
75+
enable-rubberband: true;
76+
77+
factory: BuilderListItemFactory {
78+
template ListItem {
79+
child: Gtk.Box {
80+
Gtk.Label {
81+
label: bind template.item as <StringObject>.string;
82+
height-request: 50;
83+
margin-start: 12;
84+
margin-end: 12;
85+
}
86+
};
87+
}
88+
};
89+
}
8590
}
8691
};
8792
}
@@ -93,11 +98,16 @@ Adw.StatusPage {
9398
child: Frame {
9499
valign: start;
95100

96-
GridView grid_view {
97-
orientation: vertical;
98-
max-columns: 4;
99-
min-columns: 4;
100-
enable-rubberband: true;
101+
ScrolledWindow {
102+
hscrollbar-policy: never;
103+
propagate-natural-height: true;
104+
105+
GridView grid_view {
106+
orientation: vertical;
107+
max-columns: 2;
108+
min-columns: 2;
109+
enable-rubberband: true;
110+
}
101111
}
102112
};
103113
}

0 commit comments

Comments
 (0)