From d8cc980a1d8bb33ea007ecef6663604c7b521d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erick=20P=C3=A9rez=20Castellanos?= Date: Sun, 5 Oct 2014 19:57:30 -0400 Subject: [PATCH] month-view: implement GcalView::wil_add_event vfunc --- src/gcal-month-view.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c index 79f9000f..f80e7857 100644 --- a/src/gcal-month-view.c +++ b/src/gcal-month-view.c @@ -1304,7 +1304,29 @@ static gboolean gcal_month_view_will_add_event (GcalView *view, GcalEventWidget *event) { - ; + GcalMonthViewPrivate *priv; + + icaltimetype *start_date; + gboolean is_in_range; + + const gchar* event_uuid; + + g_return_val_if_fail (GCAL_IS_MONTH_VIEW (view), FALSE); + priv = gcal_month_view_get_instance_private (GCAL_MONTH_VIEW (view)); + + if (priv->date == NULL) + return FALSE; + + start_date = gcal_event_widget_get_date (event); + is_in_range = (priv->date->month == start_date->month && + priv->date->year == start_date->year); + g_free (start_date); + + if (!is_in_range) + return FALSE; + + event_uuid = gcal_event_widget_peek_uuid (event); + return !(gcal_month_view_get_by_uuid (view, event_uuid) != NULL); } /* Public API */