Skip to content

Commit 3c66fd2

Browse files
authored
CalendarChooser: iterate without get_children (#888)
1 parent 86cdef4 commit 3c66fd2

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/Widgets/CalendarChooser.vala

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Box {
105105
current_source = ((CalendarRow) (row.get_child ())).source;
106106

107107
// Clear selected property
108-
foreach (unowned Gtk.Widget deselect_row in list_box.get_children ()) {
109-
var calrow = ((Gtk.ListBoxRow) deselect_row).get_child ();
110-
((CalendarRow) calrow).selected = false;
108+
for (int i = 0; list_box.get_row_at_index (i) != null; i++) {
109+
var calrow = (CalendarRow) list_box.get_row_at_index (i).get_child ();
110+
calrow.selected = false;
111111
}
112112

113113
// Select new row
@@ -116,9 +116,11 @@ public class Maya.View.Widgets.CalendarChooser : Gtk.Box {
116116
});
117117

118118
search_entry.activate.connect (() => {
119-
foreach (unowned Gtk.Widget child in list_box.get_children ()) {
120-
if (child.get_child_visible ()) {
121-
((Gtk.ListBoxRow) child).activate ();
119+
for (int i = 0; list_box.get_row_at_index (i) != null; i++) {
120+
var row = list_box.get_row_at_index (i);
121+
if (row.get_child_visible ()) {
122+
row.activate ();
123+
return;
122124
}
123125
}
124126
});

0 commit comments

Comments
 (0)