Since we refactored all events widgets and date headers to be
constructed by GtkListView directly, we are able to use
`gtk_list_view_scroll_to` to jump to the top of the list when opening
the agenda view, and changing date, instead of needing a complicated
timer and GSource callback
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/809>
Similar to the previous commit, we now create the date header label
using the model provided directly from `ListView:header-factory`, by
querying the date of the day the item is in the section of.
This requires copying the auxiliary method `new_date_header_string ()`
from `gcal-agenda-view-day-item.c` to `gcal-agenda-view.c` for
generating the appropriate using facing string for the header
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/809>
Instead of having the `GtkListView` create a row for each day containing
their own internal `GtkListBox` to store the event widgets, move the
creation of event widgets to the `GtkListView`'s item factory.
The motivation for this change is having internal listbox's inside a
`GtkListView` is problematic for keyboard navigation, because the user
can either:
- The event widgets in the internal listbox's can not be activated by
pressing Space/Enter on a focused event widget if the listbox row's are set to be focusable.
- If the internal listbox's rows are set to be unfocusable, the user is
not able to navigate the event widgets using the arrow keys, Page
Up/Down or Home/End.
To use `GtkListView:factory` to generate the event widgets, we first
wrap the filtered day model inside the list view around a
`GtkFlattenListModel` to concatenate all the containing
`GcalAgendaViewItem` (which contain a given event and the date it occurs
on) in the day models together. This gives us a model of all events that
can be turned into event widgets, and a model of day sections to create
headers for each day in the next commit.
This approach was taken because we do not get the activated row widget,
unlike with the previously used `GtkListBox` where the row widget is
passed as an argument in `::row-activated`, and there is no feasible
other way to obtain the correct event widget from a `GtkListView`.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/809>
Required some small changes to `gcal-agenda-day-row.c` to keep the
application working - `create_day_row_func` was tweaked to query the
given item for the event, instead of assuming the event is the item
itself. This will be removed (alongside the rest of GcalAgendaDayRow) in
a later commit
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/809>
GcalAgendaViewItem is an auxiliary object that will be used instead of
the raw events by GcalAgendaViewDay in a later commit to construct the
event widgets inside the main ListView of the agenda view as opposed to
a creating them inside of a `GtkListBox` inside each row of the
ListView.
Holding a reference to the event widget will be necessary in later
commits, so when a ListView row is activated, we can query its model of
GcalAgendaViewItem's with the given activated position, and pass the
correct item's event widget to `gcal_view_event_activated ()`
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/809>
This fixes an issue where pressing Shift + Up/Down while focused on the
overflow button will result in a bail out when asserting the focused
widget has a month cell ancestor:
```
GcalMonthView:ERROR:../src/gui/views/gcal-month-view.c:1002:on_key_controller_key_pressed_cb: assertion failed: (GCAL_IS_MONTH_CELL (month_cell))
Bail out! GcalMonthView:ERROR:../src/gui/views/gcal-month-view.c:1002:on_key_controller_key_pressed_cb: assertion failed: (GCAL_IS_MONTH_CELL (month_cell))
```
When navigating between month cells with a keyboard, focus is set
on respective month cells, so checking whether the ancestor
is a month cell or not is not only unnecessary, it also causes
bugs like the assertion above.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/720>