From 7b4baac1d34ce22a570f080066856e229462f606 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 25 Jul 2013 19:04:47 -0500 Subject: Add support for displaying alarms. EDS treats alarms as attributes of existing calendar events, so the difference in supporting them in the indicator is largely visual -- we use a different x-canonical-type for the menuitem so that clients can render them differently, such as with an alarm icon. --- README | 6 ++++++ src/planner-eds.c | 5 +++++ src/planner.h | 1 + src/service.c | 14 ++++++++++---- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/README b/README index c6a8780..5dc9764 100644 --- a/README +++ b/README @@ -42,6 +42,12 @@ CUSTOM MENUITEMS * Calendar - x-canonical-type s "com.canonical.indicator.calendar" + * Alarm + - label s short summary of the appointment + - x-canonical-type s "com.canonical.indicator.alarm" + - x-canonical-time x the date of the appointment + - x-canonical-time-format s strftime format string + * Appointment - label s short summary of the appointment - x-canonical-type s "com.canonical.indicator.appointment" diff --git a/src/planner-eds.c b/src/planner-eds.c index 8fdc50b..d417d41 100644 --- a/src/planner-eds.c +++ b/src/planner-eds.c @@ -81,6 +81,7 @@ my_get_appointments_foreach (ECalComponent * component, e_cal_component_get_status (component, &status); if ((status != ICAL_STATUS_COMPLETED) && (status != ICAL_STATUS_CANCELLED)) { + GList * alarm_uids; ECalComponentText text; struct IndicatorDatetimeAppt * appt = g_new0 (struct IndicatorDatetimeAppt, 1); @@ -93,6 +94,10 @@ my_get_appointments_foreach (ECalComponent * component, appt->is_event = vtype == E_CAL_COMPONENT_EVENT; appt->summary = g_strdup (text.value); + alarm_uids = e_cal_component_get_alarm_uids (component); + appt->has_alarms = alarm_uids != NULL; + cal_obj_uid_list_free (alarm_uids); + data->appointments = g_slist_prepend (data->appointments, appt); } } diff --git a/src/planner.h b/src/planner.h index 7499b75..eab5f9a 100644 --- a/src/planner.h +++ b/src/planner.h @@ -44,6 +44,7 @@ struct IndicatorDatetimeAppt GDateTime * begin; GDateTime * end; gboolean is_event; + gboolean has_alarms; }; /** diff --git a/src/service.c b/src/service.c index 4a7dedf..0167d82 100644 --- a/src/service.c +++ b/src/service.c @@ -725,14 +725,18 @@ create_appointments_section (IndicatorDatetimeService * self) const gint64 unix_time = g_date_time_to_unix (appt->begin); menu_item = g_menu_item_new (appt->summary, NULL); - g_menu_item_set_attribute (menu_item, "x-canonical-color", - "s", appt->color); + + if (!appt->has_alarms) + g_menu_item_set_attribute (menu_item, "x-canonical-color", + "s", appt->color); + g_menu_item_set_attribute (menu_item, "x-canonical-time", "x", unix_time); g_menu_item_set_attribute (menu_item, "x-canonical-time-format", "s", fmt); g_menu_item_set_attribute (menu_item, "x-canonical-type", - "s", "com.canonical.indicator.appointment"); + "s", appt->has_alarms ? "com.canonical.indicator.alarm" + : "com.canonical.indicator.appointment"); g_menu_item_set_action_and_target_value (menu_item, "indicator.activate-planner", g_variant_new_int64 (unix_time)); @@ -1164,6 +1168,7 @@ create_menu (IndicatorDatetimeService * self, int profile) switch (profile) { case PROFILE_PHONE: + sections[n++] = create_appointments_section (self); sections[n++] = create_phone_settings_section (self); break; @@ -1363,6 +1368,7 @@ rebuild_now (IndicatorDatetimeService * self, int sections) if (sections & SECTION_APPOINTMENTS) { + rebuild_section (phone->submenu, 0, create_appointments_section (self)); rebuild_section (desktop->submenu, 1, create_appointments_section (self)); } @@ -1373,7 +1379,7 @@ rebuild_now (IndicatorDatetimeService * self, int sections) if (sections & SECTION_SETTINGS) { - rebuild_section (phone->submenu, 0, create_phone_settings_section (self)); + rebuild_section (phone->submenu, 1, create_phone_settings_section (self)); rebuild_section (desktop->submenu, 3, create_desktop_settings_section (self)); } } -- cgit v1.2.3