window: Delegate changing dates to GcalView
The view knows its time range, and knows what the next or previous dates should be. So instead of calculating the next date manually, ask the views for that.
This commit is contained in:
@@ -248,6 +248,25 @@ gcal_week_view_update_subscription (GcalView *view)
|
||||
range_end);
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
gcal_week_view_get_next_date (GcalView *view)
|
||||
{
|
||||
GcalWeekView *self = GCAL_WEEK_VIEW (view);
|
||||
|
||||
g_assert (self->date != NULL);
|
||||
return g_date_time_add_weeks (self->date, 1);
|
||||
}
|
||||
|
||||
|
||||
static GDateTime*
|
||||
gcal_week_view_get_previous_date (GcalView *view)
|
||||
{
|
||||
GcalWeekView *self = GCAL_WEEK_VIEW (view);
|
||||
|
||||
g_assert (self->date != NULL);
|
||||
return g_date_time_add_weeks (self->date, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_view_interface_init (GcalViewInterface *iface)
|
||||
{
|
||||
@@ -256,6 +275,8 @@ gcal_view_interface_init (GcalViewInterface *iface)
|
||||
iface->get_children_by_uuid = gcal_week_view_get_children_by_uuid;
|
||||
iface->clear_marks = gcal_week_view_clear_marks;
|
||||
iface->update_subscription = gcal_week_view_update_subscription;
|
||||
iface->get_next_date = gcal_week_view_get_next_date;
|
||||
iface->get_previous_date = gcal_week_view_get_previous_date;
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user