aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-06-17 09:33:23 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-06-17 09:33:23 -0500
commit1d015b51af186c0f71ff8164321feeef1cf63c19 (patch)
tree50ce8d2c519a7436ab5e323315fcdd01d628fa8b
parent556eb6bdee7b2c5d3aa5676963fd77749edf4c9e (diff)
downloadayatana-indicator-datetime-1d015b51af186c0f71ff8164321feeef1cf63c19.tar.gz
ayatana-indicator-datetime-1d015b51af186c0f71ff8164321feeef1cf63c19.tar.bz2
ayatana-indicator-datetime-1d015b51af186c0f71ff8164321feeef1cf63c19.zip
make indicator_datetime_service_set_calendar_date() public. This is another one we'll need for unit tests
-rw-r--r--src/service.c42
-rw-r--r--src/service.h4
2 files changed, 36 insertions, 10 deletions
diff --git a/src/service.c b/src/service.c
index 74bddbf..cc0b17d 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1257,18 +1257,19 @@ on_calendar_action_activated (GSimpleAction * action G_GNUC_UNUSED,
GVariant * state,
gpointer gself)
{
+ gint64 unix_time;
IndicatorDatetimeService * self = INDICATOR_DATETIME_SERVICE (gself);
- priv_t * p = self->priv;
- gint64 t = g_variant_get_int64 (state);
- /* update calendar_date */
- g_clear_pointer (&p->calendar_date, g_date_time_unref);
- if (t)
- p->calendar_date = g_date_time_new_from_unix_local (t);
-
- /* sync the menuitems and action states */
- update_calendar_action_state (self);
- rebuild_appointments_section_soon (self);
+ if ((unix_time = g_variant_get_int64 (state)))
+ {
+ GDateTime * date = g_date_time_new_from_unix_local (unix_time);
+ indicator_datetime_service_set_calendar_date (self, date);
+ g_date_time_unref (date);
+ }
+ else /* unset */
+ {
+ indicator_datetime_service_set_calendar_date (self, NULL);
+ }
}
@@ -1856,3 +1857,24 @@ indicator_datetime_service_get_localtime (IndicatorDatetimeService * self G_GNUC
return g_date_time_new_now_local ();
}
+void
+indicator_datetime_service_set_calendar_date (IndicatorDatetimeService * self,
+ GDateTime * date)
+{
+ gboolean dirty;
+ priv_t * p = self->priv;
+
+ dirty = !date || !p->calendar_date || g_date_time_compare (date, p->calendar_date);
+
+ /* update calendar_date */
+ g_clear_pointer (&p->calendar_date, g_date_time_unref);
+ if (date != NULL)
+ p->calendar_date = g_date_time_ref (date);
+
+ /* sync the menuitems and action states */
+ if (dirty)
+ {
+ update_calendar_action_state (self);
+ rebuild_appointments_section_soon (self);
+ }
+}
diff --git a/src/service.h b/src/service.h
index b8c9bcd..53d4281 100644
--- a/src/service.h
+++ b/src/service.h
@@ -66,6 +66,10 @@ IndicatorDatetimeService * indicator_datetime_service_new (gboolean replace);
GDateTime * indicator_datetime_service_get_localtime (IndicatorDatetimeService * service);
+void indicator_datetime_service_set_calendar_date (IndicatorDatetimeService * self,
+ GDateTime * date);
+
+
G_END_DECLS
#endif /* __INDICATOR_DATETIME_SERVICE_H__ */