diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2013-07-25 19:04:47 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2013-07-25 19:04:47 -0500 |
commit | 7b4baac1d34ce22a570f080066856e229462f606 (patch) | |
tree | 1fe434370027aaeddbd6a69ff8d427c06128f913 /src | |
parent | 7364cf8dcb250e69748cdf077556778dd60a5f1d (diff) | |
download | ayatana-indicator-datetime-7b4baac1d34ce22a570f080066856e229462f606.tar.gz ayatana-indicator-datetime-7b4baac1d34ce22a570f080066856e229462f606.tar.bz2 ayatana-indicator-datetime-7b4baac1d34ce22a570f080066856e229462f606.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/planner-eds.c | 5 | ||||
-rw-r--r-- | src/planner.h | 1 | ||||
-rw-r--r-- | src/service.c | 14 |
3 files changed, 16 insertions, 4 deletions
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)); } } |