aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog20
-rw-r--r--calendar/TODO6
-rw-r--r--calendar/cal-util/calobj.c48
-rw-r--r--calendar/cal-util/calobj.h2
-rw-r--r--calendar/calobj.c48
-rw-r--r--calendar/calobj.h2
-rw-r--r--calendar/gncal-full-day.c44
-rw-r--r--calendar/gnome-cal.c2
-rw-r--r--calendar/gui/gncal-full-day.c44
-rw-r--r--calendar/gui/gnome-cal.c2
-rw-r--r--calendar/pcs/calobj.c48
-rw-r--r--calendar/pcs/calobj.h2
-rw-r--r--calendar/timeutil.c2
13 files changed, 234 insertions, 36 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index a921d7f813..c842753ec2 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,23 @@
+1998-05-14 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * timeutil.c (isodate_from_time_t): Do not add the spurious
+ padding.
+
+ * calobj.c (store_date_list): Bug fix: I was using the wrong
+ pointer when saving the exception date list.
+ (set_date_list): Bug fix: load correctly the complete exception
+ date list.
+ (set_date_list): Use ',' for the exception date separator as the
+ versit people can not get their standard right.
+
+ * gncal-full-day.c (unrecur_appointment): Support for making an
+ existing recurrent event `movable' for a day.
+
+ * calobj.c (ical_object_add_exdate): New routine, used to add
+ exception dates.
+ (ical_object_duplicate): New routine: used to do the magic
+ recur->no-recur event.
+
1998-05-08 Miguel de Icaza <miguel@nuclecu.unam.mx>
* gncal-full-day.c (new_appointment): Use gtk_calendar freeze/thaw
diff --git a/calendar/TODO b/calendar/TODO
index 9aedd41ca4..211bb2558f 100644
--- a/calendar/TODO
+++ b/calendar/TODO
@@ -23,12 +23,6 @@ Week view:
- Replace the calendar by a `task density' widget like in Solaris cm.
-Day view:
-
-- Highlight the days with appointments in the calendar.
-
General:
-- See that the views synchronize when you do a gnome_calendar_goto().
-
- Write online help. Nice help. Lots of help.
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index f3cf23e78d..7b9b42b716 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -92,6 +92,7 @@ ical_object_destroy (iCalObject *ico)
free_if_defined (ico->status);
free_if_defined (ico->class);
free_if_defined (ico->url);
+ free_if_defined (ico->recur);
/* Lists */
lfree_if_defined (ico->exdate);
@@ -127,15 +128,26 @@ set_date_list (char *str)
GList *list = 0;
char *s;
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";")){
+ for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
time_t *t = g_new (time_t, 1);
+ while (*s && isspace (*s))
+ s++;
*t = time_from_isodate (s);
list = g_list_prepend (list, t);
}
return list;
}
+void
+ical_object_add_exdate (iCalObject *o, time_t t)
+{
+ time_t *pt = g_new (time_t, 1);
+
+ *pt = t;
+ o->exdate = g_list_prepend (o->exdate, pt);
+}
+
static void
ignore_space(char **str)
{
@@ -455,6 +467,31 @@ setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *
}
}
+/*
+ * Duplicates an iCalObject. Implementation is a grand hack
+ */
+iCalObject *
+ical_object_duplicate (iCalObject *o)
+{
+ VObject *vo;
+ iCalObject *new;
+
+ vo = ical_object_to_vobject (o);
+ switch (o->type){
+ case ICAL_EVENT:
+ new = ical_object_create_from_vobject (vo, VCEventProp);
+ break;
+ case ICAL_TODO:
+ new = ical_object_create_from_vobject (vo, VCTodoProp);
+ break;
+ default:
+ new = NULL;
+ }
+
+ cleanVObject (vo);
+ return new;
+}
+
/* FIXME: we need to load the recurrence properties */
iCalObject *
ical_object_create_from_vobject (VObject *o, const char *object_name)
@@ -716,7 +753,7 @@ static void
store_date_list (VObject *o, char *prop, GList *values)
{
GList *l;
- int size;
+ int size, len;
char *s, *p;
size = g_list_length (values);
@@ -724,12 +761,13 @@ store_date_list (VObject *o, char *prop, GList *values)
for (l = values; l; l = l->next){
strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- s [16] = ';';
- s += 17;
+ len = strlen (s);
+ s [len] = ',';
+ s += len + 1;
}
s--;
*s = 0;
- addPropValue (o, prop, s);
+ addPropValue (o, prop, p);
g_free (p);
}
diff --git a/calendar/cal-util/calobj.h b/calendar/cal-util/calobj.h
index 12b7578f10..d18acd4f8a 100644
--- a/calendar/cal-util/calobj.h
+++ b/calendar/cal-util/calobj.h
@@ -182,8 +182,10 @@ iCalObject *ical_object_new (void);
void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
+iCalObject *ical_object_duplicate (iCalObject *o);
void ical_foreach (GList *events, calendarfn fn, void *closure);
void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
+void ical_object_add_exdate (iCalObject *o, time_t t);
/* Computes the enddate field of the recurrence based on the duration */
void ical_object_compute_end (iCalObject *ico);
diff --git a/calendar/calobj.c b/calendar/calobj.c
index f3cf23e78d..7b9b42b716 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -92,6 +92,7 @@ ical_object_destroy (iCalObject *ico)
free_if_defined (ico->status);
free_if_defined (ico->class);
free_if_defined (ico->url);
+ free_if_defined (ico->recur);
/* Lists */
lfree_if_defined (ico->exdate);
@@ -127,15 +128,26 @@ set_date_list (char *str)
GList *list = 0;
char *s;
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";")){
+ for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
time_t *t = g_new (time_t, 1);
+ while (*s && isspace (*s))
+ s++;
*t = time_from_isodate (s);
list = g_list_prepend (list, t);
}
return list;
}
+void
+ical_object_add_exdate (iCalObject *o, time_t t)
+{
+ time_t *pt = g_new (time_t, 1);
+
+ *pt = t;
+ o->exdate = g_list_prepend (o->exdate, pt);
+}
+
static void
ignore_space(char **str)
{
@@ -455,6 +467,31 @@ setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *
}
}
+/*
+ * Duplicates an iCalObject. Implementation is a grand hack
+ */
+iCalObject *
+ical_object_duplicate (iCalObject *o)
+{
+ VObject *vo;
+ iCalObject *new;
+
+ vo = ical_object_to_vobject (o);
+ switch (o->type){
+ case ICAL_EVENT:
+ new = ical_object_create_from_vobject (vo, VCEventProp);
+ break;
+ case ICAL_TODO:
+ new = ical_object_create_from_vobject (vo, VCTodoProp);
+ break;
+ default:
+ new = NULL;
+ }
+
+ cleanVObject (vo);
+ return new;
+}
+
/* FIXME: we need to load the recurrence properties */
iCalObject *
ical_object_create_from_vobject (VObject *o, const char *object_name)
@@ -716,7 +753,7 @@ static void
store_date_list (VObject *o, char *prop, GList *values)
{
GList *l;
- int size;
+ int size, len;
char *s, *p;
size = g_list_length (values);
@@ -724,12 +761,13 @@ store_date_list (VObject *o, char *prop, GList *values)
for (l = values; l; l = l->next){
strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- s [16] = ';';
- s += 17;
+ len = strlen (s);
+ s [len] = ',';
+ s += len + 1;
}
s--;
*s = 0;
- addPropValue (o, prop, s);
+ addPropValue (o, prop, p);
g_free (p);
}
diff --git a/calendar/calobj.h b/calendar/calobj.h
index 12b7578f10..d18acd4f8a 100644
--- a/calendar/calobj.h
+++ b/calendar/calobj.h
@@ -182,8 +182,10 @@ iCalObject *ical_object_new (void);
void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
+iCalObject *ical_object_duplicate (iCalObject *o);
void ical_foreach (GList *events, calendarfn fn, void *closure);
void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
+void ical_object_add_exdate (iCalObject *o, time_t t);
/* Computes the enddate field of the recurrence based on the duration */
void ical_object_compute_end (iCalObject *ico);
diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c
index 47d5ca8d39..1ac7613dbf 100644
--- a/calendar/gncal-full-day.c
+++ b/calendar/gncal-full-day.c
@@ -286,7 +286,7 @@ static void
child_draw_decor (GncalFullDay *fullday, Child *child, GdkRectangle *area)
{
iCalObject *ico = child->ico;
- GdkRectangle rect, dest;
+ GdkRectangle rect;
int ry = 0;
rect.x = child->width - child->decor_width;
@@ -432,11 +432,36 @@ delete_appointment (GtkWidget *widget, gpointer data)
}
static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
+unrecur_appointment (GtkWidget *widget, gpointer data)
{
- int sensitive;
+ Child *child;
+ GncalFullDay *fullday;
+ iCalObject *new;
+
+ child = data;
+ fullday = GNCAL_FULL_DAY (child->widget->parent);
+
+ /* New object */
+ new = ical_object_duplicate (child->ico);
+ g_free (new->recur);
+ new->recur = 0;
+ new->dtstart = child->start;
+ new->dtend = child->end;
+
+ /* Duplicate, and eliminate the recurrency fields */
+ ical_object_add_exdate (child->ico, child->start);
+ gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
+ gnome_calendar_add_object (fullday->calendar, new);
+}
+
+static void
+child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
+{
+ int sensitive, idx, items;
+
static struct menu_item child_items[] = {
+ { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
{ N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
{ N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
{ NULL, NULL, NULL, TRUE },
@@ -445,14 +470,23 @@ child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
child_items[0].data = child;
child_items[1].data = child;
- child_items[3].data = fullday;
+ child_items[2].data = child;
+ child_items[4].data = fullday;
sensitive = (child->ico->user_data == NULL);
child_items[0].sensitive = sensitive;
child_items[1].sensitive = sensitive;
+ child_items[2].sensitive = sensitive;
- popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event);
+ if (child->ico->recur){
+ idx = 0;
+ items = 5;
+ } else {
+ idx = 1;
+ items = 4;
+ }
+ popup_menu (&child_items [idx], items, event);
}
static void
diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c
index 5db24e9828..24c854ee5c 100644
--- a/calendar/gnome-cal.c
+++ b/calendar/gnome-cal.c
@@ -274,7 +274,6 @@ mail_notify (char *mail_address, char *text, time_t app_time)
pipe (p);
pid = fork ();
if (pid == 0){
- const int top = max_open_files ();
int dev_null;
dev_null = open ("/dev/null", O_RDWR);
@@ -362,7 +361,6 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
{
time_t month_begin, month_end;
struct tm tm;
- GList *l;
/* compute month_begin */
tm.tm_hour = 0;
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index 47d5ca8d39..1ac7613dbf 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -286,7 +286,7 @@ static void
child_draw_decor (GncalFullDay *fullday, Child *child, GdkRectangle *area)
{
iCalObject *ico = child->ico;
- GdkRectangle rect, dest;
+ GdkRectangle rect;
int ry = 0;
rect.x = child->width - child->decor_width;
@@ -432,11 +432,36 @@ delete_appointment (GtkWidget *widget, gpointer data)
}
static void
-child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
+unrecur_appointment (GtkWidget *widget, gpointer data)
{
- int sensitive;
+ Child *child;
+ GncalFullDay *fullday;
+ iCalObject *new;
+
+ child = data;
+ fullday = GNCAL_FULL_DAY (child->widget->parent);
+
+ /* New object */
+ new = ical_object_duplicate (child->ico);
+ g_free (new->recur);
+ new->recur = 0;
+ new->dtstart = child->start;
+ new->dtend = child->end;
+
+ /* Duplicate, and eliminate the recurrency fields */
+ ical_object_add_exdate (child->ico, child->start);
+ gnome_calendar_object_changed (fullday->calendar, child->ico, CHANGE_ALL);
+ gnome_calendar_add_object (fullday->calendar, new);
+}
+
+static void
+child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
+{
+ int sensitive, idx, items;
+
static struct menu_item child_items[] = {
+ { N_("Make this appointment movable"), (GtkSignalFunc) unrecur_appointment, NULL, TRUE },
{ N_("Edit this appointment..."), (GtkSignalFunc) edit_appointment, NULL, TRUE },
{ N_("Delete this appointment"), (GtkSignalFunc) delete_appointment, NULL, TRUE },
{ NULL, NULL, NULL, TRUE },
@@ -445,14 +470,23 @@ child_popup_menu (GncalFullDay *fullday, Child *child, GdkEventButton *event)
child_items[0].data = child;
child_items[1].data = child;
- child_items[3].data = fullday;
+ child_items[2].data = child;
+ child_items[4].data = fullday;
sensitive = (child->ico->user_data == NULL);
child_items[0].sensitive = sensitive;
child_items[1].sensitive = sensitive;
+ child_items[2].sensitive = sensitive;
- popup_menu (child_items, sizeof (child_items) / sizeof (child_items[0]), event);
+ if (child->ico->recur){
+ idx = 0;
+ items = 5;
+ } else {
+ idx = 1;
+ items = 4;
+ }
+ popup_menu (&child_items [idx], items, event);
}
static void
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 5db24e9828..24c854ee5c 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -274,7 +274,6 @@ mail_notify (char *mail_address, char *text, time_t app_time)
pipe (p);
pid = fork ();
if (pid == 0){
- const int top = max_open_files ();
int dev_null;
dev_null = open ("/dev/null", O_RDWR);
@@ -362,7 +361,6 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
{
time_t month_begin, month_end;
struct tm tm;
- GList *l;
/* compute month_begin */
tm.tm_hour = 0;
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index f3cf23e78d..7b9b42b716 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -92,6 +92,7 @@ ical_object_destroy (iCalObject *ico)
free_if_defined (ico->status);
free_if_defined (ico->class);
free_if_defined (ico->url);
+ free_if_defined (ico->recur);
/* Lists */
lfree_if_defined (ico->exdate);
@@ -127,15 +128,26 @@ set_date_list (char *str)
GList *list = 0;
char *s;
- for (s = strtok (str, ";"); s; s = strtok (NULL, ";")){
+ for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){
time_t *t = g_new (time_t, 1);
+ while (*s && isspace (*s))
+ s++;
*t = time_from_isodate (s);
list = g_list_prepend (list, t);
}
return list;
}
+void
+ical_object_add_exdate (iCalObject *o, time_t t)
+{
+ time_t *pt = g_new (time_t, 1);
+
+ *pt = t;
+ o->exdate = g_list_prepend (o->exdate, pt);
+}
+
static void
ignore_space(char **str)
{
@@ -455,6 +467,31 @@ setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject *
}
}
+/*
+ * Duplicates an iCalObject. Implementation is a grand hack
+ */
+iCalObject *
+ical_object_duplicate (iCalObject *o)
+{
+ VObject *vo;
+ iCalObject *new;
+
+ vo = ical_object_to_vobject (o);
+ switch (o->type){
+ case ICAL_EVENT:
+ new = ical_object_create_from_vobject (vo, VCEventProp);
+ break;
+ case ICAL_TODO:
+ new = ical_object_create_from_vobject (vo, VCTodoProp);
+ break;
+ default:
+ new = NULL;
+ }
+
+ cleanVObject (vo);
+ return new;
+}
+
/* FIXME: we need to load the recurrence properties */
iCalObject *
ical_object_create_from_vobject (VObject *o, const char *object_name)
@@ -716,7 +753,7 @@ static void
store_date_list (VObject *o, char *prop, GList *values)
{
GList *l;
- int size;
+ int size, len;
char *s, *p;
size = g_list_length (values);
@@ -724,12 +761,13 @@ store_date_list (VObject *o, char *prop, GList *values)
for (l = values; l; l = l->next){
strcpy (s, isodate_from_time_t (*(time_t *)l->data));
- s [16] = ';';
- s += 17;
+ len = strlen (s);
+ s [len] = ',';
+ s += len + 1;
}
s--;
*s = 0;
- addPropValue (o, prop, s);
+ addPropValue (o, prop, p);
g_free (p);
}
diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h
index 12b7578f10..d18acd4f8a 100644
--- a/calendar/pcs/calobj.h
+++ b/calendar/pcs/calobj.h
@@ -182,8 +182,10 @@ iCalObject *ical_object_new (void);
void ical_object_destroy (iCalObject *ico);
iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name);
VObject *ical_object_to_vobject (iCalObject *ical);
+iCalObject *ical_object_duplicate (iCalObject *o);
void ical_foreach (GList *events, calendarfn fn, void *closure);
void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure);
+void ical_object_add_exdate (iCalObject *o, time_t t);
/* Computes the enddate field of the recurrence based on the duration */
void ical_object_compute_end (iCalObject *ico);
diff --git a/calendar/timeutil.c b/calendar/timeutil.c
index 0813410a3a..f23277ce37 100644
--- a/calendar/timeutil.c
+++ b/calendar/timeutil.c
@@ -57,7 +57,7 @@ isodate_from_time_t (time_t t)
static char isotime [40];
tm = localtime (&t);
- strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S ", tm);
+ strftime (isotime, sizeof (isotime)-1, "%Y%m%dT%H%M%S", tm);
return isotime;
}