aboutsummaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/service.c b/src/service.c
index c36e996..c46beeb 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1637,7 +1637,7 @@ on_upcoming_appointments_ready (GObject * source,
}
static void
-on_appointments_changed (IndicatorDatetimeService * self)
+update_appointment_lists (IndicatorDatetimeService * self)
{
IndicatorDatetimePlanner * planner;
GDateTime * calendar_date;
@@ -1652,22 +1652,23 @@ on_appointments_changed (IndicatorDatetimeService * self)
g_date_time_get_ymd (calendar_date, &y, &m, &d);
begin = g_date_time_new_local (y, m, 1, 0, 0, 0);
end = g_date_time_new_local (y, m, g_date_get_days_in_month(m,y), 23, 59, 0);
- indicator_datetime_planner_get_appointments (planner, begin, end,
- on_calendar_appointments_ready,
- self);
- g_date_time_unref (begin);
- g_date_time_unref (end);
+ if (begin && end)
+ indicator_datetime_planner_get_appointments (planner, begin, end,
+ on_calendar_appointments_ready,
+ self);
+ g_clear_pointer (&begin, g_date_time_unref);
+ g_clear_pointer (&end, g_date_time_unref);
/* get the upcoming appointments */
begin = g_date_time_ref (calendar_date);
end = g_date_time_add_months (begin, 1);
- indicator_datetime_planner_get_appointments (planner, begin, end,
- on_upcoming_appointments_ready,
- self);
- g_date_time_unref (begin);
- g_date_time_unref (end);
-
- g_date_time_unref (calendar_date);
+ if (begin && end)
+ indicator_datetime_planner_get_appointments (planner, begin, end,
+ on_upcoming_appointments_ready,
+ self);
+ g_clear_pointer (&begin, g_date_time_unref);
+ g_clear_pointer (&end, g_date_time_unref);
+ g_clear_pointer (&calendar_date, g_date_time_unref);
}
@@ -1907,7 +1908,7 @@ indicator_datetime_service_init (IndicatorDatetimeService * self)
p->planner = indicator_datetime_planner_eds_new ();
g_signal_connect_swapped (p->planner, "appointments-changed",
- G_CALLBACK(on_appointments_changed), self);
+ G_CALLBACK(update_appointment_lists), self);
/***
@@ -2041,8 +2042,5 @@ indicator_datetime_service_set_calendar_date (IndicatorDatetimeService * self,
/* sync the menuitems and action states */
if (dirty)
- {
- update_calendar_action_state (self);
- rebuild_appointments_section_soon (self);
- }
+ update_appointment_lists (self);
}