aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-05-01 08:27:17 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-05-01 08:27:17 +0800
commitc4f6855cebd5b13deca8109e79f0beb7dabdd0ce (patch)
tree95937961c0290907b5a469618c1b137f97c94480 /calendar/gui/gnome-cal.c
parent165bf85c4d07928acf01c43c49c7e65c16b28ac8 (diff)
downloadgsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar.gz
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar.bz2
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar.lz
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar.xz
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.tar.zst
gsoc2013-evolution-c4f6855cebd5b13deca8109e79f0beb7dabdd0ce.zip
new function to see if the event dates have changed (including any
2000-05-01 Damon Chaplin <damon@helixcode.com> * 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
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c75
1 files changed, 52 insertions, 23 deletions
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:"<NULL>");
- 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:"<NULL>");
- 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;
}