aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-18 07:48:05 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-18 07:48:05 +0800
commitd55901c052e7431d907f1db4aa243b79948c3f46 (patch)
treea7e6eeedf30f9a73d31029fef10773c72a7b46c1
parent4b926012c0cae01569d71d178dc651d9e4b2c8e8 (diff)
downloadgsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar.gz
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar.bz2
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar.lz
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar.xz
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.tar.zst
gsoc2013-evolution-d55901c052e7431d907f1db4aa243b79948c3f46.zip
Year view, double click -mig
svn path=/trunk/; revision=152
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/cal-util/calobj.c114
-rw-r--r--calendar/cal-util/calobj.h1
-rw-r--r--calendar/calendar.c4
-rw-r--r--calendar/calendar.h3
-rw-r--r--calendar/calobj.c114
-rw-r--r--calendar/calobj.h1
-rw-r--r--calendar/gncal-week-view.c2
-rw-r--r--calendar/gnome-cal.c18
-rw-r--r--calendar/gnome-cal.h1
-rw-r--r--calendar/gui/calendar.c4
-rw-r--r--calendar/gui/calendar.h3
-rw-r--r--calendar/gui/gncal-week-view.c2
-rw-r--r--calendar/gui/gnome-cal.c18
-rw-r--r--calendar/gui/gnome-cal.h1
-rw-r--r--calendar/gui/test.vcf132
-rw-r--r--calendar/gui/year-view.c24
-rw-r--r--calendar/pcs/calobj.c114
-rw-r--r--calendar/pcs/calobj.h1
-rw-r--r--calendar/test.vcf132
-rw-r--r--calendar/year-view.c24
21 files changed, 611 insertions, 112 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index f637e41c1e..58a01b187f 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,8 @@
+1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * gnome-cal.c (gnome_calendar_remove_object): Add support for
+ removing objects.
+
1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
* eventedit.c (ee_init_recurrence_page): New function that creates
@@ -8,6 +13,11 @@
* calobj.c (ical_object_generate_events): Implement
RECUR_MONTHLY_BY_POS implemented.
+ (ical_object_create_from_vobject): Fix the alarm
+ initialization code.
+ (save_alarm): Save alarms.
+ (ical_object_generate_events): Fixed the recurrent code to take
+ into account the recur->endate field (if at all specified).
(ical_object_to_vobject): Implement recurrence rule saving.
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 73406b9a5f..7878df7aa8 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
/* Compute the enddate */
if (o->recur->_enddate == 0){
- printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
if (o->recur->duration != 0){
ical_object_compute_end (o);
} else
o->recur->enddate = 0;
} else {
- printf ("El evento termina\n");
o->recur->enddate = o->recur->_enddate;
}
return 1;
}
+/*
+ * FIXME: This is loosing precission. Enhanec the thresholds
+ */
+#define HOURS(n) (n*(60*60))
+
+static void
+setup_alarm_at (time_t base, CalendarAlarm *alarm, char *iso_time)
+{
+ time_t alarm_time = time_from_isodate (iso_time);
+ int d = difftime (base, alarm_time);
+
+ if (d > HOURS (2)){
+ if (d > HOURS (48)){
+ alarm->count = d / HOURS (24);
+ alarm->units = ALARM_DAYS;
+ } else {
+ alarm->count = d / 60*60;
+ alarm->units = ALARM_HOURS;
+ }
+ } else {
+ alarm->count = d / 60;
+ alarm->units = ALARM_MINUTES;
+ }
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* dalarm */
+ ical->dalarm.type = ALARM_DISPLAY;
+ ical->dalarm.enabled = 0;
if (has (o, VCDAlarmProp)){
- ical->dalarm.type = ALARM_DISPLAY;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->dalarm.enabled = 1;
- ical->dalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->dalarm, str_val (a));
free (the_str);
}
}
/* aalarm */
+ ical->aalarm.type = ALARM_AUDIO;
+ ical->aalarm.enabled = 0;
if (has (o, VCAAlarmProp)){
- ical->aalarm.type = ALARM_AUDIO;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->aalarm.enabled = 1;
- ical->aalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->aalarm, str_val (a));
free (the_str);
}
}
/* palarm */
+ ical->palarm.type = ALARM_PROGRAM;
+ ical->palarm.enabled = 0;
if (has (o, VCPAlarmProp)){
ical->palarm.type = ALARM_PROGRAM;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->palarm.enabled = 1;
- ical->palarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->palarm, str_val (a));
free (the_str);
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
@@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* malarm */
+ ical->malarm.type = ALARM_MAIL;
+ ical->malarm.enabled = 0;
if (has (o, VCMAlarmProp)){
ical->malarm.type = ALARM_MAIL;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->malarm.enabled = 1;
- ical->malarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->malarm, str_val (a));
free (the_str);
- if ((a = is_a_prop_of (o, VCProcedureNameProp))){
+ if ((a = is_a_prop_of (o, VCEmailAddressProp))){
ical->malarm.data = g_strdup (str_val (a));
free (the_str);
}
@@ -659,11 +688,45 @@ store_list (VObject *o, char *prop, GList *values, char sep)
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
+static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
+
+static VObject *
+save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
+{
+ VObject *alarm_object;
+ struct tm *tm;
+ time_t alarm_time;
+
+ if (!alarm->enabled)
+ return NULL;
+ tm = localtime (&ical->dtstart);
+ switch (alarm->units){
+ case ALARM_MINUTES:
+ tm->tm_min -= alarm->count;
+ break;
+
+ case ALARM_HOURS:
+ tm->tm_hour -= alarm->count;
+ break;
+
+ case ALARM_DAYS:
+ tm->tm_mday -= alarm->count;
+ break;
+ }
+
+ alarm_time = mktime (tm);
+ alarm_object = addProp (o, alarm_names [alarm->type]);
+ addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
+ addPropValue (alarm_object, VCRepeatCountProp, "1");
+ addPropValue (alarm_object, VCDisplayStringProp, "GNOME appointment alarm");
+
+ return alarm_object;
+}
VObject *
ical_object_to_vobject (iCalObject *ical)
{
- VObject *o;
+ VObject *o, *alarm;
GList *l;
if (ical->type == ICAL_EVENT)
@@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
else
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
strcat (result, buffer);
+ addPropValue (o, VCRRuleProp, result);
}
- /* FIXME: alarms */
+
+ save_alarm (o, &ical->aalarm, ical);
+ save_alarm (o, &ical->dalarm, ical);
+
+ if ((alarm = save_alarm (o, &ical->palarm, ical)))
+ addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
+ if ((alarm = save_alarm (o, &ical->malarm, ical)))
+ addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
return o;
}
@@ -830,6 +901,7 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
}
#define time_in_range(x,a,b) ((x >= a) && (b ? x <= b : 1))
+#define recur_in_range(t,r) (r->enddate ? (t < r->enddate) : 1)
/*
* Generate every possible event. Invokes the callback routine for
@@ -862,7 +934,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (end != 0){
if (ico->dtstart > end)
return;
- if (!IS_INFINITE (ico->recur) && recur->enddate < start)
+ if (!IS_INFINITE (recur) && recur->enddate < start)
return;
}
@@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
switch (recur->type){
case RECUR_DAILY:
do {
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (!generate (ico, current, cb, closure))
return;
}
@@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
do {
struct tm *tm = localtime (&current);
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (recur->weekday & (1 << tm->tm_wday))
if (!generate (ico, current, cb, closure))
return;
@@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_MONTHLY_BY_POS:
/* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0)
+ if (recur->u.month_pos < 0)
return;
- if (ico->recur->u.month_pos == 0)
+ if (recur->u.month_pos == 0)
return;
first_week_day = 7;
for (i = 6; i >= 0; i--)
- if (ico->recur->weekday & (1 << i))
+ if (recur->weekday & (1 << i))
first_week_day = i;
/* This should not happen, but take it into account */
@@ -936,13 +1008,13 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
tm = *localtime (&t);
week_day_start = tm.tm_wday;
- tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ tm.tm_mday = 7 * (recur->u.month_pos -
((week_day_start <= first_week_day ) ? 1 : 0)) -
(week_day_start - first_week_day) + 1;
t = mktime (&tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
p = tm->tm_mday;
tm->tm_mday = recur->u.month_day;
t = mktime (tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -986,7 +1058,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_YEARLY_BY_MONTH:
case RECUR_YEARLY_BY_DAY:
do {
- if (time_in_range (current, start, end))
+ if (time_in_range (current, start, end) && recur_in_range (current, recur))
if (!generate (ico, current, cb, closure))
return;
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 48b3012695..26b0acf35b 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -32,7 +32,6 @@ typedef struct {
int count;
enum AlarmUnit units;
char *data;
- time_t time;
/* Widgets */
void *w_count; /* A GtkEntry */
diff --git a/calendar/calendar.c b/calendar/calendar.c
index 641d6d765e..be45bb04bb 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -35,8 +35,6 @@ calendar_add_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_prepend (cal->events, obj);
- if (obj->recur)
- cal->recur = g_list_prepend (cal->recur, obj);
break;
case ICAL_TODO:
@@ -61,8 +59,6 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_remove (cal->events, obj);
- if (obj->recur)
- cal->recur = g_list_remove (cal->recur, obj);
break;
case ICAL_TODO:
diff --git a/calendar/calendar.h b/calendar/calendar.h
index e68b74ebf4..94b471d3da 100644
--- a/calendar/calendar.h
+++ b/calendar/calendar.h
@@ -17,9 +17,6 @@ typedef struct {
GList *todo;
GList *journal;
- /* Events that have a recurrence field are also present here */
- GList *recur;
-
/* Time at which the calendar was created */
time_t created;
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 73406b9a5f..7878df7aa8 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
/* Compute the enddate */
if (o->recur->_enddate == 0){
- printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
if (o->recur->duration != 0){
ical_object_compute_end (o);
} else
o->recur->enddate = 0;
} else {
- printf ("El evento termina\n");
o->recur->enddate = o->recur->_enddate;
}
return 1;
}
+/*
+ * FIXME: This is loosing precission. Enhanec the thresholds
+ */
+#define HOURS(n) (n*(60*60))
+
+static void
+setup_alarm_at (time_t base, CalendarAlarm *alarm, char *iso_time)
+{
+ time_t alarm_time = time_from_isodate (iso_time);
+ int d = difftime (base, alarm_time);
+
+ if (d > HOURS (2)){
+ if (d > HOURS (48)){
+ alarm->count = d / HOURS (24);
+ alarm->units = ALARM_DAYS;
+ } else {
+ alarm->count = d / 60*60;
+ alarm->units = ALARM_HOURS;
+ }
+ } else {
+ alarm->count = d / 60;
+ alarm->units = ALARM_MINUTES;
+ }
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* dalarm */
+ ical->dalarm.type = ALARM_DISPLAY;
+ ical->dalarm.enabled = 0;
if (has (o, VCDAlarmProp)){
- ical->dalarm.type = ALARM_DISPLAY;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->dalarm.enabled = 1;
- ical->dalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->dalarm, str_val (a));
free (the_str);
}
}
/* aalarm */
+ ical->aalarm.type = ALARM_AUDIO;
+ ical->aalarm.enabled = 0;
if (has (o, VCAAlarmProp)){
- ical->aalarm.type = ALARM_AUDIO;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->aalarm.enabled = 1;
- ical->aalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->aalarm, str_val (a));
free (the_str);
}
}
/* palarm */
+ ical->palarm.type = ALARM_PROGRAM;
+ ical->palarm.enabled = 0;
if (has (o, VCPAlarmProp)){
ical->palarm.type = ALARM_PROGRAM;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->palarm.enabled = 1;
- ical->palarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->palarm, str_val (a));
free (the_str);
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
@@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* malarm */
+ ical->malarm.type = ALARM_MAIL;
+ ical->malarm.enabled = 0;
if (has (o, VCMAlarmProp)){
ical->malarm.type = ALARM_MAIL;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->malarm.enabled = 1;
- ical->malarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->malarm, str_val (a));
free (the_str);
- if ((a = is_a_prop_of (o, VCProcedureNameProp))){
+ if ((a = is_a_prop_of (o, VCEmailAddressProp))){
ical->malarm.data = g_strdup (str_val (a));
free (the_str);
}
@@ -659,11 +688,45 @@ store_list (VObject *o, char *prop, GList *values, char sep)
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
+static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
+
+static VObject *
+save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
+{
+ VObject *alarm_object;
+ struct tm *tm;
+ time_t alarm_time;
+
+ if (!alarm->enabled)
+ return NULL;
+ tm = localtime (&ical->dtstart);
+ switch (alarm->units){
+ case ALARM_MINUTES:
+ tm->tm_min -= alarm->count;
+ break;
+
+ case ALARM_HOURS:
+ tm->tm_hour -= alarm->count;
+ break;
+
+ case ALARM_DAYS:
+ tm->tm_mday -= alarm->count;
+ break;
+ }
+
+ alarm_time = mktime (tm);
+ alarm_object = addProp (o, alarm_names [alarm->type]);
+ addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
+ addPropValue (alarm_object, VCRepeatCountProp, "1");
+ addPropValue (alarm_object, VCDisplayStringProp, "GNOME appointment alarm");
+
+ return alarm_object;
+}
VObject *
ical_object_to_vobject (iCalObject *ical)
{
- VObject *o;
+ VObject *o, *alarm;
GList *l;
if (ical->type == ICAL_EVENT)
@@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
else
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
strcat (result, buffer);
+ addPropValue (o, VCRRuleProp, result);
}
- /* FIXME: alarms */
+
+ save_alarm (o, &ical->aalarm, ical);
+ save_alarm (o, &ical->dalarm, ical);
+
+ if ((alarm = save_alarm (o, &ical->palarm, ical)))
+ addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
+ if ((alarm = save_alarm (o, &ical->malarm, ical)))
+ addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
return o;
}
@@ -830,6 +901,7 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
}
#define time_in_range(x,a,b) ((x >= a) && (b ? x <= b : 1))
+#define recur_in_range(t,r) (r->enddate ? (t < r->enddate) : 1)
/*
* Generate every possible event. Invokes the callback routine for
@@ -862,7 +934,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (end != 0){
if (ico->dtstart > end)
return;
- if (!IS_INFINITE (ico->recur) && recur->enddate < start)
+ if (!IS_INFINITE (recur) && recur->enddate < start)
return;
}
@@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
switch (recur->type){
case RECUR_DAILY:
do {
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (!generate (ico, current, cb, closure))
return;
}
@@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
do {
struct tm *tm = localtime (&current);
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (recur->weekday & (1 << tm->tm_wday))
if (!generate (ico, current, cb, closure))
return;
@@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_MONTHLY_BY_POS:
/* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0)
+ if (recur->u.month_pos < 0)
return;
- if (ico->recur->u.month_pos == 0)
+ if (recur->u.month_pos == 0)
return;
first_week_day = 7;
for (i = 6; i >= 0; i--)
- if (ico->recur->weekday & (1 << i))
+ if (recur->weekday & (1 << i))
first_week_day = i;
/* This should not happen, but take it into account */
@@ -936,13 +1008,13 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
tm = *localtime (&t);
week_day_start = tm.tm_wday;
- tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ tm.tm_mday = 7 * (recur->u.month_pos -
((week_day_start <= first_week_day ) ? 1 : 0)) -
(week_day_start - first_week_day) + 1;
t = mktime (&tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
p = tm->tm_mday;
tm->tm_mday = recur->u.month_day;
t = mktime (tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -986,7 +1058,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_YEARLY_BY_MONTH:
case RECUR_YEARLY_BY_DAY:
do {
- if (time_in_range (current, start, end))
+ if (time_in_range (current, start, end) && recur_in_range (current, recur))
if (!generate (ico, current, cb, closure))
return;
diff --git a/calendar/calobj.h b/calendar/calobj.h
index 48b3012695..26b0acf35b 100644
--- a/calendar/calobj.h
+++ b/calendar/calobj.h
@@ -32,7 +32,6 @@ typedef struct {
int count;
enum AlarmUnit units;
char *data;
- time_t time;
/* Widgets */
void *w_count; /* A GtkEntry */
diff --git a/calendar/gncal-week-view.c b/calendar/gncal-week-view.c
index e391c80344..59252baa0c 100644
--- a/calendar/gncal-week-view.c
+++ b/calendar/gncal-week-view.c
@@ -159,8 +159,6 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
tm.tm_mday++;
day_end = mktime (&tm);
- printf ("Boundary: ");
- print_time_t (day_start);
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
day_start = day_end;
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 14c9a53975..862c659d83 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -91,7 +91,7 @@ setup_widgets (GnomeCalendar *gcal)
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view_container, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo")));
+/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
gtk_widget_show_all (gcal->notebook);
@@ -166,6 +166,13 @@ gnome_calendar_previous (GnomeCalendar *gcal)
gnome_calendar_direction (gcal, -1);
}
+void
+gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
+{
+ gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
+ gnome_calendar_goto (gcal, time);
+}
+
GtkWidget *
gnome_calendar_new (char *title)
{
@@ -210,13 +217,18 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
{
- printf ("Adding object at: ");
- print_time_t (obj->dtstart);
calendar_add_object (gcal->cal, obj);
gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
}
void
+gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
+{
+ calendar_remove_object (gcal->cal, obj);
+ gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
+}
+
+void
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
{
g_return_if_fail (gcal != NULL);
diff --git a/calendar/gnome-cal.h b/calendar/gnome-cal.h
index 96567ab722..71c5c386c8 100644
--- a/calendar/gnome-cal.h
+++ b/calendar/gnome-cal.h
@@ -44,6 +44,7 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_next (GnomeCalendar *gcal);
void gnome_calendar_previous (GnomeCalendar *gcal);
void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
+void gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time);
/* Flags is a bitmask of CalObjectChange values */
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 641d6d765e..be45bb04bb 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -35,8 +35,6 @@ calendar_add_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_prepend (cal->events, obj);
- if (obj->recur)
- cal->recur = g_list_prepend (cal->recur, obj);
break;
case ICAL_TODO:
@@ -61,8 +59,6 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_remove (cal->events, obj);
- if (obj->recur)
- cal->recur = g_list_remove (cal->recur, obj);
break;
case ICAL_TODO:
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index e68b74ebf4..94b471d3da 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -17,9 +17,6 @@ typedef struct {
GList *todo;
GList *journal;
- /* Events that have a recurrence field are also present here */
- GList *recur;
-
/* Time at which the calendar was created */
time_t created;
diff --git a/calendar/gui/gncal-week-view.c b/calendar/gui/gncal-week-view.c
index e391c80344..59252baa0c 100644
--- a/calendar/gui/gncal-week-view.c
+++ b/calendar/gui/gncal-week-view.c
@@ -159,8 +159,6 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
tm.tm_mday++;
day_end = mktime (&tm);
- printf ("Boundary: ");
- print_time_t (day_start);
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
day_start = day_end;
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 14c9a53975..862c659d83 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -91,7 +91,7 @@ setup_widgets (GnomeCalendar *gcal)
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->day_view_container, gtk_label_new (_("Day View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->week_view, gtk_label_new (_("Week View")));
gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->year_view, gtk_label_new (_("Year View")));
- gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo")));
+/* gtk_notebook_append_page (GTK_NOTEBOOK (gcal->notebook), gcal->task_view, gtk_label_new (_("Todo"))); */
gtk_widget_show_all (gcal->notebook);
@@ -166,6 +166,13 @@ gnome_calendar_previous (GnomeCalendar *gcal)
gnome_calendar_direction (gcal, -1);
}
+void
+gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time)
+{
+ gtk_notebook_set_page (GTK_NOTEBOOK (gcal->notebook), 0);
+ gnome_calendar_goto (gcal, time);
+}
+
GtkWidget *
gnome_calendar_new (char *title)
{
@@ -210,13 +217,18 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
{
- printf ("Adding object at: ");
- print_time_t (obj->dtstart);
calendar_add_object (gcal->cal, obj);
gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
}
void
+gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
+{
+ calendar_remove_object (gcal->cal, obj);
+ gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
+}
+
+void
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
{
g_return_if_fail (gcal != NULL);
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index 96567ab722..71c5c386c8 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -44,6 +44,7 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
void gnome_calendar_next (GnomeCalendar *gcal);
void gnome_calendar_previous (GnomeCalendar *gcal);
void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
+void gnome_calendar_dayjump (GnomeCalendar *gcal, time_t time);
/* Flags is a bitmask of CalObjectChange values */
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf
index ed6aedb8ac..f2910c50d8 100644
--- a/calendar/gui/test.vcf
+++ b/calendar/gui/test.vcf
@@ -8,19 +8,143 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980401T116000
-DTEND:19980401T119000
-SUMMARY:Primer miercoles, 4 meses
+DTSTART:19980415T003000
+DTEND:19980415T010000
+SUMMARY: Semana: Mi, Ju, Vi, Dom (10 veces)
STATUS:NEEDS ACTION
CLASS:PUBLIC
PRIORITY:0
TRANSP:0
-RRULE:MP1 1+ WE # 4
+RRULE:W1 WE TH FR SU #10
RELATED-TO:0
X-PILOTID:0
X-PILOTSTAT:0
END:VEVENT
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T006000
+DTEND:19980415T009000
+SUMMARY:Diario durante 5 dias
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:D1 #5
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T116000
+DTEND:19980415T119000
+SUMMARY:Semanal -- 4 semanas
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:W1 #4
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T006000
+DTEND:19980415T009000
+SUMMARY:Diario durante 5 dias
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:D1 #5
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980415T140000
+DTEND:19980415T160000
+SUMMARY:Normal
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980501T140000
+DTEND:19980501T140000
+RRULE:D1 19980601T140000
+SUMMARY:Diariamente de 05/01 al 06/01
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980501T140000
+DTEND:19980501T140000
+RRULE:D1 #5
+SUMMARY:5 dias.
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980601T150000
+DTEND:19980601T150000
+RRULE:D2 19980701T140000
+SUMMARY:Cada dos dias de 06/01 al 07/01
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
END:VCALENDAR
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index a922ac2748..5376826239 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -15,9 +15,20 @@
static void gncal_year_view_init (GncalYearView *yview);
static void
-double_click(GtkWidget *widget, gpointer data)
+double_click(GtkCalendar *gc, GncalYearView *yview)
{
- printf("Recieved double click.\n");
+ struct tm tm;
+ time_t t;
+
+ tm.tm_mday = gc->selected_day;
+ tm.tm_mon = gc->month;
+ tm.tm_year = gc->year;
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ t = mktime (&tm);
+
+ gnome_calendar_dayjump (yview->gcal, t);
}
static void
@@ -189,6 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
for (i = 0; i < 12; i++) {
gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
+ gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
}
year_begin = time_year_begin (yview->year);
@@ -197,7 +209,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
l = calendar_get_events_in_range (yview->gcal->cal, year_begin, year_end);
for (; l; l = l->next){
CalendarObject *co = l->data;
-
+
year_view_mark_day (co->ico, co->ev_start, co->ev_end, yview);
}
calendar_destroy_event_list (l);
@@ -221,10 +233,8 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
/* If only the summary changed, we dont care */
- if ((flags & CHANGE_SUMMARY) == flags)
+ if (flags && (flags & CHANGE_SUMMARY) == flags)
return;
- printf ("MARCANDO!\n");
- if (flags & CHANGE_NEW)
- gncal_year_view_set_year (yview, yview->year);
+ gncal_year_view_set_year (yview, yview->year);
}
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 73406b9a5f..7878df7aa8 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
/* Compute the enddate */
if (o->recur->_enddate == 0){
- printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
if (o->recur->duration != 0){
ical_object_compute_end (o);
} else
o->recur->enddate = 0;
} else {
- printf ("El evento termina\n");
o->recur->enddate = o->recur->_enddate;
}
return 1;
}
+/*
+ * FIXME: This is loosing precission. Enhanec the thresholds
+ */
+#define HOURS(n) (n*(60*60))
+
+static void
+setup_alarm_at (time_t base, CalendarAlarm *alarm, char *iso_time)
+{
+ time_t alarm_time = time_from_isodate (iso_time);
+ int d = difftime (base, alarm_time);
+
+ if (d > HOURS (2)){
+ if (d > HOURS (48)){
+ alarm->count = d / HOURS (24);
+ alarm->units = ALARM_DAYS;
+ } else {
+ alarm->count = d / 60*60;
+ alarm->units = ALARM_HOURS;
+ }
+ } else {
+ alarm->count = d / 60;
+ alarm->units = ALARM_MINUTES;
+ }
+}
+
#define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
@@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* dalarm */
+ ical->dalarm.type = ALARM_DISPLAY;
+ ical->dalarm.enabled = 0;
if (has (o, VCDAlarmProp)){
- ical->dalarm.type = ALARM_DISPLAY;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->dalarm.enabled = 1;
- ical->dalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->dalarm, str_val (a));
free (the_str);
}
}
/* aalarm */
+ ical->aalarm.type = ALARM_AUDIO;
+ ical->aalarm.enabled = 0;
if (has (o, VCAAlarmProp)){
- ical->aalarm.type = ALARM_AUDIO;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->aalarm.enabled = 1;
- ical->aalarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->aalarm, str_val (a));
free (the_str);
}
}
/* palarm */
+ ical->palarm.type = ALARM_PROGRAM;
+ ical->palarm.enabled = 0;
if (has (o, VCPAlarmProp)){
ical->palarm.type = ALARM_PROGRAM;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->palarm.enabled = 1;
- ical->palarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->palarm, str_val (a));
free (the_str);
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
@@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* malarm */
+ ical->malarm.type = ALARM_MAIL;
+ ical->malarm.enabled = 0;
if (has (o, VCMAlarmProp)){
ical->malarm.type = ALARM_MAIL;
if ((a = is_a_prop_of (o, VCRunTimeProp))){
ical->malarm.enabled = 1;
- ical->malarm.time = time_from_isodate (str_val (a));
+ setup_alarm_at (ical->dtstart, &ical->malarm, str_val (a));
free (the_str);
- if ((a = is_a_prop_of (o, VCProcedureNameProp))){
+ if ((a = is_a_prop_of (o, VCEmailAddressProp))){
ical->malarm.data = g_strdup (str_val (a));
free (the_str);
}
@@ -659,11 +688,45 @@ store_list (VObject *o, char *prop, GList *values, char sep)
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
+static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
+
+static VObject *
+save_alarm (VObject *o, CalendarAlarm *alarm, iCalObject *ical)
+{
+ VObject *alarm_object;
+ struct tm *tm;
+ time_t alarm_time;
+
+ if (!alarm->enabled)
+ return NULL;
+ tm = localtime (&ical->dtstart);
+ switch (alarm->units){
+ case ALARM_MINUTES:
+ tm->tm_min -= alarm->count;
+ break;
+
+ case ALARM_HOURS:
+ tm->tm_hour -= alarm->count;
+ break;
+
+ case ALARM_DAYS:
+ tm->tm_mday -= alarm->count;
+ break;
+ }
+
+ alarm_time = mktime (tm);
+ alarm_object = addProp (o, alarm_names [alarm->type]);
+ addPropValue (alarm_object, VCRunTimeProp, isodate_from_time_t (alarm_time));
+ addPropValue (alarm_object, VCRepeatCountProp, "1");
+ addPropValue (alarm_object, VCDisplayStringProp, "GNOME appointment alarm");
+
+ return alarm_object;
+}
VObject *
ical_object_to_vobject (iCalObject *ical)
{
- VObject *o;
+ VObject *o, *alarm;
GList *l;
if (ical->type == ICAL_EVENT)
@@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
else
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
strcat (result, buffer);
+ addPropValue (o, VCRRuleProp, result);
}
- /* FIXME: alarms */
+
+ save_alarm (o, &ical->aalarm, ical);
+ save_alarm (o, &ical->dalarm, ical);
+
+ if ((alarm = save_alarm (o, &ical->palarm, ical)))
+ addPropValue (alarm, VCProcedureNameProp, ical->palarm.data);
+ if ((alarm = save_alarm (o, &ical->malarm, ical)))
+ addPropValue (alarm, VCEmailAddressProp, ical->malarm.data);
return o;
}
@@ -830,6 +901,7 @@ generate (iCalObject *ico, time_t reference, calendarfn cb, void *closure)
}
#define time_in_range(x,a,b) ((x >= a) && (b ? x <= b : 1))
+#define recur_in_range(t,r) (r->enddate ? (t < r->enddate) : 1)
/*
* Generate every possible event. Invokes the callback routine for
@@ -862,7 +934,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
if (end != 0){
if (ico->dtstart > end)
return;
- if (!IS_INFINITE (ico->recur) && recur->enddate < start)
+ if (!IS_INFINITE (recur) && recur->enddate < start)
return;
}
@@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
switch (recur->type){
case RECUR_DAILY:
do {
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (!generate (ico, current, cb, closure))
return;
}
@@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
do {
struct tm *tm = localtime (&current);
- if (time_in_range (current, start, end)){
+ if (time_in_range (current, start, end) && recur_in_range (current, recur)){
if (recur->weekday & (1 << tm->tm_wday))
if (!generate (ico, current, cb, closure))
return;
@@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_MONTHLY_BY_POS:
/* FIXME: We only deal with positives now */
- if (ico->recur->u.month_pos < 0)
+ if (recur->u.month_pos < 0)
return;
- if (ico->recur->u.month_pos == 0)
+ if (recur->u.month_pos == 0)
return;
first_week_day = 7;
for (i = 6; i >= 0; i--)
- if (ico->recur->weekday & (1 << i))
+ if (recur->weekday & (1 << i))
first_week_day = i;
/* This should not happen, but take it into account */
@@ -936,13 +1008,13 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
tm = *localtime (&t);
week_day_start = tm.tm_wday;
- tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ tm.tm_mday = 7 * (recur->u.month_pos -
((week_day_start <= first_week_day ) ? 1 : 0)) -
(week_day_start - first_week_day) + 1;
t = mktime (&tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
p = tm->tm_mday;
tm->tm_mday = recur->u.month_day;
t = mktime (tm);
- if (time_in_range (t, start, end))
+ if (time_in_range (t, start, end) && recur_in_range (current, recur))
if (!generate (ico, t, cb, closure))
return;
@@ -986,7 +1058,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
case RECUR_YEARLY_BY_MONTH:
case RECUR_YEARLY_BY_DAY:
do {
- if (time_in_range (current, start, end))
+ if (time_in_range (current, start, end) && recur_in_range (current, recur))
if (!generate (ico, current, cb, closure))
return;
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
index 48b3012695..26b0acf35b 100644
--- a/calendar/pcs/calobj.h
+++ b/calendar/pcs/calobj.h
@@ -32,7 +32,6 @@ typedef struct {
int count;
enum AlarmUnit units;
char *data;
- time_t time;
/* Widgets */
void *w_count; /* A GtkEntry */
diff --git a/calendar/test.vcf b/calendar/test.vcf
index ed6aedb8ac..f2910c50d8 100644
--- a/calendar/test.vcf
+++ b/calendar/test.vcf
@@ -8,19 +8,143 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980401T116000
-DTEND:19980401T119000
-SUMMARY:Primer miercoles, 4 meses
+DTSTART:19980415T003000
+DTEND:19980415T010000
+SUMMARY: Semana: Mi, Ju, Vi, Dom (10 veces)
STATUS:NEEDS ACTION
CLASS:PUBLIC
PRIORITY:0
TRANSP:0
-RRULE:MP1 1+ WE # 4
+RRULE:W1 WE TH FR SU #10
RELATED-TO:0
X-PILOTID:0
X-PILOTSTAT:0
END:VEVENT
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T006000
+DTEND:19980415T009000
+SUMMARY:Diario durante 5 dias
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:D1 #5
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T116000
+DTEND:19980415T119000
+SUMMARY:Semanal -- 4 semanas
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:W1 #4
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023552
+UID:KOrganizer - 1804289383
+SEQUENCE:1
+LAST-MODIFIED:19980330T225948
+DTSTART:19980415T006000
+DTEND:19980415T009000
+SUMMARY:Diario durante 5 dias
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RRULE:D1 #5
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980415T140000
+DTEND:19980415T160000
+SUMMARY:Normal
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980501T140000
+DTEND:19980501T140000
+RRULE:D1 19980601T140000
+SUMMARY:Diariamente de 05/01 al 06/01
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980501T140000
+DTEND:19980501T140000
+RRULE:D1 #5
+SUMMARY:5 dias.
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
+
+BEGIN:VEVENT
+DCREATED:19980402T023558
+UID:KOrganizer - 846930886
+SEQUENCE:1
+LAST-MODIFIED:19980402T023558
+DTSTART:19980601T150000
+DTEND:19980601T150000
+RRULE:D2 19980701T140000
+SUMMARY:Cada dos dias de 06/01 al 07/01
+STATUS:NEEDS ACTION
+CLASS:PUBLIC
+PRIORITY:0
+TRANSP:0
+RELATED-TO:0
+X-PILOTID:0
+X-PILOTSTAT:0
+END:VEVENT
END:VCALENDAR
diff --git a/calendar/year-view.c b/calendar/year-view.c
index a922ac2748..5376826239 100644
--- a/calendar/year-view.c
+++ b/calendar/year-view.c
@@ -15,9 +15,20 @@
static void gncal_year_view_init (GncalYearView *yview);
static void
-double_click(GtkWidget *widget, gpointer data)
+double_click(GtkCalendar *gc, GncalYearView *yview)
{
- printf("Recieved double click.\n");
+ struct tm tm;
+ time_t t;
+
+ tm.tm_mday = gc->selected_day;
+ tm.tm_mon = gc->month;
+ tm.tm_year = gc->year;
+ tm.tm_hour = 0;
+ tm.tm_min = 0;
+ tm.tm_sec = 0;
+ t = mktime (&tm);
+
+ gnome_calendar_dayjump (yview->gcal, t);
}
static void
@@ -189,6 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
for (i = 0; i < 12; i++) {
gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
+ gtk_calendar_clear_marks (GTK_CALENDAR (yview->calendar[i]));
}
year_begin = time_year_begin (yview->year);
@@ -197,7 +209,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
l = calendar_get_events_in_range (yview->gcal->cal, year_begin, year_end);
for (; l; l = l->next){
CalendarObject *co = l->data;
-
+
year_view_mark_day (co->ico, co->ev_start, co->ev_end, yview);
}
calendar_destroy_event_list (l);
@@ -221,10 +233,8 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
/* If only the summary changed, we dont care */
- if ((flags & CHANGE_SUMMARY) == flags)
+ if (flags && (flags & CHANGE_SUMMARY) == flags)
return;
- printf ("MARCANDO!\n");
- if (flags & CHANGE_NEW)
- gncal_year_view_set_year (yview, yview->year);
+ gncal_year_view_set_year (yview, yview->year);
}