aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/calendar.c
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui/calendar.c')
-rw-r--r--calendar/gui/calendar.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 30e4e0168c..339995cb92 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -38,6 +38,8 @@ calendar_new (char *title)
cal->title = g_strdup (title);
+ cal->event_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
calendar_init_alarms (cal);
return cal;
@@ -93,9 +95,14 @@ ical_object_try_alarms (iCalObject *obj)
void
calendar_add_object (Calendar *cal, iCalObject *obj)
{
+ g_return_if_fail (cal != NULL);
+ g_return_if_fail (obj != NULL);
+ g_return_if_fail (obj->uid != NULL);
+
obj->new = 0;
switch (obj->type){
case ICAL_EVENT:
+ g_hash_table_insert (cal->event_hash, obj->uid, obj);
cal->events = g_list_prepend (cal->events, obj);
ical_object_try_alarms (obj);
#ifdef DEBUGGING_MAIL_ALARM
@@ -133,6 +140,7 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_remove (cal->events, obj);
+ g_hash_table_remove (cal->event_hash, obj->uid);
break;
case ICAL_TODO:
@@ -161,6 +169,8 @@ calendar_destroy (Calendar *cal)
g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
g_list_free (cal->journal);
+ g_hash_table_destroy (cal->event_hash);
+
if (cal->title)
g_free (cal->title);
if (cal->filename)
@@ -169,17 +179,6 @@ calendar_destroy (Calendar *cal)
g_free (cal);
}
-static char *
-ice (time_t t)
-{
- static char buffer [100];
- struct tm *tm;
-
- tm = localtime (&t);
- sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
- return buffer;
-}
-
void
calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
{
@@ -544,7 +543,7 @@ calendar_object_find_event (Calendar *cal, const char *uid)
g_return_val_if_fail (cal != NULL, NULL);
g_return_val_if_fail (uid != NULL, NULL);
- return calendar_object_find_in_list (cal, cal->events, uid);
+ return g_hash_table_lookup (cal->event_hash, uid);
}
iCalObject *