From 523609f2c01c8cdf088608f1a99582b04eedecf0 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sun, 29 Oct 2017 19:05:42 -0200 Subject: [PATCH] month-view: always update month cells in idle This way, we can schedule the multiple resizing queueing operations to after the size-allocate phase is over. --- src/views/gcal-month-view.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c index 4840af75..e2a013ae 100644 --- a/src/views/gcal-month-view.c +++ b/src/views/gcal-month-view.c @@ -131,6 +131,8 @@ struct _GcalMonthView /* Storage for the accumulated scrolling */ gdouble scroll_value; + guint update_grid_id; + /* property */ icaltimetype *date; GcalManager *manager; @@ -471,8 +473,8 @@ setup_month_grid (GcalMonthView *self, } } -static void -update_month_cells (GcalMonthView *self) +static gboolean +update_month_cells_in_idle_cb (GcalMonthView *self) { g_autoptr (GDateTime) dt; guint row, col; @@ -550,6 +552,19 @@ update_month_cells (GcalMonthView *self) gtk_widget_queue_draw (GTK_WIDGET (cell)); } } + + self->update_grid_id = 0; + + return G_SOURCE_REMOVE; +} + +static void +update_month_cells (GcalMonthView *self) +{ + if (self->update_grid_id > 0) + g_source_remove (self->update_grid_id); + + self->update_grid_id = g_idle_add ((GSourceFunc) update_month_cells_in_idle_cb, self); } static void @@ -1300,6 +1315,12 @@ gcal_month_view_finalize (GObject *object) g_clear_object (&self->manager); + if (self->update_grid_id > 0) + { + g_source_remove (self->update_grid_id); + self->update_grid_id = 0; + } + /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (gcal_month_view_parent_class)->finalize (object); }