diff options
-rw-r--r-- | calendar/gui/month-view.c | 78 | ||||
-rw-r--r-- | calendar/gui/month-view.h | 4 | ||||
-rw-r--r-- | calendar/month-view.c | 78 | ||||
-rw-r--r-- | calendar/month-view.h | 4 |
4 files changed, 158 insertions, 6 deletions
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c index 4fc8fbbe3f..2a76387b5d 100644 --- a/calendar/gui/month-view.c +++ b/calendar/gui/month-view.c @@ -16,6 +16,16 @@ #define SPACING 4 /* Spacing between title and calendar */ +/* This is a child in the month view. Each child has a number of canvas items associated to it -- + * it can be more than one box because an event may span several weeks. + */ +struct child { + iCalObject *ico; /* The calendar object this child refers to */ + time_t start, end; /* Start and end times for the instance of the event */ + GList *items; /* The list of canvas items needed to display this child */ +}; + + static void month_view_class_init (MonthViewClass *class); static void month_view_init (MonthView *mv); static void month_view_size_request (GtkWidget *widget, @@ -27,6 +37,13 @@ static void month_view_size_allocate (GtkWidget *widget, static GnomeCanvasClass *parent_class; +/* Adjusts the child events of the month view to the appropriate size and position */ +static void +adjust_children (MonthView *mv) +{ + +} + GtkType month_view_get_type (void) { @@ -158,16 +175,73 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) "height", (double) (allocation->height - y - 1), NULL); - /* FIXME: adjust events */ + /* Adjust children */ + + adjust_children (mv); +} + +/* Destroys a child structure and its associated canvas items */ +static void +child_destroy (MonthView *mv, struct child *child) +{ + GList *list; + + /* Destroy the list of items */ + + for (list = child->items; list; list = list->next) + gtk_object_destroy (list->data); + + g_list_free (child->items); + + /* Destroy the child */ + + g_free (child); +} + +/* This is the callback function used from the calendar iterator. It adds events to the list of + * children in the month view. + */ +static int +add_event (iCalObject *ico, time_t start, time_t end, void *data) +{ + MonthView *mv; + struct child *child; + + mv = MONTH_VIEW (data); + + child = g_new (struct child, 1); + child->ico = ico; + child->start = start; + child->end = end; + + /* FIXME: create items */ } void month_view_update (MonthView *mv, iCalObject *object, int flags) { + GList *list; + time_t t; + time_t month_begin, month_end; + g_return_if_fail (mv != NULL); g_return_if_fail (IS_MONTH_VIEW (mv)); - /* FIXME */ + /* Destroy the old list of children */ + + for (list = mv->children; list; list = list->next) + child_destroy (mv, list->data); + + g_list_free (mv->children); + mv->children = NULL; + + /* Create a new list of children and lay them out */ + + t = time_from_day (mv->year, mv->month, 1); + month_begin = time_month_begin (t); + month_end = time_month_end (t); + + calendar_iterate (mv->calendar->cal, month_begin, month_end, add_event, mv); } /* Unmarks the old day that was marked as current and marks the current day if appropriate */ diff --git a/calendar/gui/month-view.h b/calendar/gui/month-view.h index 77c418e947..300c8c5607 100644 --- a/calendar/gui/month-view.h +++ b/calendar/gui/month-view.h @@ -33,9 +33,11 @@ struct _MonthView { int year; /* The year of the month we are displaying */ int month; /* The month we are displaying */ - int old_current_index; /* The index of the day marked as current, or -1 if none */ + GList *children; /* The list of children (events) we are carrying */ + int num_slots; /* The number of slots we need to do the child layout (layout.h) */ + GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ }; diff --git a/calendar/month-view.c b/calendar/month-view.c index 4fc8fbbe3f..2a76387b5d 100644 --- a/calendar/month-view.c +++ b/calendar/month-view.c @@ -16,6 +16,16 @@ #define SPACING 4 /* Spacing between title and calendar */ +/* This is a child in the month view. Each child has a number of canvas items associated to it -- + * it can be more than one box because an event may span several weeks. + */ +struct child { + iCalObject *ico; /* The calendar object this child refers to */ + time_t start, end; /* Start and end times for the instance of the event */ + GList *items; /* The list of canvas items needed to display this child */ +}; + + static void month_view_class_init (MonthViewClass *class); static void month_view_init (MonthView *mv); static void month_view_size_request (GtkWidget *widget, @@ -27,6 +37,13 @@ static void month_view_size_allocate (GtkWidget *widget, static GnomeCanvasClass *parent_class; +/* Adjusts the child events of the month view to the appropriate size and position */ +static void +adjust_children (MonthView *mv) +{ + +} + GtkType month_view_get_type (void) { @@ -158,16 +175,73 @@ month_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation) "height", (double) (allocation->height - y - 1), NULL); - /* FIXME: adjust events */ + /* Adjust children */ + + adjust_children (mv); +} + +/* Destroys a child structure and its associated canvas items */ +static void +child_destroy (MonthView *mv, struct child *child) +{ + GList *list; + + /* Destroy the list of items */ + + for (list = child->items; list; list = list->next) + gtk_object_destroy (list->data); + + g_list_free (child->items); + + /* Destroy the child */ + + g_free (child); +} + +/* This is the callback function used from the calendar iterator. It adds events to the list of + * children in the month view. + */ +static int +add_event (iCalObject *ico, time_t start, time_t end, void *data) +{ + MonthView *mv; + struct child *child; + + mv = MONTH_VIEW (data); + + child = g_new (struct child, 1); + child->ico = ico; + child->start = start; + child->end = end; + + /* FIXME: create items */ } void month_view_update (MonthView *mv, iCalObject *object, int flags) { + GList *list; + time_t t; + time_t month_begin, month_end; + g_return_if_fail (mv != NULL); g_return_if_fail (IS_MONTH_VIEW (mv)); - /* FIXME */ + /* Destroy the old list of children */ + + for (list = mv->children; list; list = list->next) + child_destroy (mv, list->data); + + g_list_free (mv->children); + mv->children = NULL; + + /* Create a new list of children and lay them out */ + + t = time_from_day (mv->year, mv->month, 1); + month_begin = time_month_begin (t); + month_end = time_month_end (t); + + calendar_iterate (mv->calendar->cal, month_begin, month_end, add_event, mv); } /* Unmarks the old day that was marked as current and marks the current day if appropriate */ diff --git a/calendar/month-view.h b/calendar/month-view.h index 77c418e947..300c8c5607 100644 --- a/calendar/month-view.h +++ b/calendar/month-view.h @@ -33,9 +33,11 @@ struct _MonthView { int year; /* The year of the month we are displaying */ int month; /* The month we are displaying */ - int old_current_index; /* The index of the day marked as current, or -1 if none */ + GList *children; /* The list of children (events) we are carrying */ + int num_slots; /* The number of slots we need to do the child layout (layout.h) */ + GnomeCanvasItem *title; /* The title heading with the month/year */ GnomeCanvasItem *mitem; /* The canvas month item used by this month view */ }; |