aboutsummaryrefslogtreecommitdiff
path: root/src/planner-eds.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-07-25 21:06:25 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-07-25 21:06:25 -0500
commit30d45a522eb83d519f1ee44ebe06a6696d2b094d (patch)
tree2a4678ee1c5b9f41ce93de6b06bdcedfb1bd563d /src/planner-eds.c
parent7b4baac1d34ce22a570f080066856e229462f606 (diff)
downloadayatana-indicator-datetime-30d45a522eb83d519f1ee44ebe06a6696d2b094d.tar.gz
ayatana-indicator-datetime-30d45a522eb83d519f1ee44ebe06a6696d2b094d.tar.bz2
ayatana-indicator-datetime-30d45a522eb83d519f1ee44ebe06a6696d2b094d.zip
in the appointments section, only show the next instance of recurring events. If the event is daily, say so in the time format string.
Diffstat (limited to 'src/planner-eds.c')
-rw-r--r--src/planner-eds.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/planner-eds.c b/src/planner-eds.c
index d417d41..276058d 100644
--- a/src/planner-eds.c
+++ b/src/planner-eds.c
@@ -64,6 +64,9 @@ struct my_get_appointments_data
{
ESource * source;
GSList * appointments;
+
+ /* ensure that recurring events don't get multiple IndicatorDatetimeAppts */
+ GHashTable * added;
};
static gboolean
@@ -77,13 +80,37 @@ my_get_appointments_foreach (ECalComponent * component,
if ((vtype == E_CAL_COMPONENT_EVENT) || (vtype == E_CAL_COMPONENT_TODO))
{
- icalproperty_status status;
+ const gchar * uid = NULL;
+ icalproperty_status status = 0;
+
+ e_cal_component_get_uid (component, &uid);
e_cal_component_get_status (component, &status);
- if ((status != ICAL_STATUS_COMPLETED) && (status != ICAL_STATUS_CANCELLED))
+
+ if ((uid != NULL) &&
+ (!g_hash_table_contains (data->added, uid)) &&
+ (status != ICAL_STATUS_COMPLETED) &&
+ (status != ICAL_STATUS_CANCELLED))
{
GList * alarm_uids;
+ GSList * l;
+ GSList * recur_list;
ECalComponentText text;
- struct IndicatorDatetimeAppt * appt = g_new0 (struct IndicatorDatetimeAppt, 1);
+ struct IndicatorDatetimeAppt * appt;
+
+ appt = g_new0 (struct IndicatorDatetimeAppt, 1);
+
+ /* Determine whether this is a recurring event.
+ NB: icalrecurrencetype supports complex recurrence patterns;
+ however, since design only allows daily recurrence,
+ that's all we support here. */
+ e_cal_component_get_rrule_list (component, &recur_list);
+ for (l=recur_list; l!=NULL; l=l->next)
+ {
+ const struct icalrecurrencetype * recur = l->data;
+ appt->is_daily |= ((recur->freq == ICAL_DAILY_RECURRENCE)
+ && (recur->interval == 1));
+ }
+ e_cal_component_free_recur_list (recur_list);
text.value = "";
e_cal_component_get_summary (component, &text);
@@ -99,6 +126,7 @@ my_get_appointments_foreach (ECalComponent * component,
cal_obj_uid_list_free (alarm_uids);
data->appointments = g_slist_prepend (data->appointments, appt);
+ g_hash_table_add (data->added, g_strdup(uid));
}
}
@@ -146,6 +174,7 @@ my_get_appointments (IndicatorDatetimePlanner * planner,
data.source = NULL;
data.appointments = NULL;
+ data.added = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
sources = e_source_registry_list_sources (p->source_registry, E_SOURCE_EXTENSION_CALENDAR);
for (l=sources; l!=NULL; l=l->next)
@@ -188,6 +217,7 @@ my_get_appointments (IndicatorDatetimePlanner * planner,
g_list_free_full (sources, g_object_unref);
g_debug ("%s EDS get_appointments returning %d appointments", G_STRLOC, g_slist_length (data.appointments));
+ g_hash_table_destroy (data.added);
return data.appointments;
}