diff options
-rw-r--r-- | src/datetime-service.c | 20 | ||||
-rw-r--r-- | src/indicator-datetime.c | 24 |
2 files changed, 31 insertions, 13 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c index 17745fe..b0298ae 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -607,7 +607,7 @@ update_appointment_menu_items (gpointer user_data) int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if ((this_year % 400 == 0) || (this_year % 100 > 0 && this_year % 4 == 0)) days[1] = 29; - int highlightdays = days[mon] - mday + 1; + int highlightdays = days[mon] - mday; t1 = curtime; // By default the current time is the appointment start time. if (start_time_appointments > 0) { @@ -627,10 +627,7 @@ update_appointment_menu_items (gpointer user_data) g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1)); - t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); - - // Remove all highlights from the calendar widget - dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL); + t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) { g_debug("Failed to get ecal sources\n"); @@ -702,6 +699,11 @@ update_appointment_menu_items (gpointer user_data) } else { apt_output = SETTINGS_TIME_LOCALE; } + // Remove all highlights from the calendar widget + dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL); + + GVariantBuilder markeddays; + g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); i = 0; for (l = sorted_comp_instances; l; l = l->next) { @@ -724,9 +726,8 @@ update_appointment_menu_items (gpointer user_data) const int dyear = due->tm_year; // Mark day - g_debug("Marking date %s", ctime(&ci->start)); - dbusmenu_menuitem_property_set_int (calendar, CALENDAR_MENUITEM_PROP_MARK, due->tm_mday); - + g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday); + g_variant_builder_add (&markeddays, "i", dmday); // If the appointment time is less than the selected date, // don't create an appointment item for it. @@ -854,6 +855,9 @@ update_appointment_menu_items (gpointer user_data) } g_list_free(sorted_comp_instances); + GVariant * marks = g_variant_builder_end (&markeddays); + dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARK, marks); + updating_appointments = FALSE; g_debug("End of objects"); return TRUE; diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index b47f1af..71b174c 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -1155,14 +1155,28 @@ calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, I { g_debug("Changing calendar property"); if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_MARK)) { - ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value)); - g_debug("Marked day: %d", g_variant_get_int16(value)); + GVariantIter iter; + GVariant *day; + gchar *key; + + g_variant_iter_init (&iter, value); + while (g_variant_iter_loop (&iter, "{i}", &key, &day)) { + ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int32(day)); + g_debug("Marked day: %d", g_variant_get_int32(day)); + } } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_UNMARK)) { - ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value)); - g_debug("Unmarked day: %d", g_variant_get_int16(value)); + GVariantIter iter; + GVariant *day; + gchar *key; + + g_variant_iter_init (&iter, value); + while (g_variant_iter_loop (&iter, "{i}", &key, &day)) { + ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int32(day)); + g_debug("Unmarked day: %d", g_variant_get_int32(day)); + } } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) { - g_debug("Cleared Marks"); ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data)); + g_debug("Cleared Marks"); } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { gsize size = 3; const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint)); |