aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/gnome-cal.c
diff options
context:
space:
mode:
authorDamon Chaplin <damon@helixcode.com>2000-05-05 05:04:40 +0800
committerDamon Chaplin <damon@src.gnome.org>2000-05-05 05:04:40 +0800
commitea787be7184b4d0c5d093b3c560b8f1879839d73 (patch)
tree367fc0091afe6bfaaeca7971fce0221319a6bef7 /calendar/gui/gnome-cal.c
parentbe8e1b8c1f5e52bdb0e3c674da29dc3ca8bc49f4 (diff)
downloadgsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar.gz
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar.bz2
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar.lz
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar.xz
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.tar.zst
gsoc2013-evolution-ea787be7184b4d0c5d093b3c560b8f1879839d73.zip
for the long events pass E_DAY_VIEW_LONG_EVENT as the day. Fixes SEGV.
2000-05-04 Damon Chaplin <damon@helixcode.com> * gui/e-day-view.c (e_day_view_foreach_event_with_uid): for the long events pass E_DAY_VIEW_LONG_EVENT as the day. Fixes SEGV. * gui/calendar-commands.c: when we switch views, grab the focus. * gui/gnome-cal.c (gnome_calendar_tag_calendar): (gnome_calendar_mark_gtk_calendar_day): changed this so it uses cal_client_get_events_in_range(), and doesn't load any objects. Also just return if it isn't visible. * gui/calendar-commands.c (calendar_get_events_in_range): call g_list_sort() to sort the list rather than g_list_insert_sorted() for each element. It is much more efficient. Also changed it so that the co->ev_start/end fields are copied from the CalObjInstance rather than the parameters to the function (that is right, isn't it?) Also freed the list elements, and finally the list. (calendar_iterate): changed this to use cal_client_get_events_in_range since that is more efficient than getting all the uids and then loading and parsing all the events. * pcs/cal-backend.c (save): output the '... saved' message before freeing the string! * gui/gncal-todo.c (gncal_todo_update): * gui/e-week-view.c (e_week_view_update_event): * gui/e-day-view.c (e_day_view_update_event): * gui/calendar-commands.c (calendar_get_events_in_range): (calendar_iterate): free obj_string after it is parsed. svn path=/trunk/; revision=2802
Diffstat (limited to 'calendar/gui/gnome-cal.c')
-rw-r--r--calendar/gui/gnome-cal.c92
1 files changed, 61 insertions, 31 deletions
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 748a805e9f..f7a6eb5ac4 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -36,6 +36,10 @@ static void gnome_calendar_destroy (GtkObject *object);
static void gnome_calendar_update_view_times (GnomeCalendar *gcal,
GtkWidget *page);
static void gnome_calendar_update_gtk_calendar (GnomeCalendar *gcal);
+static int gnome_calendar_mark_gtk_calendar_day (GnomeCalendar *cal,
+ GtkCalendar *gtk_cal,
+ time_t start,
+ time_t end);
static void gnome_calendar_on_day_selected (GtkCalendar *calendar,
GnomeCalendar *gcal);
static void gnome_calendar_on_month_changed (GtkCalendar *calendar,
@@ -814,33 +818,6 @@ calendar_notify (time_t activation_time, CalendarAlarm *which, void *data)
}
/*
- * called from the calendar_iterate routine to mark the days of a GtkCalendar
- */
-static int
-mark_gtk_calendar_day (iCalObject *obj, time_t start, time_t end, void *c)
-{
- GtkCalendar *gtk_cal = c;
- struct tm tm_s, tm_e;
- gint start_day, end_day, day;
-
- tm_s = *localtime (&start);
- tm_e = *localtime (&end);
-
- 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);
-
- return TRUE;
-}
-
-/*
* Tags the dates with appointments in a GtkCalendar based on the
* GnomeCalendar contents
*/
@@ -849,18 +826,25 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
{
time_t month_begin, month_end;
struct tm tm;
+ GList *cois, *l;
g_return_if_fail (cal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (cal));
g_return_if_fail (gtk_cal != NULL);
g_return_if_fail (GTK_IS_CALENDAR (gtk_cal));
+ /* If the GtkCalendar isn't visible, we just return. */
+ if (!GTK_WIDGET_VISIBLE (cal->gtk_calendar))
+ return;
+
/* compute month_begin */
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
- tm.tm_mday = 1; /* setting this to zero is a no-no; it will set mktime back to the end of the
- previous month, which may be 28,29,30; this may chop some days from the calendar */
+ /* setting tm_day to zero is a no-no; it will set mktime back to the
+ end of the previous month, which may be 28,29,30; this may chop
+ some days from the calendar */
+ tm.tm_mday = 1;
tm.tm_mon = gtk_cal->month;
tm.tm_year = gtk_cal->year - 1900;
tm.tm_isdst= -1;
@@ -871,11 +855,57 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
gtk_calendar_freeze (gtk_cal);
gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal, month_begin, month_end,
- mark_gtk_calendar_day, gtk_cal);
+
+ cois = cal_client_get_events_in_range (cal->client, month_begin,
+ month_end);
+
+ for (l = cois; l; l = l->next) {
+ CalObjInstance *coi = l->data;
+
+ gnome_calendar_mark_gtk_calendar_day (cal, gtk_cal,
+ coi->start, coi->end);
+
+ g_free (coi->uid);
+ g_free (coi);
+ }
+
+ g_list_free (cois);
+
gtk_calendar_thaw (gtk_cal);
}
+
+/*
+ * This is called from gnome_calendar_tag_calendar to mark the days of a
+ * GtkCalendar on which the user has appointments.
+ */
+static int
+gnome_calendar_mark_gtk_calendar_day (GnomeCalendar *cal,
+ GtkCalendar *gtk_cal,
+ time_t start,
+ time_t end)
+{
+ struct tm tm_s, tm_e;
+ gint start_day, end_day, day;
+
+ tm_s = *localtime (&start);
+ tm_e = *localtime (&end);
+
+ 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);
+
+ return TRUE;
+}
+
+
/* This is called when the day begin & end times, the AM/PM flag, or the
week_starts_on_monday flags are changed.
FIXME: Which of these options do we want the new views to support? */