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:
@@ -1220,6 +1220,25 @@ gcal_month_view_update_subscription (GcalView *view)
|
||||
range_end);
|
||||
}
|
||||
|
||||
static GDateTime*
|
||||
gcal_month_view_get_next_date (GcalView *view)
|
||||
{
|
||||
GcalMonthView *self = GCAL_MONTH_VIEW (view);
|
||||
|
||||
g_assert (self->date != NULL);
|
||||
return g_date_time_add_months (self->date, 1);
|
||||
}
|
||||
|
||||
|
||||
static GDateTime*
|
||||
gcal_month_view_get_previous_date (GcalView *view)
|
||||
{
|
||||
GcalMonthView *self = GCAL_MONTH_VIEW (view);
|
||||
|
||||
g_assert (self->date != NULL);
|
||||
return g_date_time_add_months (self->date, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_view_interface_init (GcalViewInterface *iface)
|
||||
{
|
||||
@@ -1228,6 +1247,8 @@ gcal_view_interface_init (GcalViewInterface *iface)
|
||||
iface->clear_marks = gcal_month_view_clear_marks;
|
||||
iface->get_children_by_uuid = gcal_month_view_get_children_by_uuid;
|
||||
iface->update_subscription = gcal_month_view_update_subscription;
|
||||
iface->get_next_date = gcal_month_view_get_next_date;
|
||||
iface->get_previous_date = gcal_month_view_get_previous_date;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user