`g_dbus_proxy_call_sync` will return NULL and set the recoverable
`error` in case of failure.
We didn't catch this previously so reading the variant from the return
value caused a CRITICAL because a user didn't have the `week-start-day`
setting (introduced in 50.alpha) and the returned `GVariant` was NULL.
Now, we check whether en error is set after calling
`g_dbus_proxy_call_sync` and propagate it to the calling method so it
can gracefully handle it.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/862>
The `gcal_agenda_view_first_weekday_changed` uses the same
`gtk_list_view_scroll_to` method that expects the scroll position to be
smaller than the number of items in the list model.
When the list model contains no items, the method reports a critical
which crashes the Calendar whith `fatal-criticals` enabled.
This is the same fix that Georges made in the
`gcal_agenda_view_set_date` method. We now check the number of items
before trying to scroll the list view to position zero.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/861>
It's possible to change the density of the week view, but only through
pinch-zooming or Ctrl+scroll wheel. This means it can't be done with
only the keyboard, and since neither of these methods are documented,
it's not discoverable either.
This adds shortcuts for zooming the view in and out, and documents them
in the shortcuts dialog to make them discoverable.
Helps #1556
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/859>
`gtk_list_view_scroll_to()` is documented to require that `pos` is
smaller than the number of items in the model. We were not checking
if the model was empty before calling this function, which could
lead to criticals.
Check if the listview model has any items before scrolling it.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/860>
Currently, `gcal_date_time_get_start_of_week()` seems to be
the only user of this macro function. In the next commit, the
month view will use it to traverse weeks while maintaining
the weekday.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/839>
At the moment `gcal_date_chooser_set_date()` is automatically setting
the day to 1, which is undesirable behavior for a method that is
designed to "just" set the date. By connecting to
`GcalMultiChoice::explicitly-changed`, we can simply have the day
set to 1 to accompanying callbacks.
Currently, `multi_choice_changed()` is invoked 50 times at startup.
By using `GcalMultiChoice::explicitly-changed`, `multi_choice_changed()`
is only invoked 10 times. This is still more than ideal, but it's
a significant drop.
Fixes: https://gitlab.gnome.org/GNOME/gnome-calendar/-/work_items/1639
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/837>
We currently rely on connecting the `notify::value` signal,
which is emitted every time the value is changed explicitly or
implicitly. This can be problematic when, for example, the user
scrolls in the month view, which changes the value of each
GcalDateChooser widget, and each minor difference will re-emit
the signal until it's over. The `GcalMultiChoice::user-changed`
signal will only emit when the user presses the
previous/next buttons.
The next commit will port GcalDateChooser
to `GcalMultiChoice::user-changed`.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/837>
Change the 'get_first_weekday' function to number the weekdays
Monday(1)-Sunday(7) like ISO does. Change the function name to reflect
that. Add tests for different locales, although the tests depend on
system-installed locales.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/822>
Use the gcal-utils to find the actual day in case the desktop setting
for start of week is set to 'default'. After this commit, all usages of
that function have to be changed to use the GcalContext instead.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/822>
Start the enum from Monday-Sunday (1-7). Adapt code that references the
`is_workday()` utility method, which in turn uses the GcalWeekDay enum
to combine pairs of days by bitwise or-ing.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/822>
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>
GcalEventWidget was adjusted to handle NULL events so it could
more easily be used in GtkListView & family, however, what was
left out of thie adjustment were the functions related to the
orientation of the event.
Protect these functions by only running them when an event widget
is around.
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>