Closed danirabbit closed 8 months ago
@jeremypw ah I didn't realize this list didn't reflect the same number of items in the list. We can use observe children
in GTK 4, but docs say it's expensive. So I'm avoiding the list here unless we need it
@danirabbit You could try:
int index = 0;
while (list.get_row_at_index (index) != null) { index++; }
unowned var first_child = (DisplayRow) list.get_row_at_index (0);
unowned var last_child = first_child;
if (index > 1) {
last_child = (DisplayRow) list.get_row_at_index (index - 1);
}
first_child.up_button.sensitive = false;
last_child.down_button.sensitive = false;
@jeremypw ah yeah you're smart. It's probably plenty cheap enough to just iterate every time for a list that's probably pretty short
Yes. Tbh observe_children ()
is probably not that expensive for short lists. But we can go with this for now.
Can't use
get_children
in GTK4, so useget_row_at_index
where it makes sense. Useremove
instead ofdestroy
to avoid an infinite loop in GTK 4 where widgets are destroyed but not removed