view: rework active-date
The current implementation is deficient in many ways, the worst one being the it relying on GObject semi-synchronous property emission. This issue was exposed by the Week view code, where the active date was updated, but delayed to reach the Week header and some events were being added ~before~ the active date changed. With this work, I was also able to figure out a bunch of code that relied on this (i.e. luck) to work.
This commit is contained in:
+41
-16
@@ -162,6 +162,35 @@ schedule_position_scroll (GcalWeekView *self)
|
||||
self);
|
||||
}
|
||||
|
||||
/* GcalView implementation */
|
||||
static icaltimetype*
|
||||
gcal_week_view_get_date (GcalView *view)
|
||||
{
|
||||
GcalWeekView *self = GCAL_WEEK_VIEW (view);
|
||||
|
||||
return self->date;
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_week_view_set_date (GcalView *view,
|
||||
icaltimetype *date)
|
||||
{
|
||||
GcalWeekView *self = GCAL_WEEK_VIEW (view);
|
||||
|
||||
GCAL_ENTRY;
|
||||
|
||||
g_clear_pointer (&self->date, g_free);
|
||||
self->date = gcal_dup_icaltime (date);
|
||||
|
||||
/* Propagate the new date */
|
||||
gcal_week_grid_set_date (GCAL_WEEK_GRID (self->week_grid), date);
|
||||
gcal_week_header_set_date (GCAL_WEEK_HEADER (self->header), date);
|
||||
|
||||
schedule_position_scroll (self);
|
||||
|
||||
GCAL_EXIT;
|
||||
}
|
||||
|
||||
static GList*
|
||||
gcal_week_view_get_children_by_uuid (GcalView *view,
|
||||
const gchar *uuid)
|
||||
@@ -185,6 +214,15 @@ gcal_week_view_clear_marks (GcalView *view)
|
||||
gcal_week_grid_clear_marks (GCAL_WEEK_GRID (self->week_grid));
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_view_interface_init (GcalViewInterface *iface)
|
||||
{
|
||||
iface->get_date = gcal_week_view_get_date;
|
||||
iface->set_date = gcal_week_view_set_date;
|
||||
iface->get_children_by_uuid = gcal_week_view_get_children_by_uuid;
|
||||
iface->clear_marks = gcal_week_view_clear_marks;
|
||||
}
|
||||
|
||||
static void
|
||||
update_hours_sidebar_size (GcalWeekView *self)
|
||||
{
|
||||
@@ -239,6 +277,8 @@ update_hours_sidebar_size (GcalWeekView *self)
|
||||
g_object_unref (layout);
|
||||
}
|
||||
|
||||
|
||||
/* ECalDataModelSubscriber implementation */
|
||||
static void
|
||||
gcal_week_view_component_added (ECalDataModelSubscriber *subscriber,
|
||||
ECalClient *client,
|
||||
@@ -429,13 +469,6 @@ gcal_week_view_draw_hours (GcalWeekView *self,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface)
|
||||
{
|
||||
@@ -465,18 +498,10 @@ gcal_week_view_set_property (GObject *object,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalWeekView *self;
|
||||
|
||||
self = GCAL_WEEK_VIEW (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_DATE:
|
||||
g_clear_pointer (&self->date, g_free);
|
||||
self->date = g_value_dup_boxed (value);
|
||||
|
||||
schedule_position_scroll (self);
|
||||
|
||||
gcal_view_set_date (GCAL_VIEW (object), g_value_get_boxed (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user