diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/calendar.c | 6 | ||||
-rw-r--r-- | calendar/gui/calendar.h | 12 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 5 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 57 | ||||
-rw-r--r-- | calendar/gui/year-view.h | 8 |
5 files changed, 73 insertions, 15 deletions
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c index ebece3aadc..9f9ef4dc51 100644 --- a/calendar/gui/calendar.c +++ b/calendar/gui/calendar.c @@ -36,6 +36,8 @@ 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: @@ -60,6 +62,8 @@ 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: @@ -107,7 +111,7 @@ ice (time_t t) return buffer; } -static GList * +GList * calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func) { GList *new_events = 0; diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h index f93946315c..a59fec7544 100644 --- a/calendar/gui/calendar.h +++ b/calendar/gui/calendar.h @@ -6,13 +6,24 @@ BEGIN_GNOME_DECLS typedef struct { + /* This calendar's title */ char *title; + + /* backing store for this calendar object */ char *filename; + + /* The list of events; todo's and journal entries */ GList *events; 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; + + /* If the calendar was last modified */ int modified; void *temp; } Calendar; @@ -23,6 +34,7 @@ void calendar_add_object (Calendar *cal, iCalObject *obj); void calendar_remove_object (Calendar *cal, iCalObject *obj); void calendar_destroy (Calendar *cal); GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); +GList *calendar_get_objects_in_range (GList *objects, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_todo_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); GList *calendar_get_journal_in_range (Calendar *cal, time_t start, time_t end, GCompareFunc sort_func); gint calendar_compare_by_dtstart (gpointer a, gpointer b); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 6be4eb3f1e..e38f818c49 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -83,7 +83,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->notebook = gtk_notebook_new (); gcal->week_view = gncal_week_view_new (gcal, now); - gcal->year_view = gncal_year_view_new (now); + gcal->year_view = gncal_year_view_new (gcal, now); gcal->task_view = tasks_create (gcal); setup_day_view (gcal); @@ -190,8 +190,9 @@ gnome_calendar_new (char *title) static void gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags) { - gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, flags); + gncal_full_day_update (GNCAL_FULL_DAY (cal->day_view), object, flags); gncal_week_view_update (GNCAL_WEEK_VIEW (cal->week_view), object, flags); + gncal_year_view_update (GNCAL_YEAR_VIEW (cal->year_view), object, flags); } void diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index c3d6057086..c3db60f28b 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -72,7 +72,7 @@ gncal_year_view_init (GncalYearView *yview) } GtkWidget * -gncal_year_view_new (time_t date) +gncal_year_view_new (GnomeCalendar *calendar, time_t date) { struct tm my_tm = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; char monthbuff[40]; @@ -85,7 +85,8 @@ gncal_year_view_new (time_t date) tmptm = localtime(&date); yview->year = tmptm->tm_year; - my_tm.tm_mon = tmptm->tm_year; + yview->gcal = calendar; + my_tm.tm_year = tmptm->tm_year; yview->year_label = gtk_label_new(""); gtk_table_attach (GTK_TABLE (yview), GTK_WIDGET (yview->year_label), @@ -151,11 +152,51 @@ void gncal_year_view_set (GncalYearView *yview, time_t date) } } -/*void -gncal_week_view_update (GncalWeekView *wview, iCalObject *ico, int flags) +static void +year_view_mark_day (iCalObject *ical, time_t start, time_t end, void *closure) +{ + GncalYearView *yview = (GncalYearView *) closure; + struct tm *tm_s; + int days, day; + + tm_s = localtime (&start); + days = difftime (end, start) / (60*60*24); + + for (day = 0; day <= days; day++){ + time_t new = mktime (tm_s); + struct tm *tm_day; + + tm_day = localtime (&new); + gtk_calendar_mark_day (GTK_CALENDAR (yview->calendar [tm_day->tm_mon]), + tm_day->tm_mday); + tm_s->tm_mday++; + } +} + +void +gncal_year_view_update (GncalYearView *yview, iCalObject *ico, int flags) { - g_return_if_fail (wview != NULL); - g_return_if_fail (GNCAL_IS_YEAR_VIEW (wview)); + g_return_if_fail (yview != NULL); + g_return_if_fail (GNCAL_IS_YEAR_VIEW (yview)); + + /* If only the summary changed, we dont care */ + 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); + } +} - update (wview, TRUE, ico, flags); -}*/ diff --git a/calendar/gui/year-view.h b/calendar/gui/year-view.h index bdd542abda..828678f56d 100644 --- a/calendar/gui/year-view.h +++ b/calendar/gui/year-view.h @@ -33,7 +33,8 @@ typedef struct _GncalYearViewClass GncalYearViewClass; struct _GncalYearView { GtkTable table; - GtkWidget *calendar[12]; /* one calendar per month */ + GnomeCalendar *gcal; /* The calendar we are associated to */ + GtkWidget *calendar[12]; /* one calendar per month */ guint handler[12]; /* for (un)blocking the calendars */ GtkWidget *year_label; @@ -46,9 +47,8 @@ struct _GncalYearViewClass { guint gncal_year_view_get_type (void); -GtkWidget *gncal_year_view_new (time_t date); - -void gncal_year_view_set (GncalYearView *yview, time_t date); +GtkWidget *gncal_year_view_new (GnomeCalendar *calendar, time_t date); +void gncal_year_view_set (GncalYearView *yview, time_t date); END_GNOME_DECLS |