aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gnome-cal.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-30 06:19:39 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-30 06:19:39 +0800
commit5c1c9710338cb7f3b29ed1eac1006bb95f39c048 (patch)
treedacbe29633e17a82ac619ea4c0a2fd67a650d56d /calendar/gnome-cal.c
parentb14e3c892ce8feac4e72ab80800fb7b6e0408002 (diff)
downloadgsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.gz
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.bz2
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.lz
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.xz
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.tar.zst
gsoc2013-evolution-5c1c9710338cb7f3b29ed1eac1006bb95f39c048.zip
Various fixes and optimizations; Tagging of the days with appointements.
Various fixes and optimizations; Tagging of the days with appointements. the 1969 bug is gone. Really. Miguel. svn path=/trunk/; revision=201
Diffstat (limited to 'calendar/gnome-cal.c')
-rw-r--r--calendar/gnome-cal.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index d37d4156a8..e4312e9341 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -275,7 +275,7 @@ mail_notify (char *mail_address, char *text, time_t app_time)
pid = fork ();
if (pid == 0){
const int top = max_open_files ();
- int dev_null, i;
+ int dev_null;
dev_null = open ("/dev/null", O_RDWR);
dup2 (p [0], 0);
@@ -329,3 +329,54 @@ calendar_notify (time_t time, 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;
+ int days, day;
+
+ tm_s = localtime (&start);
+ days = difftime (end, start) / (60*60*24);
+
+ for (day = 0; day <= days; day++){
+ time_t new = mktime (tm_s);
+ struct tm *tm_day;
+
+ tm_day = localtime (&new);
+ gtk_calendar_mark_day (gtk_cal, tm_day->tm_mday);
+ tm_s->tm_mday++;
+ }
+ return TRUE;
+}
+
+/*
+ * Tags the dates with appointments in a GtkCalendar based on the
+ * GnomeCalendar contents
+ */
+void
+gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
+{
+ time_t month_begin, month_end;
+ struct tm tm;
+ GList *l;
+
+ /* compute month_begin */
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ tm.tm_mday = 0;
+ tm.tm_mon = gtk_cal->month;
+ tm.tm_year = gtk_cal->year - 1900;
+ tm.tm_isdst= -1;
+
+ month_begin = mktime (&tm);
+ tm.tm_mon++;
+ month_end = mktime (&tm);
+
+ gtk_calendar_clear_marks (gtk_cal);
+ calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
+}