[gnome-calendar] month-view: calculate popover events on a per-event basis
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] month-view: calculate popover events on a per-event basis
- Date: Wed, 28 Sep 2016 00:10:20 +0000 (UTC)
commit 96626352d389c941e5d5ae4b5f0c775fa6ad3a70
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Sep 27 21:08:09 2016 -0300
month-view: calculate popover events on a per-event basis
Since we need to special-case the datetimes to deal with UTC
all day events, using a general local GTimeZone would cause
the cloned all-day events to show wrongly inside the popover.
Fix that by calculating each event's start and end dates according
to the all day events.
https://bugzilla.gnome.org/show_bug.cgi?id=771655
src/gcal-month-view.c | 49 +++++++++++++++++++++++++++----------------------
1 files changed, 27 insertions(+), 22 deletions(-)
---
diff --git a/src/gcal-month-view.c b/src/gcal-month-view.c
index 166b9f1..6f90bec 100644
--- a/src/gcal-month-view.c
+++ b/src/gcal-month-view.c
@@ -515,8 +515,6 @@ rebuild_popover_for_day (GcalMonthView *view,
PangoFontDescription *ofont_desc;
gint font_height, padding_bottom;
- GTimeZone *tz;
-
priv = gcal_month_view_get_instance_private (view);
ppriv = GCAL_SUBSCRIBER_VIEW (view)->priv;
@@ -528,26 +526,34 @@ rebuild_popover_for_day (GcalMonthView *view,
gtk_container_foreach (GTK_CONTAINER (priv->events_list_box), (GtkCallback) gtk_widget_destroy, NULL);
l = g_hash_table_lookup (ppriv->overflow_cells, GINT_TO_POINTER (priv->pressed_overflow_indicator));
- tz = g_time_zone_new_local ();
/* Setup the start & end dates of the events as the begin & end of day */
- if (l != NULL)
+ if (l)
{
- GDateTime *current_date;
- GDateTime *dt_start;
- GDateTime *dt_end;
- current_date = icaltime_to_datetime (priv->date);
- dt_start = g_date_time_new (tz,
- g_date_time_get_year (current_date),
- g_date_time_get_month (current_date),
- day,
- 0, 0, 0);
-
- dt_end = g_date_time_add_days (dt_start, 1);
-
for (; l != NULL; l = g_list_next (l))
{
GtkWidget *cloned_event;
+ GDateTime *current_date;
+ GDateTime *dt_start;
+ GDateTime *dt_end;
+ GcalEvent *event;
+ GTimeZone *tz;
+
+ event = gcal_event_widget_get_event (l->data);
+
+ if (gcal_event_get_all_day (event))
+ tz = g_time_zone_new_utc ();
+ else
+ tz = g_time_zone_new_local ();
+
+ current_date = icaltime_to_datetime (priv->date);
+ dt_start = g_date_time_new (tz,
+ g_date_time_get_year (current_date),
+ g_date_time_get_month (current_date),
+ day,
+ 0, 0, 0);
+
+ dt_end = g_date_time_add_days (dt_start, 1);
cloned_event = gcal_event_widget_clone (l->data);
gcal_event_widget_set_date_start (GCAL_EVENT_WIDGET (cloned_event), dt_start);
@@ -555,15 +561,14 @@ rebuild_popover_for_day (GcalMonthView *view,
gtk_container_add (GTK_CONTAINER (priv->events_list_box), cloned_event);
_gcal_subscriber_view_setup_child (GCAL_SUBSCRIBER_VIEW (view), cloned_event);
- }
- g_clear_pointer (¤t_date, g_date_time_unref);
- g_clear_pointer (&dt_start, g_date_time_unref);
- g_clear_pointer (&dt_end, g_date_time_unref);
+ g_clear_pointer (¤t_date, g_date_time_unref);
+ g_clear_pointer (&dt_start, g_date_time_unref);
+ g_clear_pointer (&dt_end, g_date_time_unref);
+ g_clear_pointer (&tz, g_time_zone_unref);
+ }
}
- g_clear_pointer (&tz, g_time_zone_unref);
-
/* placement calculation */
start_grid_y = get_start_grid_y (GTK_WIDGET (view));
shown_rows = ceil ((priv->days_delay + icaltime_days_in_month (priv->date->month, priv->date->year)) /
7.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]