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>
The new menu allows opening either the new-local-calendar or the
new-online-calendar page. As of this commit both pages still show
the same content, this will be fixed in the following commits.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/850>
This page will be replaced by the two pages created in the previous
commits, new-local-calendar and new-online-calendar.
To keep the project compiling the button to add a new calendar now
temporarily points at new-local-calendar. The button will be replaced
by a menu exposing both new pages in one of the following commits.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/850>
If the user has 12h time and sets a properly formatted but invalid time,
Calendar would crash because `date_time` would be `NULL`. This would
specifically happen if the time was set over 23:59 AM or 11:59 PM (ex:
19:00 PM).
By breaking if `date_time` is `NULL`, the crash can be avoided.
Closes#1602
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/848>
Using GtkToggleButton in this case is not only overkill for our
intended use case, it is also a hinderance, as the states and focus
of the widget are handled by the widget itself, which can lead to
unpredictable and undesired behavior.
Using AdwBin solves this problem by allowing us to set the styles
and states from the parent, provided that the CSS name is changed
to "button". Switching to AdwBin also allows us to not override the
`focus()`, `grab_focus()`, and `get_platform_state()` virtual methods.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/841>
This is a prerequisite for removing the strong dependence on the
child GtkToggleButton widget, removing the platform state override,
and adding binding actions in later commits.
Inheriting AdwBin was attempted but it didn't work, as AdwBin
presumably messes with focusability and activation, making
it insufficient for this use case.
`hexpand=true` needs to be explicitly set.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/841>
We no longer use this property. Removing it will then allow us to
directly set the label without having to use GtkStack, but this
will be done in a later commit.
This also sets all transitions to "none".
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/840>