diff options
author | Ted Gould <ted@gould.cx> | 2011-03-30 14:44:28 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-30 14:44:28 -0500 |
commit | 49ffaa6c41cee3855f5101cdbe0220e225f59ac0 (patch) | |
tree | 719d0b240c8af92e0e7f6e4f36bc238fe3f20fa3 /src | |
parent | c0166121f74d4d0552f1241a8bc42f380cfbd662 (diff) | |
download | ayatana-indicator-datetime-49ffaa6c41cee3855f5101cdbe0220e225f59ac0.tar.gz ayatana-indicator-datetime-49ffaa6c41cee3855f5101cdbe0220e225f59ac0.tar.bz2 ayatana-indicator-datetime-49ffaa6c41cee3855f5101cdbe0220e225f59ac0.zip |
Ensure that the marks get cleared on day changes that go across monthly boundries as well
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime-service.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c index 6820bb9..85139ed 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -300,10 +300,33 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g static gboolean day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { - start_time_appointments = (time_t)g_variant_get_uint32(variant); - + time_t new_time = (time_t)g_variant_get_uint32(variant); + g_warn_if_fail(new_time != 0); + + if (start_time_appointments == 0 || new_time == 0) { + /* If we've got nothing, assume everyhting is going to + get repopulated, let's start with a clean slate */ + dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); + } else { + /* No check to see if we changed months. If we did we'll + want to clear the marks. Otherwise we're cool keeping + them around. */ + struct tm start_tm; + struct tm new_tm; + + localtime_r(&start_time_appointments, &start_tm); + localtime_r(&new_time, &new_tm); + + if (start_tm.tm_mon != new_tm.tm_mon) { + dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); + } + } + + start_time_appointments = new_time; + g_debug("Received day-selected with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments)); g_idle_add(update_appointment_menu_items_idle, NULL); + return TRUE; } |