From 541c3a7a73e084b5ebd82aae7c3fc1f3ba4f0b72 Mon Sep 17 00:00:00 2001 From: Arturo Espinosa Date: Fri, 17 Apr 1998 04:49:37 +0000 Subject: New event generation api in place -miguel svn path=/trunk/; revision=146 --- calendar/cal-util/calobj.c | 4 ++- calendar/calendar.c | 65 +++++++++++++++++++++++++++++++++++++++---- calendar/calendar.h | 21 +++++++++++++- calendar/calobj.c | 4 ++- calendar/gncal-day-view.c | 7 ++--- calendar/gncal-full-day.c | 62 ++++++++++++++++++++++++++--------------- calendar/gui/calendar.c | 65 +++++++++++++++++++++++++++++++++++++++---- calendar/gui/calendar.h | 21 +++++++++++++- calendar/gui/gncal-day-view.c | 7 ++--- calendar/gui/gncal-full-day.c | 62 ++++++++++++++++++++++++++--------------- calendar/gui/main.c | 41 ++++++++++++++++----------- calendar/gui/view-utils.c | 51 +++------------------------------ calendar/main.c | 41 ++++++++++++++++----------- calendar/pcs/calobj.c | 4 ++- calendar/view-utils.c | 51 +++------------------------------ 15 files changed, 309 insertions(+), 197 deletions(-) diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 8272fd1560..89bfc94540 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -408,8 +408,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ical->type = ICAL_EVENT; else if (strcmp (object_name, VCTodoProp) == 0) ical->type = ICAL_TODO; - else + else { + g_free (ical); return 0; + } /* uid */ if (has (o, VCUniqueStringProp)){ diff --git a/calendar/calendar.c b/calendar/calendar.c index dd0a5cca3f..8ad0208ac5 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -111,6 +111,23 @@ ice (time_t t) return buffer; } +void +calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure) +{ + for (; objects; objects = objects->next){ + iCalObject *object = objects->data; + + if ((start <= object->dtstart) && (object->dtend <= end)) + (*cb)(object, object->dtstart, object->dtend, closure); + } +} + +void +calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure) +{ + calendar_iterate_on_objects (cal->events, start, end, cb, closure); +} + GList * calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func) { @@ -130,12 +147,6 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar return new_events; } -GList * -calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) -{ - return calendar_get_objects_in_range (cal->events, start, end, sort_func); -} - GList * calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) { @@ -241,3 +252,45 @@ calendar_save (Calendar *cal, char *fname) cleanStrTbl (); } +static void +calendar_object_compare_by_start (gpointer a, gpointer b) +{ + CalendarObject *ca = a; + CalendarObject *cb = b; + time_t diff; + + diff = ca->ev_start - cb->ev_start; + return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; +} + +static void +assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c) +{ + CalendarObject *co; + GList **l = c; + + co = g_new (CalendarObject, 1); + co->ev_start = start; + co->ev_end = end; + co->ico = obj; + *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start); +} + +void +calendar_destroy_event_list (GList *l) +{ + GList *p; + + for (p = l; p; p = p->next) + g_free (l->data); + g_list_free (l); +} + +GList * +calendar_get_events_in_range (Calendar *cal, time_t start, time_t end) +{ + GList *l = 0; + + calendar_iterate (cal, start, end, assemble_event_list, &l); + return l; +} diff --git a/calendar/calendar.h b/calendar/calendar.h index a59fec7544..95c92e7fa8 100644 --- a/calendar/calendar.h +++ b/calendar/calendar.h @@ -28,17 +28,36 @@ typedef struct { void *temp; } Calendar; +/* This is only used by the calendar_get_events_in_range routine to get + * a list of objects that recur on a specific date + */ +typedef struct { + time_t ev_start; + time_t ev_end; + iCalObject *ico; +} CalendarObject; + +typedef void (*calendarfn)(iCalObject *obj, time_t start, time_t end, void *closure); + Calendar *calendar_new (char *title); void calendar_load (Calendar *cal, char *fname); void calendar_add_object (Calendar *cal, iCalObject *obj); void calendar_remove_object (Calendar *cal, iCalObject *obj); void calendar_destroy (Calendar *cal); -GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); gint calendar_compare_by_dtstart (gpointer a, gpointer b); +void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure); +void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure); + +/* Note this routine returns a GList with CalendarObjects */ +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end); + +/* Destroy the above list with this method */ +void calendar_destroy_event_list (GList *l); + END_GNOME_DECLS #endif diff --git a/calendar/calobj.c b/calendar/calobj.c index 8272fd1560..89bfc94540 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -408,8 +408,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ical->type = ICAL_EVENT; else if (strcmp (object_name, VCTodoProp) == 0) ical->type = ICAL_TODO; - else + else { + g_free (ical); return 0; + } /* uid */ if (has (o, VCUniqueStringProp)){ diff --git a/calendar/gncal-day-view.c b/calendar/gncal-day-view.c index d338802240..2172810c52 100644 --- a/calendar/gncal-day-view.c +++ b/calendar/gncal-day-view.c @@ -94,7 +94,7 @@ gncal_day_view_destroy (GtkObject *object) if (dview->day_str) g_free (dview->day_str); if (dview->events) - g_list_free (dview->events); + calendar_destroy_event_list (dview->events); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -303,12 +303,11 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags) dview->day_str = g_strdup (buf); if (dview->events) - g_list_free (dview->events); + calendar_destroy_event_list (dview->events); dview->events = calendar_get_events_in_range (dview->calendar->cal, dview->lower, - dview->upper, - calendar_compare_by_dtstart); + dview->upper); gtk_widget_draw (GTK_WIDGET (dview), NULL); } diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index d7aecccfee..028e3657b7 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -31,6 +31,7 @@ typedef struct { int y; int width; int height; + time_t start, end; } Child; struct layout_row { @@ -302,7 +303,7 @@ child_range_changed (GncalFullDay *fullday, Child *child) /* Calc display range for event */ - get_tm_range (fullday, child->ico->dtstart, child->ico->dtend, &start, &end, &lower_row, &rows_used); + get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used); get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL); child->lower_row = lower_row - f_lower_row; @@ -536,7 +537,7 @@ child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) } static Child * -child_new (GncalFullDay *fullday, iCalObject *ico) +child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico) { Child *child; @@ -549,7 +550,9 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->y = 0; child->width = 0; child->height = 0; - + child->start = start; + child->end = end; + child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -956,7 +959,7 @@ gncal_full_day_realize (GtkWidget *widget) gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]); fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW); - fullday->beam_cursor = gdk_cursor_new (GDK_XTERM); + fullday->beam_cursor = gdk_cursor_new (GDK_XTERM); for (children = fullday->children; children; children = children->next) child_realize (fullday, children->data); @@ -1644,8 +1647,8 @@ update_from_drag_info (GncalFullDay *fullday) widget = GTK_WIDGET (fullday); get_time_from_rows (fullday, di->child_start_row, di->child_rows_used, - &di->child->ico->dtstart, - &di->child->ico->dtend); + &di->child->start, + &di->child->end); child_range_changed (fullday, di->child); @@ -1864,13 +1867,34 @@ gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer } } +static gint +child_compare_by_start (gpointer a, gpointer b) +{ + Child *ca = a; + Child *cb = b; + time_t diff; + + diff = ca->start - cb->start; + return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; +} + +static void +fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c) +{ + GncalFullDay *fullday = c; + Child *child; + + child = child_new (fullday, start, end, obj); + fullday->children = g_list_insert_sorted (fullday->children, child, child_compare_by_start); +} + void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) { GList *children; GList *l_events, *events; Child *child; - + g_return_if_fail (fullday != NULL); g_return_if_fail (GNCAL_IS_FULL_DAY (fullday)); @@ -1900,22 +1924,14 @@ gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) g_list_free (fullday->children); - children = NULL; - - l_events = calendar_get_events_in_range (fullday->calendar->cal, - fullday->lower, - fullday->upper, - calendar_compare_by_dtstart); - - for (events = l_events; events; events = events->next) { - child = child_new (fullday, events->data); - children = g_list_append (children, child); - } - - g_list_free (l_events); - - fullday->children = g_list_first (children); - + fullday->children = NULL; + + calendar_iterate (fullday->calendar->cal, + fullday->lower, + fullday->upper, + fullday_add_children, + fullday); + layout_children (fullday); /* Realize and map children */ diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index dd0a5cca3f..8ad0208ac5 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -111,6 +111,23 @@ ice (time_t t) return buffer; } +void +calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure) +{ + for (; objects; objects = objects->next){ + iCalObject *object = objects->data; + + if ((start <= object->dtstart) && (object->dtend <= end)) + (*cb)(object, object->dtstart, object->dtend, closure); + } +} + +void +calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure) +{ + calendar_iterate_on_objects (cal->events, start, end, cb, closure); +} + GList * calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func) { @@ -130,12 +147,6 @@ calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompar return new_events; } -GList * -calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) -{ - return calendar_get_objects_in_range (cal->events, start, end, sort_func); -} - GList * calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) { @@ -241,3 +252,45 @@ calendar_save (Calendar *cal, char *fname) cleanStrTbl (); } +static void +calendar_object_compare_by_start (gpointer a, gpointer b) +{ + CalendarObject *ca = a; + CalendarObject *cb = b; + time_t diff; + + diff = ca->ev_start - cb->ev_start; + return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; +} + +static void +assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c) +{ + CalendarObject *co; + GList **l = c; + + co = g_new (CalendarObject, 1); + co->ev_start = start; + co->ev_end = end; + co->ico = obj; + *l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start); +} + +void +calendar_destroy_event_list (GList *l) +{ + GList *p; + + for (p = l; p; p = p->next) + g_free (l->data); + g_list_free (l); +} + +GList * +calendar_get_events_in_range (Calendar *cal, time_t start, time_t end) +{ + GList *l = 0; + + calendar_iterate (cal, start, end, assemble_event_list, &l); + return l; +} diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h index a59fec7544..95c92e7fa8 100644 --- a/calendar/gui/calendar.h +++ b/calendar/gui/calendar.h @@ -28,17 +28,36 @@ typedef struct { void *temp; } Calendar; +/* This is only used by the calendar_get_events_in_range routine to get + * a list of objects that recur on a specific date + */ +typedef struct { + time_t ev_start; + time_t ev_end; + iCalObject *ico; +} CalendarObject; + +typedef void (*calendarfn)(iCalObject *obj, time_t start, time_t end, void *closure); + Calendar *calendar_new (char *title); void calendar_load (Calendar *cal, char *fname); void calendar_add_object (Calendar *cal, iCalObject *obj); void calendar_remove_object (Calendar *cal, iCalObject *obj); void calendar_destroy (Calendar *cal); -GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); gint calendar_compare_by_dtstart (gpointer a, gpointer b); +void calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure); +void calendar_iterate (Calendar *cal, time_t start, time_t end, calendarfn cb, void *closure); + +/* Note this routine returns a GList with CalendarObjects */ +GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end); + +/* Destroy the above list with this method */ +void calendar_destroy_event_list (GList *l); + END_GNOME_DECLS #endif diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c index d338802240..2172810c52 100644 --- a/calendar/gui/gncal-day-view.c +++ b/calendar/gui/gncal-day-view.c @@ -94,7 +94,7 @@ gncal_day_view_destroy (GtkObject *object) if (dview->day_str) g_free (dview->day_str); if (dview->events) - g_list_free (dview->events); + calendar_destroy_event_list (dview->events); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -303,12 +303,11 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags) dview->day_str = g_strdup (buf); if (dview->events) - g_list_free (dview->events); + calendar_destroy_event_list (dview->events); dview->events = calendar_get_events_in_range (dview->calendar->cal, dview->lower, - dview->upper, - calendar_compare_by_dtstart); + dview->upper); gtk_widget_draw (GTK_WIDGET (dview), NULL); } diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index d7aecccfee..028e3657b7 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -31,6 +31,7 @@ typedef struct { int y; int width; int height; + time_t start, end; } Child; struct layout_row { @@ -302,7 +303,7 @@ child_range_changed (GncalFullDay *fullday, Child *child) /* Calc display range for event */ - get_tm_range (fullday, child->ico->dtstart, child->ico->dtend, &start, &end, &lower_row, &rows_used); + get_tm_range (fullday, child->start, child->end, &start, &end, &lower_row, &rows_used); get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, &f_lower_row, NULL); child->lower_row = lower_row - f_lower_row; @@ -536,7 +537,7 @@ child_button_press (GtkWidget *widget, GdkEventButton *event, gpointer data) } static Child * -child_new (GncalFullDay *fullday, iCalObject *ico) +child_new (GncalFullDay *fullday, time_t start, time_t end, iCalObject *ico) { Child *child; @@ -549,7 +550,9 @@ child_new (GncalFullDay *fullday, iCalObject *ico) child->y = 0; child->width = 0; child->height = 0; - + child->start = start; + child->end = end; + child_range_changed (fullday, child); /* We set the i-beam cursor and the initial summary text upon realization */ @@ -956,7 +959,7 @@ gncal_full_day_realize (GtkWidget *widget) gdk_window_set_background (widget->window, &widget->style->bg[GTK_STATE_PRELIGHT]); fullday->up_down_cursor = gdk_cursor_new (GDK_DOUBLE_ARROW); - fullday->beam_cursor = gdk_cursor_new (GDK_XTERM); + fullday->beam_cursor = gdk_cursor_new (GDK_XTERM); for (children = fullday->children; children; children = children->next) child_realize (fullday, children->data); @@ -1644,8 +1647,8 @@ update_from_drag_info (GncalFullDay *fullday) widget = GTK_WIDGET (fullday); get_time_from_rows (fullday, di->child_start_row, di->child_rows_used, - &di->child->ico->dtstart, - &di->child->ico->dtend); + &di->child->start, + &di->child->end); child_range_changed (fullday, di->child); @@ -1864,13 +1867,34 @@ gncal_full_day_foreach (GtkContainer *container, GtkCallback callback, gpointer } } +static gint +child_compare_by_start (gpointer a, gpointer b) +{ + Child *ca = a; + Child *cb = b; + time_t diff; + + diff = ca->start - cb->start; + return (diff < 0) ? -1 : (diff > 0) ? 1 : 0; +} + +static void +fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c) +{ + GncalFullDay *fullday = c; + Child *child; + + child = child_new (fullday, start, end, obj); + fullday->children = g_list_insert_sorted (fullday->children, child, child_compare_by_start); +} + void gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) { GList *children; GList *l_events, *events; Child *child; - + g_return_if_fail (fullday != NULL); g_return_if_fail (GNCAL_IS_FULL_DAY (fullday)); @@ -1900,22 +1924,14 @@ gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags) g_list_free (fullday->children); - children = NULL; - - l_events = calendar_get_events_in_range (fullday->calendar->cal, - fullday->lower, - fullday->upper, - calendar_compare_by_dtstart); - - for (events = l_events; events; events = events->next) { - child = child_new (fullday, events->data); - children = g_list_append (children, child); - } - - g_list_free (l_events); - - fullday->children = g_list_first (children); - + fullday->children = NULL; + + calendar_iterate (fullday->calendar->cal, + fullday->lower, + fullday->upper, + fullday_add_children, + fullday); + layout_children (fullday); /* Realize and map children */ diff --git a/calendar/gui/main.c b/calendar/gui/main.c index 08bb61fb8b..6075cc0f7d 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -32,6 +32,9 @@ int day_begin, day_end; /* Number of calendars active */ int active_calendars = 0; +/* A list of all of the calendars started */ +GList *all_calendars = NULL; + void init_username (void) { @@ -89,21 +92,6 @@ init_calendar (void) gnome_config_pop_prefix (); } -void -new_calendar_cmd (GtkWidget *widget, void *data) -{ -} - -void -open_calendar_cmd (GtkWidget *widget, void *data) -{ -} - -void -save_calendar_cmd (GtkWidget *widget, void *data) -{ -} - void about_calendar_cmd (GtkWidget *widget, void *data) { @@ -170,6 +158,26 @@ today_clicked (GtkWidget *widget, GnomeCalendar *gcal) gnome_calendar_goto (gcal, time (NULL)); } +void +new_calendar_cmd (GtkWidget *widget, void *data) +{ +} + +void +open_calendar_cmd (GtkWidget *widget, void *data) +{ + GtkWidget *filesel; + + filesel = gtk_file_selection_new (_("Open Calendar")); + gtk_widget_show (filesel); + +} + +void +save_calendar_cmd (GtkWidget *widget, void *data) +{ +} + GnomeUIInfo gnome_cal_file_menu [] = { { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd }, @@ -238,6 +246,7 @@ new_calendar (char *full_name, char *calendar_file) title = g_copy_strings (full_name, "'s calendar", NULL); toplevel = gnome_calendar_new (title); + g_free (title); setup_menu (toplevel); if (g_file_exists (calendar_file)){ @@ -248,7 +257,7 @@ new_calendar (char *full_name, char *calendar_file) gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } active_calendars++; - + all_calendars = g_list_prepend (all_calendars, toplevel); gtk_widget_show (toplevel); } diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c index 1a5322228d..ccbe125291 100644 --- a/calendar/gui/view-utils.c +++ b/calendar/gui/view-utils.c @@ -8,50 +8,6 @@ #include #include "view-utils.h" - -/* FIXME: remove this function later */ - -#if 0 -static GList * -calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) -{ - static iCalObject objs[24]; - static int ready = 0; - int i; - GList *list; - - if (!ready) { - struct tm tm; - time_t tim; - - ready = 1; - - for (i = 0; i < 24; i++) { - tim = time (NULL); - tm = *localtime (&tim); - - tm.tm_hour = i; - tm.tm_min = 0; - tm.tm_sec = 0; - objs[i].dtstart = mktime (&tm); - - tm.tm_hour = i; - tm.tm_min = 30; - tm.tm_sec = 0; - objs[i].dtend = mktime (&tm); - - objs[i].summary = "Ir a chingar a tu madre"; - } - } - - list = NULL; - - for (i = 0; i < 8; i++) - list = g_list_append (list, &objs[i]); - - return list; -} -#endif void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area, int flags, GList *events, time_t start, time_t end) @@ -72,10 +28,11 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1); for (y = area->y, list = events; (y < max_y) && list; y += font_height, list = list->next) { - ico = list->data; + CalendarObject *co = list->data; + ico = co->ico; - tm_start = *localtime (&ico->dtstart); - tm_end = *localtime (&ico->dtend); + tm_start = *localtime (&co->ev_start); + tm_end = *localtime (&co->ev_end); str = ico->summary; if (flags & VIEW_UTILS_DRAW_END) { diff --git a/calendar/main.c b/calendar/main.c index 08bb61fb8b..6075cc0f7d 100644 --- a/calendar/main.c +++ b/calendar/main.c @@ -32,6 +32,9 @@ int day_begin, day_end; /* Number of calendars active */ int active_calendars = 0; +/* A list of all of the calendars started */ +GList *all_calendars = NULL; + void init_username (void) { @@ -89,21 +92,6 @@ init_calendar (void) gnome_config_pop_prefix (); } -void -new_calendar_cmd (GtkWidget *widget, void *data) -{ -} - -void -open_calendar_cmd (GtkWidget *widget, void *data) -{ -} - -void -save_calendar_cmd (GtkWidget *widget, void *data) -{ -} - void about_calendar_cmd (GtkWidget *widget, void *data) { @@ -170,6 +158,26 @@ today_clicked (GtkWidget *widget, GnomeCalendar *gcal) gnome_calendar_goto (gcal, time (NULL)); } +void +new_calendar_cmd (GtkWidget *widget, void *data) +{ +} + +void +open_calendar_cmd (GtkWidget *widget, void *data) +{ + GtkWidget *filesel; + + filesel = gtk_file_selection_new (_("Open Calendar")); + gtk_widget_show (filesel); + +} + +void +save_calendar_cmd (GtkWidget *widget, void *data) +{ +} + GnomeUIInfo gnome_cal_file_menu [] = { { GNOME_APP_UI_ITEM, N_("New calendar"), NULL, new_calendar_cmd }, @@ -238,6 +246,7 @@ new_calendar (char *full_name, char *calendar_file) title = g_copy_strings (full_name, "'s calendar", NULL); toplevel = gnome_calendar_new (title); + g_free (title); setup_menu (toplevel); if (g_file_exists (calendar_file)){ @@ -248,7 +257,7 @@ new_calendar (char *full_name, char *calendar_file) gnome_calendar_load (GNOME_CALENDAR (toplevel), "./test.vcf"); } active_calendars++; - + all_calendars = g_list_prepend (all_calendars, toplevel); gtk_widget_show (toplevel); } diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 8272fd1560..89bfc94540 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -408,8 +408,10 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ical->type = ICAL_EVENT; else if (strcmp (object_name, VCTodoProp) == 0) ical->type = ICAL_TODO; - else + else { + g_free (ical); return 0; + } /* uid */ if (has (o, VCUniqueStringProp)){ diff --git a/calendar/view-utils.c b/calendar/view-utils.c index 1a5322228d..ccbe125291 100644 --- a/calendar/view-utils.c +++ b/calendar/view-utils.c @@ -8,50 +8,6 @@ #include #include "view-utils.h" - -/* FIXME: remove this function later */ - -#if 0 -static GList * -calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func) -{ - static iCalObject objs[24]; - static int ready = 0; - int i; - GList *list; - - if (!ready) { - struct tm tm; - time_t tim; - - ready = 1; - - for (i = 0; i < 24; i++) { - tim = time (NULL); - tm = *localtime (&tim); - - tm.tm_hour = i; - tm.tm_min = 0; - tm.tm_sec = 0; - objs[i].dtstart = mktime (&tm); - - tm.tm_hour = i; - tm.tm_min = 30; - tm.tm_sec = 0; - objs[i].dtend = mktime (&tm); - - objs[i].summary = "Ir a chingar a tu madre"; - } - } - - list = NULL; - - for (i = 0; i < 8; i++) - list = g_list_append (list, &objs[i]); - - return list; -} -#endif void view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRectangle *area, int flags, GList *events, time_t start, time_t end) @@ -72,10 +28,11 @@ view_utils_draw_events (GtkWidget *widget, GdkWindow *window, GdkGC *gc, GdkRect max_y = area->y + area->height - font_height * ((flags & VIEW_UTILS_DRAW_SPLIT) ? 2 : 1); for (y = area->y, list = events; (y < max_y) && list; y += font_height, list = list->next) { - ico = list->data; + CalendarObject *co = list->data; + ico = co->ico; - tm_start = *localtime (&ico->dtstart); - tm_end = *localtime (&ico->dtend); + tm_start = *localtime (&co->ev_start); + tm_end = *localtime (&co->ev_end); str = ico->summary; if (flags & VIEW_UTILS_DRAW_END) { -- cgit v1.2.3