[gnome-calendar] month-view: only send end_date if event is multiday



commit e85e55a3505577295ac0c338f90e250da08c0e50
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Fri Feb 26 21:12:25 2016 +0100

    month-view: only send end_date if event is multiday

 src/gcal-month-view.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index ba2b66e..1e66019 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -264,21 +264,28 @@ show_popover_for_position (GcalMonthView *view,
     {
       GDateTime *start_dt, *end_dt;
 
-      start_dt = g_date_time_new_utc (priv->date->year, priv->date->month, start_day, 0, 0, 0);
-      end_dt = g_date_time_new_utc (priv->date->year, priv->date->month, end_day + 1, 0, 0, 0);
+      start_dt = NULL;
+      end_dt = NULL;
 
       /* Swap dates if start > end */
       if (start_day > end_day)
         {
-          GDateTime *aux = start_dt;
-          start_dt = end_dt;
-          end_dt = aux;
+          gint aux;
+          aux = end_day;
+          end_day = start_day;
+          start_day = aux;
         }
 
+      start_dt = g_date_time_new_utc (priv->date->year, priv->date->month, start_day, 0, 0, 0);
+
+      /* Only setup an end date when days are different */
+      if (start_day != end_day)
+        end_dt = g_date_time_new_utc (priv->date->year, priv->date->month, end_day + 1, 0, 0, 0);
+
       g_signal_emit_by_name (GCAL_VIEW (widget), "create-event", start_dt, end_dt, x, y);
 
-      g_date_time_unref (start_dt);
-      g_date_time_unref (end_dt);
+      g_clear_pointer (&start_dt, g_date_time_unref);
+      g_clear_pointer (&end_dt, g_date_time_unref);
     }
 
   gtk_widget_queue_draw (widget);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]