view: Let views handle subscription range

Instead of GcalWindow handling the ranges themselves,
delegate this responsibility to the views.
This commit is contained in:
Georges Basile Stavracas Neto
2019-05-09 17:42:58 -03:00
parent 72b958f94c
commit da31180cba
6 changed files with 103 additions and 76 deletions
+23
View File
@@ -1587,6 +1587,28 @@ gcal_year_view_get_children_by_uuid (GcalView *view,
return result;
}
static void
gcal_year_view_update_subscription (GcalView *view)
{
g_autoptr (GDateTime) date_start = NULL;
g_autoptr (GDateTime) date_end = NULL;
GcalYearView *self;
time_t range_start;
time_t range_end;
self = GCAL_YEAR_VIEW (view);
date_start = g_date_time_new_local (g_date_time_get_year (self->date), 1, 1, 0, 0, 0);
range_start = g_date_time_to_unix (date_start);
date_end = g_date_time_add_years (date_start, 1);
range_end = g_date_time_to_unix (date_end);
gcal_manager_set_subscriber (gcal_context_get_manager (self->context),
E_CAL_DATA_MODEL_SUBSCRIBER (self),
range_start,
range_end);
}
static void
gcal_view_interface_init (GcalViewInterface *iface)
{
@@ -1594,6 +1616,7 @@ gcal_view_interface_init (GcalViewInterface *iface)
iface->get_date = gcal_year_view_get_date;
iface->set_date = gcal_year_view_set_date;
iface->get_children_by_uuid = gcal_year_view_get_children_by_uuid;
iface->update_subscription = gcal_year_view_update_subscription;
}
static void