diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 21 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 10 | ||||
-rw-r--r-- | calendar/gui/e-cal-view.c | 74 | ||||
-rw-r--r-- | calendar/gui/e-cal-view.h | 16 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.c | 74 | ||||
-rw-r--r-- | calendar/gui/e-calendar-view.h | 16 | ||||
-rw-r--r-- | calendar/gui/e-day-view.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-day-view.h | 20 | ||||
-rw-r--r-- | calendar/gui/e-week-view.c | 2 | ||||
-rw-r--r-- | calendar/gui/e-week-view.h | 10 |
10 files changed, 154 insertions, 91 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 83e06e7bbb..1a3465079d 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,5 +1,26 @@ 2003-07-24 Rodrigo Moya <rodrigo@ximian.com> + * gui/e-cal-view.h: define ECalViewEvent as the base struct for + the other views. + + * gui/e-day-view.[ch]: EDayViewEvent is now based on ECalViewEvent. + (e_day_view_get_selected_events): made it return a list of + ECalViewEvent's, not CalComponent's, so that we can get more + information about the events. + + * gui/e-week-view.[ch]: EWeekViewEvent is now based on ECalViewEvent. + (e_week_view_get_selected_events): same as e_day_view_get_selected_events. + + * gui/e-cal-view.c (e_cal_view_cut_clipboard, e_cal_view_copy_clipboard, + e_cal_view_delete_selected_event, e_cal_view_delete_selected_events, + on_edit_appointment, on_save_as, on_print_event, on_meeting, + on_forward, e_cal_view_create_popup_menu): + * gui/calendar-commands.c (sensitize_calendar_commands): updated + to read ECalViewEvent's instead of CalComponent's as returned + by e_cal_view_get_selected_events(). + +2003-07-24 Rodrigo Moya <rodrigo@ximian.com> + * gui/e-cal-view.c (delete_event): check the uid before using it. 2003-07-24 Rodrigo Moya <rodrigo@ximian.com> diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index d756f52cff..cda78827df 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -599,20 +599,20 @@ sensitize_calendar_commands (GnomeCalendar *gcal, BonoboControl *control, gboole /* occurrence-related menu items */ has_recurrences = FALSE; if (n_selected > 0 && !read_only) { - CalComponent *comp; + ECalViewEvent *event; GList *list; GtkWidget *view; view = gnome_calendar_get_current_view_widget (gcal); list = e_cal_view_get_selected_events (E_CAL_VIEW (view)); if (list) { - comp = (CalComponent *) list->data; + event = (ECalViewEvent *) list->data; g_list_free (list); } else - comp = NULL; + event = NULL; - if (comp) { - if (cal_component_has_recurrences (comp)) + if (event) { + if (cal_component_has_recurrences (event->comp)) has_recurrences = TRUE; } } diff --git a/calendar/gui/e-cal-view.c b/calendar/gui/e-cal-view.c index 84dab61a86..8913da5de2 100644 --- a/calendar/gui/e-cal-view.c +++ b/calendar/gui/e-cal-view.c @@ -509,14 +509,18 @@ e_cal_view_cut_clipboard (ECalView *cal_view) e_cal_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { - CalComponent *comp = l->data; + ECalViewEvent *event = (ECalViewEvent *) l->data; - if (itip_organizer_is_user (comp, cal_view->priv->client) + if (!event) + continue; + + if (itip_organizer_is_user (event->comp, cal_view->priv->client) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view), - cal_view->priv->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, cal_view->priv->client, NULL); + cal_view->priv->client, event->comp, TRUE)) + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, + cal_view->priv->client, NULL); - cal_component_get_uid (comp, &uid); + cal_component_get_uid (event->comp, &uid); delete_error_dialog (cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT); } @@ -533,6 +537,7 @@ e_cal_view_copy_clipboard (ECalView *cal_view) gchar *comp_str; icalcomponent *vcal_comp; icalcomponent *new_icalcomp; + ECalViewEvent *event; g_return_if_fail (E_IS_CAL_VIEW (cal_view)); @@ -542,13 +547,17 @@ e_cal_view_copy_clipboard (ECalView *cal_view) /* create top-level VCALENDAR component and add VTIMEZONE's */ vcal_comp = cal_util_new_top_level (); - for (l = selected; l != NULL; l = l->next) - cal_util_add_timezones_from_component (vcal_comp, (CalComponent *) l->data); + for (l = selected; l != NULL; l = l->next) { + event = (ECalViewEvent *) l->data; + + if (event) + cal_util_add_timezones_from_component (vcal_comp, event->comp); + } for (l = selected; l != NULL; l = l->next) { - CalComponent *comp = (CalComponent *) l->data; + event = (ECalViewEvent *) l->data; - new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp)); icalcomponent_add_component (vcal_comp, new_icalcomp); } @@ -605,14 +614,15 @@ void e_cal_view_delete_selected_event (ECalView *cal_view) { GList *selected; - CalComponent *comp; + ECalViewEvent *event; selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; - comp = CAL_COMPONENT (selected->data); - delete_event (cal_view, comp); + event = (ECalViewEvent *) selected->data; + if (event) + delete_event (cal_view, event->comp); g_list_free (selected); } @@ -621,15 +631,16 @@ void e_cal_view_delete_selected_events (ECalView *cal_view) { GList *selected, *l; - CalComponent *comp; + ECalViewEvent *event; selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; for (l = selected; l != NULL; l = l->next) { - comp = CAL_COMPONENT (l->data); - delete_event (cal_view, comp); + event = (ECalViewEvent *) l->data; + if (event) + delete_event (cal_view, event->comp); } g_list_free (selected); @@ -696,7 +707,10 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), FALSE); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + + if (event) + gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, FALSE); g_list_free (selected); } @@ -745,6 +759,7 @@ on_save_as (GtkWidget *widget, gpointer user_data) char *filename; char *ical_string; FILE *file; + ECalViewEvent *event; cal_view = E_CAL_VIEW (user_data); @@ -756,8 +771,8 @@ on_save_as (GtkWidget *widget, gpointer user_data) if (filename == NULL) return; - ical_string = cal_client_get_component_as_string (cal_view->priv->client, - CAL_COMPONENT (selected->data)); + event = (ECalViewEvent *) selected->data; + ical_string = cal_client_get_component_as_string (cal_view->priv->client, event->comp); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -781,13 +796,15 @@ on_print_event (GtkWidget *widget, gpointer user_data) { ECalView *cal_view; GList *selected; + ECalViewEvent *event; cal_view = E_CAL_VIEW (user_data); selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; - print_comp (CAL_COMPONENT (selected->data), cal_view->priv->client, FALSE); + event = (ECalViewEvent *) selected->data; + print_comp (event->comp, cal_view->priv->client, FALSE); } static void @@ -798,7 +815,8 @@ on_meeting (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), TRUE); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, TRUE); g_list_free (selected); } @@ -812,8 +830,8 @@ on_forward (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, CAL_COMPONENT (selected->data), - cal_view->priv->client, NULL); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, cal_view->priv->client, NULL); g_list_free (selected); } @@ -1058,21 +1076,23 @@ e_cal_view_create_popup_menu (ECalView *cal_view) main_items[9].submenu = cal_view->priv->view_menu; context_menu = main_items; } else { + ECalViewEvent *event; + context_menu = child_items; - if (cal_component_has_recurrences (CAL_COMPONENT (selected->data))) + event = (ECalViewEvent *) selected->data; + if (cal_component_has_recurrences (event->comp)) hide_mask |= MASK_SINGLE; else hide_mask |= MASK_RECURRING; - if (cal_component_is_instance (CAL_COMPONENT (selected->data))) + if (cal_component_is_instance (event->comp)) hide_mask |= MASK_INSTANCE; - if (cal_component_has_organizer (CAL_COMPONENT (selected->data))) { + if (cal_component_has_organizer (event->comp)) { disable_mask |= MASK_MEETING; - if (!itip_organizer_is_user (CAL_COMPONENT (selected->data), - cal_view->priv->client)) + if (!itip_organizer_is_user (event->comp, cal_view->priv->client)) disable_mask |= MASK_MEETING_ORGANIZER; } } diff --git a/calendar/gui/e-cal-view.h b/calendar/gui/e-cal-view.h index 4f71669080..ba9376b467 100644 --- a/calendar/gui/e-cal-view.h +++ b/calendar/gui/e-cal-view.h @@ -47,6 +47,20 @@ typedef enum { E_CAL_VIEW_POS_BOTTOM_EDGE } ECalViewPosition; +#define E_CAL_VIEW_EVENT_FIELDS \ + GnomeCanvasItem *canvas_item; \ + CalClient *client; \ + CalComponent *comp; \ + time_t start; \ + time_t end; \ + guint16 start_minute; \ + guint16 end_minute; \ + guint different_timezone : 1; + +typedef struct { + E_CAL_VIEW_EVENT_FIELDS +} ECalViewEvent; + typedef struct _ECalView ECalView; typedef struct _ECalViewClass ECalViewClass; typedef struct _ECalViewPrivate ECalViewPrivate; @@ -63,7 +77,7 @@ struct _ECalViewClass { void (* selection_changed) (ECalView *cal_view); /* Virtual methods */ - GList * (* get_selected_events) (ECalView *cal_view); + GList * (* get_selected_events) (ECalView *cal_view); /* a GList of ECalViewEvent's */ void (* get_selected_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); void (* set_selected_time_range) (ECalView *cal_view, time_t start_time, time_t end_time); gboolean (* get_visible_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); diff --git a/calendar/gui/e-calendar-view.c b/calendar/gui/e-calendar-view.c index 84dab61a86..8913da5de2 100644 --- a/calendar/gui/e-calendar-view.c +++ b/calendar/gui/e-calendar-view.c @@ -509,14 +509,18 @@ e_cal_view_cut_clipboard (ECalView *cal_view) e_cal_view_copy_clipboard (cal_view); for (l = selected; l != NULL; l = l->next) { - CalComponent *comp = l->data; + ECalViewEvent *event = (ECalViewEvent *) l->data; - if (itip_organizer_is_user (comp, cal_view->priv->client) + if (!event) + continue; + + if (itip_organizer_is_user (event->comp, cal_view->priv->client) && cancel_component_dialog ((GtkWindow *) gtk_widget_get_toplevel (cal_view), - cal_view->priv->client, comp, TRUE)) - itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, comp, cal_view->priv->client, NULL); + cal_view->priv->client, event->comp, TRUE)) + itip_send_comp (CAL_COMPONENT_METHOD_CANCEL, event->comp, + cal_view->priv->client, NULL); - cal_component_get_uid (comp, &uid); + cal_component_get_uid (event->comp, &uid); delete_error_dialog (cal_client_remove_object (cal_view->priv->client, uid), CAL_COMPONENT_EVENT); } @@ -533,6 +537,7 @@ e_cal_view_copy_clipboard (ECalView *cal_view) gchar *comp_str; icalcomponent *vcal_comp; icalcomponent *new_icalcomp; + ECalViewEvent *event; g_return_if_fail (E_IS_CAL_VIEW (cal_view)); @@ -542,13 +547,17 @@ e_cal_view_copy_clipboard (ECalView *cal_view) /* create top-level VCALENDAR component and add VTIMEZONE's */ vcal_comp = cal_util_new_top_level (); - for (l = selected; l != NULL; l = l->next) - cal_util_add_timezones_from_component (vcal_comp, (CalComponent *) l->data); + for (l = selected; l != NULL; l = l->next) { + event = (ECalViewEvent *) l->data; + + if (event) + cal_util_add_timezones_from_component (vcal_comp, event->comp); + } for (l = selected; l != NULL; l = l->next) { - CalComponent *comp = (CalComponent *) l->data; + event = (ECalViewEvent *) l->data; - new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (comp)); + new_icalcomp = icalcomponent_new_clone (cal_component_get_icalcomponent (event->comp)); icalcomponent_add_component (vcal_comp, new_icalcomp); } @@ -605,14 +614,15 @@ void e_cal_view_delete_selected_event (ECalView *cal_view) { GList *selected; - CalComponent *comp; + ECalViewEvent *event; selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; - comp = CAL_COMPONENT (selected->data); - delete_event (cal_view, comp); + event = (ECalViewEvent *) selected->data; + if (event) + delete_event (cal_view, event->comp); g_list_free (selected); } @@ -621,15 +631,16 @@ void e_cal_view_delete_selected_events (ECalView *cal_view) { GList *selected, *l; - CalComponent *comp; + ECalViewEvent *event; selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; for (l = selected; l != NULL; l = l->next) { - comp = CAL_COMPONENT (l->data); - delete_event (cal_view, comp); + event = (ECalViewEvent *) l->data; + if (event) + delete_event (cal_view, event->comp); } g_list_free (selected); @@ -696,7 +707,10 @@ on_edit_appointment (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), FALSE); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + + if (event) + gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, FALSE); g_list_free (selected); } @@ -745,6 +759,7 @@ on_save_as (GtkWidget *widget, gpointer user_data) char *filename; char *ical_string; FILE *file; + ECalViewEvent *event; cal_view = E_CAL_VIEW (user_data); @@ -756,8 +771,8 @@ on_save_as (GtkWidget *widget, gpointer user_data) if (filename == NULL) return; - ical_string = cal_client_get_component_as_string (cal_view->priv->client, - CAL_COMPONENT (selected->data)); + event = (ECalViewEvent *) selected->data; + ical_string = cal_client_get_component_as_string (cal_view->priv->client, event->comp); if (ical_string == NULL) { g_warning ("Couldn't convert item to a string"); return; @@ -781,13 +796,15 @@ on_print_event (GtkWidget *widget, gpointer user_data) { ECalView *cal_view; GList *selected; + ECalViewEvent *event; cal_view = E_CAL_VIEW (user_data); selected = e_cal_view_get_selected_events (cal_view); if (!selected) return; - print_comp (CAL_COMPONENT (selected->data), cal_view->priv->client, FALSE); + event = (ECalViewEvent *) selected->data; + print_comp (event->comp, cal_view->priv->client, FALSE); } static void @@ -798,7 +815,8 @@ on_meeting (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - gnome_calendar_edit_object (cal_view->priv->calendar, CAL_COMPONENT (selected->data), TRUE); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + gnome_calendar_edit_object (cal_view->priv->calendar, event->comp, TRUE); g_list_free (selected); } @@ -812,8 +830,8 @@ on_forward (GtkWidget *widget, gpointer user_data) selected = e_cal_view_get_selected_events (cal_view); if (selected) { - itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, CAL_COMPONENT (selected->data), - cal_view->priv->client, NULL); + ECalViewEvent *event = (ECalViewEvent *) selected->data; + itip_send_comp (CAL_COMPONENT_METHOD_PUBLISH, event->comp, cal_view->priv->client, NULL); g_list_free (selected); } @@ -1058,21 +1076,23 @@ e_cal_view_create_popup_menu (ECalView *cal_view) main_items[9].submenu = cal_view->priv->view_menu; context_menu = main_items; } else { + ECalViewEvent *event; + context_menu = child_items; - if (cal_component_has_recurrences (CAL_COMPONENT (selected->data))) + event = (ECalViewEvent *) selected->data; + if (cal_component_has_recurrences (event->comp)) hide_mask |= MASK_SINGLE; else hide_mask |= MASK_RECURRING; - if (cal_component_is_instance (CAL_COMPONENT (selected->data))) + if (cal_component_is_instance (event->comp)) hide_mask |= MASK_INSTANCE; - if (cal_component_has_organizer (CAL_COMPONENT (selected->data))) { + if (cal_component_has_organizer (event->comp)) { disable_mask |= MASK_MEETING; - if (!itip_organizer_is_user (CAL_COMPONENT (selected->data), - cal_view->priv->client)) + if (!itip_organizer_is_user (event->comp, cal_view->priv->client)) disable_mask |= MASK_MEETING_ORGANIZER; } } diff --git a/calendar/gui/e-calendar-view.h b/calendar/gui/e-calendar-view.h index 4f71669080..ba9376b467 100644 --- a/calendar/gui/e-calendar-view.h +++ b/calendar/gui/e-calendar-view.h @@ -47,6 +47,20 @@ typedef enum { E_CAL_VIEW_POS_BOTTOM_EDGE } ECalViewPosition; +#define E_CAL_VIEW_EVENT_FIELDS \ + GnomeCanvasItem *canvas_item; \ + CalClient *client; \ + CalComponent *comp; \ + time_t start; \ + time_t end; \ + guint16 start_minute; \ + guint16 end_minute; \ + guint different_timezone : 1; + +typedef struct { + E_CAL_VIEW_EVENT_FIELDS +} ECalViewEvent; + typedef struct _ECalView ECalView; typedef struct _ECalViewClass ECalViewClass; typedef struct _ECalViewPrivate ECalViewPrivate; @@ -63,7 +77,7 @@ struct _ECalViewClass { void (* selection_changed) (ECalView *cal_view); /* Virtual methods */ - GList * (* get_selected_events) (ECalView *cal_view); + GList * (* get_selected_events) (ECalView *cal_view); /* a GList of ECalViewEvent's */ void (* get_selected_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); void (* set_selected_time_range) (ECalView *cal_view, time_t start_time, time_t end_time); gboolean (* get_visible_time_range) (ECalView *cal_view, time_t *start_time, time_t *end_time); diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 790594e0a0..38642ec8eb 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -3398,7 +3398,7 @@ e_day_view_get_selected_events (ECalView *cal_view) } if (event) - list = g_list_append (list, event->comp); + list = g_list_append (list, event); return list; } diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 2738c0c5e0..4aad2a6751 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -169,11 +169,7 @@ typedef enum typedef struct _EDayViewEvent EDayViewEvent; struct _EDayViewEvent { - CalComponent *comp; - - /* These are the times of this specific occurrence of the event. */ - time_t start; - time_t end; + E_CAL_VIEW_EVENT_FIELDS /* For events in the main canvas, this contains the start column. For long events in the top canvas, this is its row. */ @@ -185,20 +181,6 @@ struct _EDayViewEvent { i.e. it couldn't fit into the display. Currently long events are always shown as we just increase the height of the top canvas. */ guint8 num_columns; - - /* TRUE if the event is at a different UTC offset than our current - timezone, i.e. it is in a different timezone. */ - guint different_timezone : 1; - - /* These are minute offsets from the first time shown in the view. - They range from 0 to 24 * 60. Currently the main canvas always - starts at 12am and the code to handle starting at other times - isn't finished. */ - guint16 start_minute; - guint16 end_minute; - - /* This is the EText item containing the event summary. */ - GnomeCanvasItem *canvas_item; }; diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 0065a00123..3aa58a0a36 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -1000,7 +1000,7 @@ e_week_view_get_selected_events (ECalView *cal_view) } if (event) - list = g_list_prepend (list, event->comp); + list = g_list_prepend (list, event); return list; } diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index 0d071a7d1f..c879797edd 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -143,17 +143,9 @@ struct _EWeekViewEventSpan { typedef struct _EWeekViewEvent EWeekViewEvent; struct _EWeekViewEvent { - CalComponent *comp; - time_t start; - time_t end; - guint16 start_minute; /* Minutes from the start of the day. */ - guint16 end_minute; + E_CAL_VIEW_EVENT_FIELDS gint spans_index; guint8 num_spans; - - /* TRUE if the event is at a different UTC offset than our current - timezone, i.e. it is in a different timezone. */ - guint different_timezone : 1; }; |