aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/planner-eds.c36
-rw-r--r--src/planner.h1
-rw-r--r--src/service.c8
-rw-r--r--src/utils.c19
-rw-r--r--src/utils.h1
5 files changed, 56 insertions, 9 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;
}
diff --git a/src/planner.h b/src/planner.h
index eab5f9a..f6148c6 100644
--- a/src/planner.h
+++ b/src/planner.h
@@ -44,6 +44,7 @@ struct IndicatorDatetimeAppt
GDateTime * begin;
GDateTime * end;
gboolean is_event;
+ gboolean is_daily;
gboolean has_alarms;
};
diff --git a/src/service.c b/src/service.c
index 0167d82..8d82355 100644
--- a/src/service.c
+++ b/src/service.c
@@ -687,7 +687,13 @@ get_appointment_time_format (struct IndicatorDatetimeAppt * appt, GDateTime * n
char * fmt;
gboolean full_day = g_date_time_difference (appt->end, appt->begin) == G_TIME_SPAN_DAY;
- if (full_day)
+ if (appt->is_daily)
+ {
+ char * time_string = generate_format_string_full (FALSE, FALSE);
+ fmt = join_date_and_time_format_strings (_("Daily"), time_string);
+ g_free (time_string);
+ }
+ else if (full_day)
{
/* TRANSLATORS: This is a strftime string for the day for full day events
in the menu. It should most likely be either '%A' for a full text day
diff --git a/src/utils.c b/src/utils.c
index fa54008..a408f68 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -154,6 +154,19 @@ T_(const char *msg)
return rv;
}
+gchar *
+join_date_and_time_format_strings (const char * date_string,
+ const char * time_string)
+{
+ /* TRANSLATORS: This is a format string passed to strftime to combine the
+ * date and the time. The value of "%s\xE2\x80\x82%s" will result in a
+ * string like this in US English 12-hour time: 'Fri Jul 16 11:50 AM'.
+ * The space in between date and time is a Unicode en space
+ * (E28082 in UTF-8 hex). */
+ return g_strdup_printf (T_("%s\xE2\x80\x82%s"), date_string, time_string);
+}
+
+
/* Tries to figure out what our format string should be. Lots
of translator comments in here. */
gchar *
@@ -218,11 +231,7 @@ generate_format_string_full (gboolean show_day, gboolean show_date)
/* Check point, we should have a date string */
g_return_val_if_fail(date_string != NULL, g_strdup(time_string));
- /* TRANSLATORS: This is a format string passed to strftime to combine the
- date and the time. The value of "%s\xE2\x80\x82%s" would result in a string like
- this in US English 12-hour time: 'Fri Jul 16 11:50 AM'.
- The space in between date and time is a Unicode en space (E28082 in UTF-8 hex). */
- return g_strdup_printf(T_("%s\xE2\x80\x82%s"), date_string, time_string);
+ return join_date_and_time_format_strings (date_string, time_string);
}
gchar *
diff --git a/src/utils.h b/src/utils.h
index 8dc2964..73bd83a 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -32,6 +32,7 @@ void split_settings_location (const gchar * location, gchar ** zone, gchar ** na
gchar * get_current_zone_name (const gchar * location);
gchar * generate_format_string_full (gboolean show_day, gboolean show_date);
gchar * generate_format_string_at_time (GDateTime * now, GDateTime * time);
+gchar * join_date_and_time_format_strings (const char * date, const char * time);
G_END_DECLS