From c4f6855cebd5b13deca8109e79f0beb7dabdd0ce Mon Sep 17 00:00:00 2001 From: Damon Chaplin Date: Mon, 1 May 2000 00:27:17 +0000 Subject: new function to see if the event dates have changed (including any 2000-05-01 Damon Chaplin * cal-util/calobj.c (ical_object_compare_dates): new function to see if the event dates have changed (including any recurrence rules). It is used for optimization when we get the "object_changed" signal. We have to do far less work if the dates are unchanged. * gui/e-week-view.c: * gui/e-day-view.c: only draw the selection when we have the keyboard focus, since the user expects to be able to type in a new event when the selection is shown. Also keep the selection when we lose focus, but just don't show it. Also quite a few changes to cope with the new client/server architecture. * gui/e-day-view-top-item.c (e_day_view_top_item_draw): * gui/e-day-view-main-item.c (e_day_view_main_item_draw): * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day): only draw the selection if the widget has the keyboard focus. * gui/gnome-cal.c (mark_gtk_calendar_day): fixed so it works with events longer than one day. And changed the code for updating events in the new views. svn path=/trunk/; revision=2701 --- calendar/gui/gnome-cal.c | 75 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 23 deletions(-) (limited to 'calendar/gui/gnome-cal.c') diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 763fd5eac4..cb37240ba4 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -385,20 +385,20 @@ gnome_calendar_set_view (GnomeCalendar *gcal, char *page_name) } +/* This tells all components to reload all calendar objects. */ static void gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { - e_day_view_update_event (E_DAY_VIEW (cal->day_view), - object, flags); - e_day_view_update_event (E_DAY_VIEW (cal->work_week_view), - object, flags); - e_week_view_update_event (E_WEEK_VIEW (cal->week_view), - object, flags); - e_week_view_update_event (E_WEEK_VIEW (cal->month_view), - object, flags); - year_view_update (YEAR_VIEW (cal->year_view), object, flags); - - gncal_todo_update (GNCAL_TODO (cal->todo), object, flags); + e_day_view_update_all_events (E_DAY_VIEW (cal->day_view)); + e_day_view_update_all_events (E_DAY_VIEW (cal->work_week_view)); + e_week_view_update_all_events (E_WEEK_VIEW (cal->week_view)); + e_week_view_update_all_events (E_WEEK_VIEW (cal->month_view)); + +#if 0 + year_view_update (YEAR_VIEW (cal->year_view), NULL, TRUE); +#endif + + gncal_todo_update (GNCAL_TODO (cal->todo), NULL, TRUE); gnome_calendar_tag_calendar (cal, cal->gtk_calendar); } @@ -410,7 +410,22 @@ gnome_calendar_object_updated_cb (GtkWidget *cal_client, { printf ("gnome-cal: got object changed_cb, uid='%s'\n", uid?uid:""); - gnome_calendar_update_all (gcal, NULL, CHANGE_NEW); + + /* FIXME: do we really want each view to reload the event itself? + Maybe we should keep track of events globally, maybe with ref + counts. We also need to sort out where they get freed. */ + e_day_view_update_event (E_DAY_VIEW (gcal->day_view), uid); + e_day_view_update_event (E_DAY_VIEW (gcal->work_week_view), uid); + e_week_view_update_event (E_WEEK_VIEW (gcal->week_view), uid); + e_week_view_update_event (E_WEEK_VIEW (gcal->month_view), uid); + + /* FIXME: optimize these? */ +#if 0 + year_view_update (YEAR_VIEW (gcal->year_view), NULL, TRUE); +#endif + + gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, TRUE); + gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); } @@ -421,7 +436,18 @@ gnome_calendar_object_removed_cb (GtkWidget *cal_client, { printf ("gnome-cal: got object removed _cb, uid='%s'\n", uid?uid:""); - gnome_calendar_update_all (gcal, NULL, CHANGE_ALL); + + e_day_view_remove_event (E_DAY_VIEW (gcal->day_view), uid); + e_day_view_remove_event (E_DAY_VIEW (gcal->work_week_view), uid); + e_week_view_remove_event (E_WEEK_VIEW (gcal->week_view), uid); + e_week_view_remove_event (E_WEEK_VIEW (gcal->month_view), uid); + + /* FIXME: optimize these? */ +#if 0 + year_view_update (YEAR_VIEW (gcal->year_view), NULL, CHANGE_ALL); +#endif + gncal_todo_update (GNCAL_TODO (gcal->todo), NULL, CHANGE_ALL); + gnome_calendar_tag_calendar (gcal, gcal->gtk_calendar); } @@ -794,20 +820,23 @@ static int mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c) { GtkCalendar *gtk_cal = c; - struct tm tm_s; - time_t t, day_end; + struct tm tm_s, tm_e; + gint start_day, end_day, day; tm_s = *localtime (&start); - day_end = time_day_end (end); + tm_e = *localtime (&end); - for (t = start; t <= day_end; t += 60*60*24){ - time_t new = mktime (&tm_s); - struct tm tm_day; + start_day = tm_s.tm_mday; + end_day = tm_e.tm_mday; + + /* If the event ends at midnight then really it ends on the previous + day (unless it started at the same time). */ + if (start != end && tm_e.tm_hour == 0 && tm_e.tm_min == 0) + end_day--; + + for (day = start_day; day <= end_day; day++) + gtk_calendar_mark_day (gtk_cal, day); - tm_day = *localtime (&new); - gtk_calendar_mark_day (gtk_cal, tm_day.tm_mday); - tm_s.tm_mday++; - } return TRUE; } -- cgit v1.2.3