From 65bc0d1269c899bed659307e48cb6dedcd915e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Thu, 4 Jul 2013 09:04:46 -0400 Subject: [PATCH] gcal-month-view: fixed days number drawing Updated GcalMonthViewPrivate:days_delay on every day update --- src/gcal-month-view.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c index b6e91691..80e346f5 100644 --- a/src/gcal-month-view.c +++ b/src/gcal-month-view.c @@ -229,11 +229,21 @@ gcal_month_view_set_property (GObject *object, switch (property_id) { case PROP_DATE: - if (priv->date != NULL) - g_free (priv->date); + { + icaltimetype *first_of_month; - priv->date = g_value_dup_boxed (value); - break; + if (priv->date != NULL) + g_free (priv->date); + + priv->date = g_value_dup_boxed (value); + + first_of_month = gcal_dup_icaltime (priv->date); + first_of_month->day = 1; + priv->days_delay = icaltime_day_of_week (*first_of_month) - 1; + g_free (first_of_month); + + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -520,6 +530,7 @@ gcal_month_view_draw (GtkWidget *widget, priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (widget)); + /* fonts and colors selection */ context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); @@ -557,6 +568,7 @@ gcal_month_view_draw (GtkWidget *widget, gtk_style_context_restore (context); + /* calculations */ days = priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year); shown_rows = ceil (days / 7.0); february_gap = shown_rows == 4 ? 1 : 0;