aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar.c16
-rw-r--r--calendar/gui/calendar.h2
-rw-r--r--calendar/gui/gncal-full-day.c10
-rw-r--r--calendar/gui/gnome-cal.c7
-rw-r--r--calendar/gui/test.vcf23
-rw-r--r--calendar/gui/year-view.c76
6 files changed, 72 insertions, 62 deletions
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 7b5f50c46f..641d6d765e 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -207,21 +207,25 @@ calendar_load_from_vobject (Calendar *cal, VObject *vcal)
}
/* Loads a calendar from a file */
-void
+char *
calendar_load (Calendar *cal, char *fname)
{
VObject *vcal;
if (cal->filename){
g_warning ("Calendar load called again\n");
- return;
+ return "Internal error";
}
cal->filename = g_strdup (fname);
vcal = Parse_MIME_FromFileName (fname);
+ if (!vcal)
+ return "Could not load the calendar";
+
calendar_load_from_vobject (cal, vcal);
cleanVObject (vcal);
cleanStrTbl ();
+ return NULL;
}
void
@@ -250,7 +254,7 @@ calendar_save (Calendar *cal, char *fname)
cleanStrTbl ();
}
-static void
+static gint
calendar_object_compare_by_start (gpointer a, gpointer b)
{
CalendarObject *ca = a;
@@ -261,7 +265,7 @@ calendar_object_compare_by_start (gpointer a, gpointer b)
return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
}
-static void
+static int
assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
{
CalendarObject *co;
@@ -272,6 +276,8 @@ assemble_event_list (iCalObject *obj, time_t start, time_t end, void *c)
co->ev_end = end;
co->ico = obj;
*l = g_list_insert_sorted (*l, co, calendar_object_compare_by_start);
+
+ return 1;
}
void
@@ -280,7 +286,7 @@ calendar_destroy_event_list (GList *l)
GList *p;
for (p = l; p; p = p->next)
- g_free (l->data);
+ g_free (p->data);
g_list_free (l);
}
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index 9fbb6088a4..e68b74ebf4 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -38,7 +38,7 @@ typedef struct {
} CalendarObject;
Calendar *calendar_new (char *title);
-void calendar_load (Calendar *cal, char *fname);
+char *calendar_load (Calendar *cal, char *fname);
void calendar_add_object (Calendar *cal, iCalObject *obj);
void calendar_remove_object (Calendar *cal, iCalObject *obj);
void calendar_destroy (Calendar *cal);
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index b048ba9de7..c3151f6dcf 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -1447,7 +1447,7 @@ button_1 (GncalFullDay *fullday, GdkEventButton *event)
child = find_child_by_window (fullday, event->window, &on_text);
- if (!child || on_text)
+ if (!child || on_text || child->ico->recur)
return FALSE;
/* Prepare for drag */
@@ -1647,8 +1647,8 @@ update_from_drag_info (GncalFullDay *fullday)
widget = GTK_WIDGET (fullday);
get_time_from_rows (fullday, di->child_start_row, di->child_rows_used,
- &di->child->start,
- &di->child->end);
+ &di->child->ico->dtstart,
+ &di->child->ico->dtend);
child_range_changed (fullday, di->child);
@@ -1878,7 +1878,7 @@ child_compare_by_start (gpointer a, gpointer b)
return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
}
-static void
+static int
fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
{
GncalFullDay *fullday = c;
@@ -1886,6 +1886,8 @@ fullday_add_children (iCalObject *obj, time_t start, time_t end, void *c)
child = child_new (fullday, start, end, obj);
fullday->children = g_list_insert_sorted (fullday->children, child, child_compare_by_start);
+
+ return 1;
}
void
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index e38f818c49..c6ca54331f 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -198,7 +198,12 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
void
gnome_calendar_load (GnomeCalendar *gcal, char *file)
{
- calendar_load (gcal->cal, file);
+ char *r;
+
+ if ((r = calendar_load (gcal->cal, file)) != NULL){
+ printf ("Error loading calendar: %s\n", r);
+ return;
+ }
gnome_calendar_update_all (gcal, NULL, 0);
}
diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf
index 7d41d14878..b0892bbf5f 100644
--- a/calendar/gui/test.vcf
+++ b/calendar/gui/test.vcf
@@ -8,34 +8,19 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980415T003000
-DTEND:19980415T010000
-SUMMARY:asdfasdfasfasdfasdf
+DTSTART:19980415T116000
+DTEND:19980415T119000
+SUMMARY:Mensual, el 15, durante 4 semanas
STATUS:NEEDS ACTION
CLASS:PUBLIC
PRIORITY:0
TRANSP:0
+RRULE:MD1 15 #4
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:asdfasfdasfasdfasfd
-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 8f5a786239..a8972a7558 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -136,23 +136,6 @@ gncal_year_view_new (GnomeCalendar *calendar, time_t date)
return GTK_WIDGET (yview);
}
-void gncal_year_view_set (GncalYearView *yview, time_t date)
-{
- int i;
- char buff[10];
- struct tm *tmptm;
-
- tmptm = localtime(&date);
- yview->year = tmptm->tm_year;
-
- snprintf(buff, 10, "%d", yview->year + 1900);
- gtk_label_set(GTK_LABEL(yview->year_label), buff);
-
- for (i = 0; i < 12; i++) {
- gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
- }
-}
-
static void
year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure)
{
@@ -174,6 +157,47 @@ year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure)
}
}
+static void
+gncal_year_view_set_year (GncalYearView *yview, int year)
+{
+ time_t year_begin, year_end;
+ char buff[20];
+ GList *l;
+ int i;
+
+ if (!yview->gcal->cal)
+ return;
+
+ snprintf(buff, 20, "%d", yview->year + 1900);
+ gtk_label_set(GTK_LABEL(yview->year_label), buff);
+
+ for (i = 0; i < 12; i++) {
+ gtk_calendar_select_month (GTK_CALENDAR(yview->calendar[i]), i, yview->year);
+ }
+
+ year_begin = time_year_begin (yview->year);
+ year_end = time_year_end (yview->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);
+}
+
+void
+gncal_year_view_set (GncalYearView *yview, time_t date)
+{
+ struct tm *tmptm;
+
+ tmptm = localtime(&date);
+ yview->year = tmptm->tm_year;
+
+ gncal_year_view_set_year (yview, yview->year);
+}
+
void
gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
{
@@ -184,19 +208,7 @@ gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags)
if ((flags & CHANGE_SUMMARY) == flags)
return;
- if (flags & CHANGE_NEW){
- time_t year_begin, year_end;
- GList *l, *nl;
-
- year_begin = time_year_begin (yview->year);
- year_end = time_year_end (yview->year);
-
- l = g_list_append (NULL, ico);
- nl = calendar_get_objects_in_range (l, year_begin, year_end, NULL);
- if (nl){
- ical_foreach (nl, year_view_mark_day, yview);
- g_list_free (nl);
- }
- g_list_free (l);
- }
+ printf ("MARCANDO!\n");
+ if (flags & CHANGE_NEW)
+ gncal_year_view_set_year (yview, yview->year);
}