Year view, double click -mig
svn path=/trunk/; revision=152
This commit is contained in:
@ -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>
|
1998-04-17 Federico Mena Quintero <federico@nuclecu.unam.mx>
|
||||||
|
|
||||||
* eventedit.c (ee_init_recurrence_page): New function that creates
|
* eventedit.c (ee_init_recurrence_page): New function that creates
|
||||||
@ -8,6 +13,11 @@
|
|||||||
|
|
||||||
* calobj.c (ical_object_generate_events): Implement
|
* calobj.c (ical_object_generate_events): Implement
|
||||||
RECUR_MONTHLY_BY_POS implemented.
|
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.
|
(ical_object_to_vobject): Implement recurrence rule saving.
|
||||||
|
|
||||||
|
@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
|
|||||||
|
|
||||||
/* Compute the enddate */
|
/* Compute the enddate */
|
||||||
if (o->recur->_enddate == 0){
|
if (o->recur->_enddate == 0){
|
||||||
printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
|
|
||||||
if (o->recur->duration != 0){
|
if (o->recur->duration != 0){
|
||||||
ical_object_compute_end (o);
|
ical_object_compute_end (o);
|
||||||
} else
|
} else
|
||||||
o->recur->enddate = 0;
|
o->recur->enddate = 0;
|
||||||
} else {
|
} else {
|
||||||
printf ("El evento termina\n");
|
|
||||||
o->recur->enddate = o->recur->_enddate;
|
o->recur->enddate = o->recur->_enddate;
|
||||||
}
|
}
|
||||||
return 1;
|
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 is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
|
||||||
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
||||||
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
||||||
@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dalarm */
|
/* dalarm */
|
||||||
if (has (o, VCDAlarmProp)){
|
|
||||||
ical->dalarm.type = ALARM_DISPLAY;
|
ical->dalarm.type = ALARM_DISPLAY;
|
||||||
|
ical->dalarm.enabled = 0;
|
||||||
|
if (has (o, VCDAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->dalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* aalarm */
|
/* aalarm */
|
||||||
if (has (o, VCAAlarmProp)){
|
|
||||||
ical->aalarm.type = ALARM_AUDIO;
|
ical->aalarm.type = ALARM_AUDIO;
|
||||||
|
ical->aalarm.enabled = 0;
|
||||||
|
if (has (o, VCAAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->aalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* palarm */
|
/* palarm */
|
||||||
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
|
ical->palarm.enabled = 0;
|
||||||
if (has (o, VCPAlarmProp)){
|
if (has (o, VCPAlarmProp)){
|
||||||
ical->palarm.type = ALARM_PROGRAM;
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->palarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
|
|
||||||
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
||||||
@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* malarm */
|
/* malarm */
|
||||||
|
ical->malarm.type = ALARM_MAIL;
|
||||||
|
ical->malarm.enabled = 0;
|
||||||
if (has (o, VCMAlarmProp)){
|
if (has (o, VCMAlarmProp)){
|
||||||
ical->malarm.type = ALARM_MAIL;
|
ical->malarm.type = ALARM_MAIL;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->malarm.enabled = 1;
|
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);
|
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));
|
ical->malarm.data = g_strdup (str_val (a));
|
||||||
free (the_str);
|
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_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
|
||||||
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
|
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 *
|
VObject *
|
||||||
ical_object_to_vobject (iCalObject *ical)
|
ical_object_to_vobject (iCalObject *ical)
|
||||||
{
|
{
|
||||||
VObject *o;
|
VObject *o, *alarm;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
if (ical->type == ICAL_EVENT)
|
if (ical->type == ICAL_EVENT)
|
||||||
@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
|
|||||||
else
|
else
|
||||||
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
||||||
strcat (result, buffer);
|
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;
|
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 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
|
* 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 (end != 0){
|
||||||
if (ico->dtstart > end)
|
if (ico->dtstart > end)
|
||||||
return;
|
return;
|
||||||
if (!IS_INFINITE (ico->recur) && recur->enddate < start)
|
if (!IS_INFINITE (recur) && recur->enddate < start)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
switch (recur->type){
|
switch (recur->type){
|
||||||
case RECUR_DAILY:
|
case RECUR_DAILY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
do {
|
do {
|
||||||
struct tm *tm = localtime (¤t);
|
struct tm *tm = localtime (¤t);
|
||||||
|
|
||||||
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 (recur->weekday & (1 << tm->tm_wday))
|
||||||
if (!generate (ico, current, cb, closure))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
|
|
||||||
case RECUR_MONTHLY_BY_POS:
|
case RECUR_MONTHLY_BY_POS:
|
||||||
/* FIXME: We only deal with positives now */
|
/* FIXME: We only deal with positives now */
|
||||||
if (ico->recur->u.month_pos < 0)
|
if (recur->u.month_pos < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ico->recur->u.month_pos == 0)
|
if (recur->u.month_pos == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
first_week_day = 7;
|
first_week_day = 7;
|
||||||
for (i = 6; i >= 0; i--)
|
for (i = 6; i >= 0; i--)
|
||||||
if (ico->recur->weekday & (1 << i))
|
if (recur->weekday & (1 << i))
|
||||||
first_week_day = i;
|
first_week_day = i;
|
||||||
|
|
||||||
/* This should not happen, but take it into account */
|
/* 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);
|
tm = *localtime (&t);
|
||||||
week_day_start = tm.tm_wday;
|
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 : 0)) -
|
||||||
(week_day_start - first_week_day) + 1;
|
(week_day_start - first_week_day) + 1;
|
||||||
|
|
||||||
t = mktime (&tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
p = tm->tm_mday;
|
p = tm->tm_mday;
|
||||||
tm->tm_mday = recur->u.month_day;
|
tm->tm_mday = recur->u.month_day;
|
||||||
t = mktime (tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
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_MONTH:
|
||||||
case RECUR_YEARLY_BY_DAY:
|
case RECUR_YEARLY_BY_DAY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ typedef struct {
|
|||||||
int count;
|
int count;
|
||||||
enum AlarmUnit units;
|
enum AlarmUnit units;
|
||||||
char *data;
|
char *data;
|
||||||
time_t time;
|
|
||||||
|
|
||||||
/* Widgets */
|
/* Widgets */
|
||||||
void *w_count; /* A GtkEntry */
|
void *w_count; /* A GtkEntry */
|
||||||
|
@ -35,8 +35,6 @@ calendar_add_object (Calendar *cal, iCalObject *obj)
|
|||||||
switch (obj->type){
|
switch (obj->type){
|
||||||
case ICAL_EVENT:
|
case ICAL_EVENT:
|
||||||
cal->events = g_list_prepend (cal->events, obj);
|
cal->events = g_list_prepend (cal->events, obj);
|
||||||
if (obj->recur)
|
|
||||||
cal->recur = g_list_prepend (cal->recur, obj);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICAL_TODO:
|
case ICAL_TODO:
|
||||||
@ -61,8 +59,6 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
|
|||||||
switch (obj->type){
|
switch (obj->type){
|
||||||
case ICAL_EVENT:
|
case ICAL_EVENT:
|
||||||
cal->events = g_list_remove (cal->events, obj);
|
cal->events = g_list_remove (cal->events, obj);
|
||||||
if (obj->recur)
|
|
||||||
cal->recur = g_list_remove (cal->recur, obj);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICAL_TODO:
|
case ICAL_TODO:
|
||||||
|
@ -17,9 +17,6 @@ typedef struct {
|
|||||||
GList *todo;
|
GList *todo;
|
||||||
GList *journal;
|
GList *journal;
|
||||||
|
|
||||||
/* Events that have a recurrence field are also present here */
|
|
||||||
GList *recur;
|
|
||||||
|
|
||||||
/* Time at which the calendar was created */
|
/* Time at which the calendar was created */
|
||||||
time_t created;
|
time_t created;
|
||||||
|
|
||||||
|
@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
|
|||||||
|
|
||||||
/* Compute the enddate */
|
/* Compute the enddate */
|
||||||
if (o->recur->_enddate == 0){
|
if (o->recur->_enddate == 0){
|
||||||
printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
|
|
||||||
if (o->recur->duration != 0){
|
if (o->recur->duration != 0){
|
||||||
ical_object_compute_end (o);
|
ical_object_compute_end (o);
|
||||||
} else
|
} else
|
||||||
o->recur->enddate = 0;
|
o->recur->enddate = 0;
|
||||||
} else {
|
} else {
|
||||||
printf ("El evento termina\n");
|
|
||||||
o->recur->enddate = o->recur->_enddate;
|
o->recur->enddate = o->recur->_enddate;
|
||||||
}
|
}
|
||||||
return 1;
|
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 is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
|
||||||
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
||||||
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
||||||
@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dalarm */
|
/* dalarm */
|
||||||
if (has (o, VCDAlarmProp)){
|
|
||||||
ical->dalarm.type = ALARM_DISPLAY;
|
ical->dalarm.type = ALARM_DISPLAY;
|
||||||
|
ical->dalarm.enabled = 0;
|
||||||
|
if (has (o, VCDAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->dalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* aalarm */
|
/* aalarm */
|
||||||
if (has (o, VCAAlarmProp)){
|
|
||||||
ical->aalarm.type = ALARM_AUDIO;
|
ical->aalarm.type = ALARM_AUDIO;
|
||||||
|
ical->aalarm.enabled = 0;
|
||||||
|
if (has (o, VCAAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->aalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* palarm */
|
/* palarm */
|
||||||
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
|
ical->palarm.enabled = 0;
|
||||||
if (has (o, VCPAlarmProp)){
|
if (has (o, VCPAlarmProp)){
|
||||||
ical->palarm.type = ALARM_PROGRAM;
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->palarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
|
|
||||||
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
||||||
@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* malarm */
|
/* malarm */
|
||||||
|
ical->malarm.type = ALARM_MAIL;
|
||||||
|
ical->malarm.enabled = 0;
|
||||||
if (has (o, VCMAlarmProp)){
|
if (has (o, VCMAlarmProp)){
|
||||||
ical->malarm.type = ALARM_MAIL;
|
ical->malarm.type = ALARM_MAIL;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->malarm.enabled = 1;
|
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);
|
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));
|
ical->malarm.data = g_strdup (str_val (a));
|
||||||
free (the_str);
|
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_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
|
||||||
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
|
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 *
|
VObject *
|
||||||
ical_object_to_vobject (iCalObject *ical)
|
ical_object_to_vobject (iCalObject *ical)
|
||||||
{
|
{
|
||||||
VObject *o;
|
VObject *o, *alarm;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
if (ical->type == ICAL_EVENT)
|
if (ical->type == ICAL_EVENT)
|
||||||
@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
|
|||||||
else
|
else
|
||||||
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
||||||
strcat (result, buffer);
|
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;
|
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 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
|
* 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 (end != 0){
|
||||||
if (ico->dtstart > end)
|
if (ico->dtstart > end)
|
||||||
return;
|
return;
|
||||||
if (!IS_INFINITE (ico->recur) && recur->enddate < start)
|
if (!IS_INFINITE (recur) && recur->enddate < start)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
switch (recur->type){
|
switch (recur->type){
|
||||||
case RECUR_DAILY:
|
case RECUR_DAILY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
do {
|
do {
|
||||||
struct tm *tm = localtime (¤t);
|
struct tm *tm = localtime (¤t);
|
||||||
|
|
||||||
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 (recur->weekday & (1 << tm->tm_wday))
|
||||||
if (!generate (ico, current, cb, closure))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
|
|
||||||
case RECUR_MONTHLY_BY_POS:
|
case RECUR_MONTHLY_BY_POS:
|
||||||
/* FIXME: We only deal with positives now */
|
/* FIXME: We only deal with positives now */
|
||||||
if (ico->recur->u.month_pos < 0)
|
if (recur->u.month_pos < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ico->recur->u.month_pos == 0)
|
if (recur->u.month_pos == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
first_week_day = 7;
|
first_week_day = 7;
|
||||||
for (i = 6; i >= 0; i--)
|
for (i = 6; i >= 0; i--)
|
||||||
if (ico->recur->weekday & (1 << i))
|
if (recur->weekday & (1 << i))
|
||||||
first_week_day = i;
|
first_week_day = i;
|
||||||
|
|
||||||
/* This should not happen, but take it into account */
|
/* 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);
|
tm = *localtime (&t);
|
||||||
week_day_start = tm.tm_wday;
|
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 : 0)) -
|
||||||
(week_day_start - first_week_day) + 1;
|
(week_day_start - first_week_day) + 1;
|
||||||
|
|
||||||
t = mktime (&tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
p = tm->tm_mday;
|
p = tm->tm_mday;
|
||||||
tm->tm_mday = recur->u.month_day;
|
tm->tm_mday = recur->u.month_day;
|
||||||
t = mktime (tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
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_MONTH:
|
||||||
case RECUR_YEARLY_BY_DAY:
|
case RECUR_YEARLY_BY_DAY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ typedef struct {
|
|||||||
int count;
|
int count;
|
||||||
enum AlarmUnit units;
|
enum AlarmUnit units;
|
||||||
char *data;
|
char *data;
|
||||||
time_t time;
|
|
||||||
|
|
||||||
/* Widgets */
|
/* Widgets */
|
||||||
void *w_count; /* A GtkEntry */
|
void *w_count; /* A GtkEntry */
|
||||||
|
@ -159,8 +159,6 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
|
|||||||
tm.tm_mday++;
|
tm.tm_mday++;
|
||||||
day_end = mktime (&tm);
|
day_end = mktime (&tm);
|
||||||
|
|
||||||
printf ("Boundary: ");
|
|
||||||
print_time_t (day_start);
|
|
||||||
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
|
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
|
||||||
|
|
||||||
day_start = day_end;
|
day_start = day_end;
|
||||||
|
@ -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->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->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->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);
|
gtk_widget_show_all (gcal->notebook);
|
||||||
|
|
||||||
@ -166,6 +166,13 @@ gnome_calendar_previous (GnomeCalendar *gcal)
|
|||||||
gnome_calendar_direction (gcal, -1);
|
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 *
|
GtkWidget *
|
||||||
gnome_calendar_new (char *title)
|
gnome_calendar_new (char *title)
|
||||||
{
|
{
|
||||||
@ -210,12 +217,17 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
|
|||||||
void
|
void
|
||||||
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
|
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
|
||||||
{
|
{
|
||||||
printf ("Adding object at: ");
|
|
||||||
print_time_t (obj->dtstart);
|
|
||||||
calendar_add_object (gcal->cal, obj);
|
calendar_add_object (gcal->cal, obj);
|
||||||
gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
|
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
|
void
|
||||||
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,7 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
|
|||||||
void gnome_calendar_next (GnomeCalendar *gcal);
|
void gnome_calendar_next (GnomeCalendar *gcal);
|
||||||
void gnome_calendar_previous (GnomeCalendar *gcal);
|
void gnome_calendar_previous (GnomeCalendar *gcal);
|
||||||
void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
|
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 */
|
/* Flags is a bitmask of CalObjectChange values */
|
||||||
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
|
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
|
||||||
|
@ -35,8 +35,6 @@ calendar_add_object (Calendar *cal, iCalObject *obj)
|
|||||||
switch (obj->type){
|
switch (obj->type){
|
||||||
case ICAL_EVENT:
|
case ICAL_EVENT:
|
||||||
cal->events = g_list_prepend (cal->events, obj);
|
cal->events = g_list_prepend (cal->events, obj);
|
||||||
if (obj->recur)
|
|
||||||
cal->recur = g_list_prepend (cal->recur, obj);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICAL_TODO:
|
case ICAL_TODO:
|
||||||
@ -61,8 +59,6 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
|
|||||||
switch (obj->type){
|
switch (obj->type){
|
||||||
case ICAL_EVENT:
|
case ICAL_EVENT:
|
||||||
cal->events = g_list_remove (cal->events, obj);
|
cal->events = g_list_remove (cal->events, obj);
|
||||||
if (obj->recur)
|
|
||||||
cal->recur = g_list_remove (cal->recur, obj);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ICAL_TODO:
|
case ICAL_TODO:
|
||||||
|
@ -17,9 +17,6 @@ typedef struct {
|
|||||||
GList *todo;
|
GList *todo;
|
||||||
GList *journal;
|
GList *journal;
|
||||||
|
|
||||||
/* Events that have a recurrence field are also present here */
|
|
||||||
GList *recur;
|
|
||||||
|
|
||||||
/* Time at which the calendar was created */
|
/* Time at which the calendar was created */
|
||||||
time_t created;
|
time_t created;
|
||||||
|
|
||||||
|
@ -159,8 +159,6 @@ gncal_week_view_set (GncalWeekView *wview, time_t start_of_week)
|
|||||||
tm.tm_mday++;
|
tm.tm_mday++;
|
||||||
day_end = mktime (&tm);
|
day_end = mktime (&tm);
|
||||||
|
|
||||||
printf ("Boundary: ");
|
|
||||||
print_time_t (day_start);
|
|
||||||
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
|
gncal_day_view_set_bounds (wview->days[i], day_start, day_end - 1);
|
||||||
|
|
||||||
day_start = day_end;
|
day_start = day_end;
|
||||||
|
@ -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->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->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->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);
|
gtk_widget_show_all (gcal->notebook);
|
||||||
|
|
||||||
@ -166,6 +166,13 @@ gnome_calendar_previous (GnomeCalendar *gcal)
|
|||||||
gnome_calendar_direction (gcal, -1);
|
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 *
|
GtkWidget *
|
||||||
gnome_calendar_new (char *title)
|
gnome_calendar_new (char *title)
|
||||||
{
|
{
|
||||||
@ -210,12 +217,17 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
|
|||||||
void
|
void
|
||||||
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
|
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
|
||||||
{
|
{
|
||||||
printf ("Adding object at: ");
|
|
||||||
print_time_t (obj->dtstart);
|
|
||||||
calendar_add_object (gcal->cal, obj);
|
calendar_add_object (gcal->cal, obj);
|
||||||
gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
|
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
|
void
|
||||||
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,7 @@ void gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj);
|
|||||||
void gnome_calendar_next (GnomeCalendar *gcal);
|
void gnome_calendar_next (GnomeCalendar *gcal);
|
||||||
void gnome_calendar_previous (GnomeCalendar *gcal);
|
void gnome_calendar_previous (GnomeCalendar *gcal);
|
||||||
void gnome_calendar_goto (GnomeCalendar *gcal, time_t new_time);
|
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 */
|
/* Flags is a bitmask of CalObjectChange values */
|
||||||
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
|
void gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags);
|
||||||
|
@ -8,19 +8,143 @@ DCREATED:19980402T023552
|
|||||||
UID:KOrganizer - 1804289383
|
UID:KOrganizer - 1804289383
|
||||||
SEQUENCE:1
|
SEQUENCE:1
|
||||||
LAST-MODIFIED:19980330T225948
|
LAST-MODIFIED:19980330T225948
|
||||||
DTSTART:19980401T116000
|
DTSTART:19980415T003000
|
||||||
DTEND:19980401T119000
|
DTEND:19980415T010000
|
||||||
SUMMARY:Primer miercoles, 4 meses
|
SUMMARY: Semana: Mi, Ju, Vi, Dom (10 veces)
|
||||||
STATUS:NEEDS ACTION
|
STATUS:NEEDS ACTION
|
||||||
CLASS:PUBLIC
|
CLASS:PUBLIC
|
||||||
PRIORITY:0
|
PRIORITY:0
|
||||||
TRANSP:0
|
TRANSP:0
|
||||||
RRULE:MP1 1+ WE # 4
|
RRULE:W1 WE TH FR SU #10
|
||||||
RELATED-TO:0
|
RELATED-TO:0
|
||||||
X-PILOTID:0
|
X-PILOTID:0
|
||||||
X-PILOTSTAT:0
|
X-PILOTSTAT:0
|
||||||
END:VEVENT
|
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
|
END:VCALENDAR
|
||||||
|
|
||||||
|
@ -15,9 +15,20 @@
|
|||||||
static void gncal_year_view_init (GncalYearView *yview);
|
static void gncal_year_view_init (GncalYearView *yview);
|
||||||
|
|
||||||
static void
|
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
|
static void
|
||||||
@ -189,6 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
|
|||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
|
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);
|
year_begin = time_year_begin (yview->year);
|
||||||
@ -221,10 +233,8 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
|
|||||||
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
|
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
|
||||||
|
|
||||||
/* If only the summary changed, we dont care */
|
/* If only the summary changed, we dont care */
|
||||||
if ((flags & CHANGE_SUMMARY) == flags)
|
if (flags && (flags & CHANGE_SUMMARY) == flags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf ("MARCANDO!\n");
|
|
||||||
if (flags & CHANGE_NEW)
|
|
||||||
gncal_year_view_set_year (yview, yview->year);
|
gncal_year_view_set_year (yview, yview->year);
|
||||||
}
|
}
|
||||||
|
@ -401,18 +401,41 @@ load_recurrence (iCalObject *o, char *str)
|
|||||||
|
|
||||||
/* Compute the enddate */
|
/* Compute the enddate */
|
||||||
if (o->recur->_enddate == 0){
|
if (o->recur->_enddate == 0){
|
||||||
printf ("ENDDATE es 0, d=%d\n", o->recur->duration);
|
|
||||||
if (o->recur->duration != 0){
|
if (o->recur->duration != 0){
|
||||||
ical_object_compute_end (o);
|
ical_object_compute_end (o);
|
||||||
} else
|
} else
|
||||||
o->recur->enddate = 0;
|
o->recur->enddate = 0;
|
||||||
} else {
|
} else {
|
||||||
printf ("El evento termina\n");
|
|
||||||
o->recur->enddate = o->recur->_enddate;
|
o->recur->enddate = o->recur->_enddate;
|
||||||
}
|
}
|
||||||
return 1;
|
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 is_a_prop_of(obj,prop) isAPropertyOf (obj,prop)
|
||||||
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj))
|
||||||
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
#define has(obj,prop) (vo = isAPropertyOf (obj, prop))
|
||||||
@ -563,31 +586,35 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dalarm */
|
/* dalarm */
|
||||||
if (has (o, VCDAlarmProp)){
|
|
||||||
ical->dalarm.type = ALARM_DISPLAY;
|
ical->dalarm.type = ALARM_DISPLAY;
|
||||||
|
ical->dalarm.enabled = 0;
|
||||||
|
if (has (o, VCDAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->dalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* aalarm */
|
/* aalarm */
|
||||||
if (has (o, VCAAlarmProp)){
|
|
||||||
ical->aalarm.type = ALARM_AUDIO;
|
ical->aalarm.type = ALARM_AUDIO;
|
||||||
|
ical->aalarm.enabled = 0;
|
||||||
|
if (has (o, VCAAlarmProp)){
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->aalarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* palarm */
|
/* palarm */
|
||||||
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
|
ical->palarm.enabled = 0;
|
||||||
if (has (o, VCPAlarmProp)){
|
if (has (o, VCPAlarmProp)){
|
||||||
ical->palarm.type = ALARM_PROGRAM;
|
ical->palarm.type = ALARM_PROGRAM;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->palarm.enabled = 1;
|
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);
|
free (the_str);
|
||||||
|
|
||||||
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
if ((a = is_a_prop_of (o, VCProcedureNameProp))){
|
||||||
@ -598,14 +625,16 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* malarm */
|
/* malarm */
|
||||||
|
ical->malarm.type = ALARM_MAIL;
|
||||||
|
ical->malarm.enabled = 0;
|
||||||
if (has (o, VCMAlarmProp)){
|
if (has (o, VCMAlarmProp)){
|
||||||
ical->malarm.type = ALARM_MAIL;
|
ical->malarm.type = ALARM_MAIL;
|
||||||
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
if ((a = is_a_prop_of (o, VCRunTimeProp))){
|
||||||
ical->malarm.enabled = 1;
|
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);
|
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));
|
ical->malarm.data = g_strdup (str_val (a));
|
||||||
free (the_str);
|
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_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
|
||||||
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
|
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 *
|
VObject *
|
||||||
ical_object_to_vobject (iCalObject *ical)
|
ical_object_to_vobject (iCalObject *ical)
|
||||||
{
|
{
|
||||||
VObject *o;
|
VObject *o, *alarm;
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
if (ical->type == ICAL_EVENT)
|
if (ical->type == ICAL_EVENT)
|
||||||
@ -787,8 +850,16 @@ ical_object_to_vobject (iCalObject *ical)
|
|||||||
else
|
else
|
||||||
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
|
||||||
strcat (result, buffer);
|
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;
|
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 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
|
* 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 (end != 0){
|
||||||
if (ico->dtstart > end)
|
if (ico->dtstart > end)
|
||||||
return;
|
return;
|
||||||
if (!IS_INFINITE (ico->recur) && recur->enddate < start)
|
if (!IS_INFINITE (recur) && recur->enddate < start)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -870,7 +942,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
switch (recur->type){
|
switch (recur->type){
|
||||||
case RECUR_DAILY:
|
case RECUR_DAILY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -889,7 +961,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
do {
|
do {
|
||||||
struct tm *tm = localtime (¤t);
|
struct tm *tm = localtime (¤t);
|
||||||
|
|
||||||
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 (recur->weekday & (1 << tm->tm_wday))
|
||||||
if (!generate (ico, current, cb, closure))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
@ -910,15 +982,15 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
|
|
||||||
case RECUR_MONTHLY_BY_POS:
|
case RECUR_MONTHLY_BY_POS:
|
||||||
/* FIXME: We only deal with positives now */
|
/* FIXME: We only deal with positives now */
|
||||||
if (ico->recur->u.month_pos < 0)
|
if (recur->u.month_pos < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ico->recur->u.month_pos == 0)
|
if (recur->u.month_pos == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
first_week_day = 7;
|
first_week_day = 7;
|
||||||
for (i = 6; i >= 0; i--)
|
for (i = 6; i >= 0; i--)
|
||||||
if (ico->recur->weekday & (1 << i))
|
if (recur->weekday & (1 << i))
|
||||||
first_week_day = i;
|
first_week_day = i;
|
||||||
|
|
||||||
/* This should not happen, but take it into account */
|
/* 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);
|
tm = *localtime (&t);
|
||||||
week_day_start = tm.tm_wday;
|
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 : 0)) -
|
||||||
(week_day_start - first_week_day) + 1;
|
(week_day_start - first_week_day) + 1;
|
||||||
|
|
||||||
t = mktime (&tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -969,7 +1041,7 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
|
|||||||
p = tm->tm_mday;
|
p = tm->tm_mday;
|
||||||
tm->tm_mday = recur->u.month_day;
|
tm->tm_mday = recur->u.month_day;
|
||||||
t = mktime (tm);
|
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))
|
if (!generate (ico, t, cb, closure))
|
||||||
return;
|
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_MONTH:
|
||||||
case RECUR_YEARLY_BY_DAY:
|
case RECUR_YEARLY_BY_DAY:
|
||||||
do {
|
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))
|
if (!generate (ico, current, cb, closure))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -32,7 +32,6 @@ typedef struct {
|
|||||||
int count;
|
int count;
|
||||||
enum AlarmUnit units;
|
enum AlarmUnit units;
|
||||||
char *data;
|
char *data;
|
||||||
time_t time;
|
|
||||||
|
|
||||||
/* Widgets */
|
/* Widgets */
|
||||||
void *w_count; /* A GtkEntry */
|
void *w_count; /* A GtkEntry */
|
||||||
|
@ -8,19 +8,143 @@ DCREATED:19980402T023552
|
|||||||
UID:KOrganizer - 1804289383
|
UID:KOrganizer - 1804289383
|
||||||
SEQUENCE:1
|
SEQUENCE:1
|
||||||
LAST-MODIFIED:19980330T225948
|
LAST-MODIFIED:19980330T225948
|
||||||
DTSTART:19980401T116000
|
DTSTART:19980415T003000
|
||||||
DTEND:19980401T119000
|
DTEND:19980415T010000
|
||||||
SUMMARY:Primer miercoles, 4 meses
|
SUMMARY: Semana: Mi, Ju, Vi, Dom (10 veces)
|
||||||
STATUS:NEEDS ACTION
|
STATUS:NEEDS ACTION
|
||||||
CLASS:PUBLIC
|
CLASS:PUBLIC
|
||||||
PRIORITY:0
|
PRIORITY:0
|
||||||
TRANSP:0
|
TRANSP:0
|
||||||
RRULE:MP1 1+ WE # 4
|
RRULE:W1 WE TH FR SU #10
|
||||||
RELATED-TO:0
|
RELATED-TO:0
|
||||||
X-PILOTID:0
|
X-PILOTID:0
|
||||||
X-PILOTSTAT:0
|
X-PILOTSTAT:0
|
||||||
END:VEVENT
|
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
|
END:VCALENDAR
|
||||||
|
|
||||||
|
@ -15,9 +15,20 @@
|
|||||||
static void gncal_year_view_init (GncalYearView *yview);
|
static void gncal_year_view_init (GncalYearView *yview);
|
||||||
|
|
||||||
static void
|
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
|
static void
|
||||||
@ -189,6 +200,7 @@ gncal_year_view_set_year (GncalYearView *yview, int year)
|
|||||||
|
|
||||||
for (i = 0; i < 12; i++) {
|
for (i = 0; i < 12; i++) {
|
||||||
gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
|
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);
|
year_begin = time_year_begin (yview->year);
|
||||||
@ -221,10 +233,8 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
|
|||||||
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
|
g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview));
|
||||||
|
|
||||||
/* If only the summary changed, we dont care */
|
/* If only the summary changed, we dont care */
|
||||||
if ((flags & CHANGE_SUMMARY) == flags)
|
if (flags && (flags & CHANGE_SUMMARY) == flags)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
printf ("MARCANDO!\n");
|
|
||||||
if (flags & CHANGE_NEW)
|
|
||||||
gncal_year_view_set_year (yview, yview->year);
|
gncal_year_view_set_year (yview, yview->year);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user