Hi, how about the review progress? Thanks, Bolian Bolian Yin wrote:
|
Index: calendar/ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v retrieving revision 1.1871 diff -u -r1.1871 ChangeLog --- calendar/ChangeLog 15 Sep 2003 09:30:59 -0000 1.1871 +++ calendar/ChangeLog 16 Sep 2003 07:20:56 -0000 @@ -1,3 +1,13 @@ +2003-09-15 Bolian Yin <bolian yin sun com> + + * gui/e-cal-view.c: add new signal "selected_time_changed" + * gui/e-day-view-main-item.c (e_day_view_main_item_class_init): + a11y initialization + * gui/e-day-view-top-item (e_day_view_top_item_get_day_label): + new public function. + * gui/e-day-view.c (e_day_view_ensure_rows_visible, e_day_view_update_calendar_selection_time): make static functions public + (e_day_view_cursor_key_up, e_day_view_cursor_key_down, e_day_view_cursor_key_left, e_day_view_cursor_key_right): emit "selected_time_changed". + 2003-09-15 Harry Lu <harry lu sun com> * gui/apps_evolution_calendar.schemas: change last_notification_time's Index: calendar/gui/e-cal-view.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.c,v retrieving revision 1.15 diff -u -r1.15 e-cal-view.c --- calendar/gui/e-cal-view.c 20 Aug 2003 12:02:32 -0000 1.15 +++ calendar/gui/e-cal-view.c 16 Sep 2003 07:20:58 -0000 @@ -82,6 +82,7 @@ /* Signal IDs */ enum { SELECTION_CHANGED, + SELECTED_TIME_CHANGED, TIMEZONE_CHANGED, EVENT_CHANGED, EVENT_ADDED, @@ -106,6 +107,14 @@ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + e_cal_view_signals[SELECTED_TIME_CHANGED] = + g_signal_new ("selected_time_changed", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (ECalViewClass, selected_time_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); e_cal_view_signals[TIMEZONE_CHANGED] = g_signal_new ("timezone_changed", G_TYPE_FROM_CLASS (klass), @@ -139,6 +148,7 @@ object_class->destroy = e_cal_view_destroy; klass->selection_changed = NULL; + klass->selected_time_changed = NULL; klass->event_changed = NULL; klass->event_added = NULL; Index: calendar/gui/e-cal-view.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-cal-view.h,v retrieving revision 1.11 diff -u -r1.11 e-cal-view.h --- calendar/gui/e-cal-view.h 20 Aug 2003 10:16:59 -0000 1.11 +++ calendar/gui/e-cal-view.h 16 Sep 2003 07:20:58 -0000 @@ -76,6 +76,7 @@ /* Notification signals */ void (* selection_changed) (ECalView *cal_view); + void (* selected_time_changed) (ECalView *cal_view); void (* timezone_changed) (ECalView *cal_view, icaltimezone *old_zone, icaltimezone *new_zone); void (* event_changed) (ECalView *day_view, ECalViewEvent *event); void (* event_added) (ECalView *day_view, ECalViewEvent *event); Index: calendar/gui/e-day-view-main-item.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-main-item.c,v retrieving revision 1.34 diff -u -r1.34 e-day-view-main-item.c --- calendar/gui/e-day-view-main-item.c 20 Aug 2003 10:16:59 -0000 1.34 +++ calendar/gui/e-day-view-main-item.c 16 Sep 2003 07:20:59 -0000 @@ -31,6 +31,7 @@ #include "e-util/e-categories-config.h" #include "e-day-view-layout.h" #include "e-day-view-main-item.h" +#include "ea-calendar.h" static void e_day_view_main_item_class_init (EDayViewMainItemClass *class); static void e_day_view_main_item_init (EDayViewMainItem *dvtitem); @@ -106,6 +107,9 @@ item_class->draw = e_day_view_main_item_draw; item_class->point = e_day_view_main_item_point; item_class->event = e_day_view_main_item_event; + + /* init the accessibility support for e_day_view */ + e_day_view_main_item_a11y_init (); } Index: calendar/gui/e-day-view-top-item.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-top-item.c,v retrieving revision 1.36 diff -u -r1.36 e-day-view-top-item.c --- calendar/gui/e-day-view-top-item.c 20 Aug 2003 10:16:59 -0000 1.36 +++ calendar/gui/e-day-view-top-item.c 16 Sep 2003 07:21:00 -0000 @@ -165,12 +165,10 @@ EDayView *day_view; GtkStyle *style; GdkGC *gc, *fg_gc, *bg_gc, *light_gc, *dark_gc; - gchar buffer[128], *format; + gchar buffer[128]; GdkRectangle clip_rect; gint canvas_width, canvas_height, left_edge, day, date_width, date_x; gint item_height, event_num; - struct tm day_start = { 0 }; - struct icaltimetype day_start_tt; PangoLayout *layout; #if 0 @@ -245,34 +243,8 @@ /* Draw the date. Set a clipping rectangle so we don't draw over the next day. */ for (day = 0; day < day_view->days_shown; day++) { - day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], FALSE, - e_cal_view_get_timezone (E_CAL_VIEW (day_view))); - day_start.tm_year = day_start_tt.year - 1900; - day_start.tm_mon = day_start_tt.month - 1; - day_start.tm_mday = day_start_tt.day; - day_start.tm_isdst = -1; - - day_start.tm_wday = time_day_of_week (day_start_tt.day, - day_start_tt.month - 1, - day_start_tt.year); - - if (day_view->date_format == E_DAY_VIEW_DATE_FULL) - /* strftime format %A = full weekday name, %d = day of month, - %B = full month name. Don't use any other specifiers. */ - format = _("%A %d %B"); - else if (day_view->date_format == E_DAY_VIEW_DATE_ABBREVIATED) - /* strftime format %a = abbreviated weekday name, %d = day of month, - %b = abbreviated month name. Don't use any other specifiers. */ - format = _("%a %d %b"); - else if (day_view->date_format == E_DAY_VIEW_DATE_NO_WEEKDAY) - /* strftime format %d = day of month, %b = abbreviated month name. - Don't use any other specifiers. */ - format = _("%d %b"); - else - format = "%d"; - - e_utf8_strftime (buffer, sizeof (buffer), format, &day_start); - + e_day_view_top_item_get_day_label (day_view, day, + buffer, sizeof (buffer)); clip_rect.x = day_view->day_offsets[day] - x; clip_rect.y = 2 - y; clip_rect.width = day_view->day_widths[day]; @@ -690,4 +662,40 @@ return FALSE; } +void +e_day_view_top_item_get_day_label (EDayView *day_view, gint day, + gchar *buffer, gint buffer_len) +{ + struct icaltimetype day_start_tt; + struct tm day_start = { 0 }; + gchar *format; + day_start_tt = icaltime_from_timet_with_zone (day_view->day_starts[day], + FALSE, + e_cal_view_get_timezone (E_CAL_VIEW (day_view))); + day_start.tm_year = day_start_tt.year - 1900; + day_start.tm_mon = day_start_tt.month - 1; + day_start.tm_mday = day_start_tt.day; + day_start.tm_isdst = -1; + + day_start.tm_wday = time_day_of_week (day_start_tt.day, + day_start_tt.month - 1, + day_start_tt.year); + + if (day_view->date_format == E_DAY_VIEW_DATE_FULL) + /* strftime format %A = full weekday name, %d = day of month, + %B = full month name. Don't use any other specifiers. */ + format = _("%A %d %B"); + else if (day_view->date_format == E_DAY_VIEW_DATE_ABBREVIATED) + /* strftime format %a = abbreviated weekday name, %d = day of month, + %b = abbreviated month name. Don't use any other specifiers. */ + format = _("%a %d %b"); + else if (day_view->date_format == E_DAY_VIEW_DATE_NO_WEEKDAY) + /* strftime format %d = day of month, %b = abbreviated month name. + Don't use any other specifiers. */ + format = _("%d %b"); + else + format = "%d"; + + e_utf8_strftime (buffer, buffer_len, format, &day_start); +} Index: calendar/gui/e-day-view-top-item.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view-top-item.h,v retrieving revision 1.5 diff -u -r1.5 e-day-view-top-item.h --- calendar/gui/e-day-view-top-item.h 27 Oct 2001 16:44:11 -0000 1.5 +++ calendar/gui/e-day-view-top-item.h 16 Sep 2003 07:21:00 -0000 @@ -55,7 +55,8 @@ GtkType e_day_view_top_item_get_type (void); - +void e_day_view_top_item_get_day_label (EDayView *day_view, gint day, + gchar *buffer, gint buffer_len); #ifdef __cplusplus Index: calendar/gui/e-day-view.c =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v retrieving revision 1.219 diff -u -r1.219 e-day-view.c --- calendar/gui/e-day-view.c 1 Sep 2003 06:15:33 -0000 1.219 +++ calendar/gui/e-day-view.c 16 Sep 2003 07:21:05 -0000 @@ -182,9 +182,6 @@ GdkEventKey *event); static void e_day_view_cursor_key_right (EDayView *day_view, GdkEventKey *event); -static void e_day_view_ensure_rows_visible (EDayView *day_view, - gint start_row, - gint end_row); static void e_day_view_scroll (EDayView *day_view, gfloat pages_to_scroll); @@ -217,7 +214,6 @@ GdkEventScroll *scroll, EDayView *day_view); -static void e_day_view_update_calendar_selection_time (EDayView *day_view); static gboolean e_day_view_on_main_canvas_motion (GtkWidget *widget, GdkEventMotion *event, EDayView *day_view); @@ -3414,7 +3410,7 @@ } -static void +void e_day_view_update_calendar_selection_time (EDayView *day_view) { time_t start, end; @@ -5348,6 +5344,7 @@ day_view->selection_start_row, day_view->selection_end_row); + g_signal_emit_by_name (day_view, "selected_time_changed"); e_day_view_update_calendar_selection_time (day_view); /* FIXME: Optimise? */ @@ -5380,6 +5377,7 @@ day_view->selection_start_row, day_view->selection_end_row); + g_signal_emit_by_name (day_view, "selected_time_changed"); e_day_view_update_calendar_selection_time (day_view); /* FIXME: Optimise? */ @@ -5403,6 +5401,7 @@ gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->main_canvas); } + g_signal_emit_by_name (day_view, "selected_time_changed"); } @@ -5421,6 +5420,7 @@ gtk_widget_queue_draw (day_view->top_canvas); gtk_widget_queue_draw (day_view->main_canvas); } + g_signal_emit_by_name (day_view, "selected_time_changed"); } @@ -5468,7 +5468,7 @@ } -static void +void e_day_view_ensure_rows_visible (EDayView *day_view, gint start_row, gint end_row) Index: calendar/gui/e-day-view.h =================================================================== RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.h,v retrieving revision 1.51 diff -u -r1.51 e-day-view.h --- calendar/gui/e-day-view.h 20 Aug 2003 10:16:59 -0000 1.51 +++ calendar/gui/e-day-view.h 16 Sep 2003 07:21:06 -0000 @@ -592,6 +592,11 @@ GnomeCanvasItem *item, gint *day_return, gint *event_num_return); +void e_day_view_update_calendar_selection_time (EDayView *day_view); +void e_day_view_ensure_rows_visible (EDayView *day_view, + gint start_row, + gint end_row); + #ifdef __cplusplus } Index: a11y/ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v retrieving revision 1.4 diff -u -r1.4 ChangeLog --- a11y/ChangeLog 27 Aug 2003 03:36:40 -0000 1.4 +++ a11y/ChangeLog 16 Sep 2003 07:21:06 -0000 @@ -1,3 +1,11 @@ +2003-09-16 Bolian Yin <bolian yin sun com> + + * Makefile.am: add entries for new files + * New files added: + ea-day-view-main-item.c ea-day-view-main-item.h + ea-day-view-cell.c ea-day-view-cell.h + * Add debug info and remove some non-C99 compilers warnings. + 2003-08-27 Bolian Yin <bolian yin sun com> * Makefile.am: add widgets directory; move calendar idl stuff to calendar directory; stop make a single shared lib for whole a11y stuff. Index: a11y/calendar/Makefile.am =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/Makefile.am,v retrieving revision 1.3 diff -u -r1.3 Makefile.am --- a11y/calendar/Makefile.am 27 Aug 2003 03:36:41 -0000 1.3 +++ a11y/calendar/Makefile.am 16 Sep 2003 07:21:06 -0000 @@ -76,6 +76,10 @@ ea-cal-view-event.h \ ea-day-view.c \ ea-day-view.h \ + ea-day-view-main-item.c \ + ea-day-view-main-item.h \ + ea-day-view-cell.c \ + ea-day-view-cell.h \ ea-week-view.c \ ea-week-view.h \ ea-gnome-calendar.c \ Index: a11y/calendar/ea-cal-view-event.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-cal-view-event.c,v retrieving revision 1.4 diff -u -r1.4 ea-cal-view-event.c --- a11y/calendar/ea-cal-view-event.c 27 Aug 2003 03:36:41 -0000 1.4 +++ a11y/calendar/ea-cal-view-event.c 16 Sep 2003 07:21:07 -0000 @@ -42,6 +42,11 @@ gint *x, gint *y, gint *width, gint *height, AtkCoordType coord_type); +#ifdef ACC_DEBUG +static gint n_ea_cal_view_event_created = 0, n_ea_cal_view_event_destroyed = 0; +static void ea_cal_view_finalize (GObject *object); +#endif + static gpointer parent_class = NULL; GType @@ -100,6 +105,10 @@ ea_cal_view_event_class_init (EaCalViewEventClass *klass) { AtkObjectClass *class = ATK_OBJECT_CLASS (klass); +#ifdef ACC_DEBUG + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = ea_cal_view_finalize; +#endif parent_class = g_type_class_peek_parent (klass); @@ -111,6 +120,15 @@ } +#ifdef ACC_DEBUG +static void ea_cal_view_finalize (GObject *object) +{ + ++n_ea_cal_view_event_destroyed; + printf ("ACC_DEBUG: n_ea_cal_view_event_destroyed = %d\n", + n_ea_cal_view_event_destroyed); +} +#endif + AtkObject* ea_cal_view_event_new (GObject *obj) { @@ -157,8 +175,9 @@ event_role = atk_role_register ("Calendar Event"); atk_obj->role = event_role; #ifdef ACC_DEBUG - printf ("EvoAcc: ea_cal_view_event created %p for item=%p\n", - atk_obj, target_obj); + ++n_ea_cal_view_event_created; + printf ("ACC_DEBUG: n_ea_cal_view_event_created = %d\n", + n_ea_cal_view_event_created); #endif } @@ -235,7 +254,7 @@ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name); #ifdef ACC_DEBUG printf("EvoAcc: name for event accobj=%p, is %s\n", - accessible, new_name); + (void *)accessible, new_name); #endif g_free (new_name); return accessible->name; Index: a11y/calendar/ea-cal-view.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-cal-view.c,v retrieving revision 1.2 diff -u -r1.2 ea-cal-view.c --- a11y/calendar/ea-cal-view.c 20 Aug 2003 07:46:04 -0000 1.2 +++ a11y/calendar/ea-cal-view.c 16 Sep 2003 07:21:07 -0000 @@ -33,7 +33,6 @@ static void ea_cal_view_class_init (EaCalViewClass *klass); static AtkObject* ea_cal_view_get_parent (AtkObject *accessible); -static gint ea_cal_view_get_index_in_parent (AtkObject *accessible); static void ea_cal_view_real_initialize (AtkObject *accessible, gpointer data); static void ea_cal_view_event_changed_cb (ECalView *cal_view, @@ -95,7 +94,6 @@ parent_class = g_type_class_peek_parent (klass); class->get_parent = ea_cal_view_get_parent; - class->get_index_in_parent = ea_cal_view_get_index_in_parent; class->initialize = ea_cal_view_real_initialize; } @@ -120,12 +118,15 @@ { ECalView *cal_view; GnomeCalendar *gcal; + static AtkRole role = ATK_ROLE_INVALID; g_return_if_fail (EA_IS_CAL_VIEW (accessible)); g_return_if_fail (E_IS_CAL_VIEW (data)); ATK_OBJECT_CLASS (parent_class)->initialize (accessible, data); - accessible->role = ATK_ROLE_CANVAS; + if (role == ATK_ROLE_INVALID) + role = atk_role_register ("Calendar View"); + accessible->role = role; cal_view = E_CAL_VIEW (data); /* add listener for event_changed, event_added @@ -164,12 +165,6 @@ return gtk_widget_get_accessible (GTK_WIDGET(gnomeCalendar)); } -static gint -ea_cal_view_get_index_in_parent (AtkObject *accessible) -{ - return 1; -} - static void ea_cal_view_event_changed_cb (ECalView *cal_view, ECalViewEvent *event, gpointer data) @@ -201,7 +196,7 @@ } if (event_atk_obj) { #ifdef ACC_DEBUG - printf ("AccDebug: event=%p changed\n", event); + printf ("AccDebug: event=%p changed\n", (void *)event); #endif g_object_notify (G_OBJECT(event_atk_obj), "accessible-name"); g_signal_emit_by_name (event_atk_obj, "visible_data_changed"); @@ -245,7 +240,7 @@ if (index < 0) return; #ifdef ACC_DEBUG - printf ("AccDebug: event=%p added\n", event); + printf ("AccDebug: event=%p added\n", (void *)event); #endif g_signal_emit_by_name (atk_obj, "children_changed::add", index, event_atk_obj, NULL); @@ -255,17 +250,22 @@ static void ea_cal_view_dates_change_cb (GnomeCalendar *gcal, gpointer data) { - AtkObject *atk_obj; + AtkObject *ea_cal_view; g_return_if_fail (GNOME_IS_CALENDAR (gcal)); g_return_if_fail (data); g_return_if_fail (EA_IS_CAL_VIEW (data)); - atk_obj = ATK_OBJECT(data); - if (atk_obj->name) { - g_free (atk_obj->name); - atk_obj->name = NULL; - } - g_object_notify (G_OBJECT (data), "accessible-name"); - g_signal_emit_by_name (data, "visible_data_changed"); + ea_cal_view = ATK_OBJECT(data); + + if (ea_cal_view->name) { + g_free (ea_cal_view->name); + ea_cal_view->name = NULL; + } + g_object_notify (G_OBJECT (ea_cal_view), "accessible-name"); + g_signal_emit_by_name (ea_cal_view, "visible_data_changed"); + g_signal_emit_by_name (ea_cal_view, "children_changed", NULL); +#ifdef ACC_DEBUG + printf ("AccDebug: cal view date changed\n"); +#endif } Index: a11y/calendar/ea-calendar.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-calendar.c,v retrieving revision 1.2 diff -u -r1.2 ea-calendar.c --- a11y/calendar/ea-calendar.c 20 Aug 2003 07:46:05 -0000 1.2 +++ a11y/calendar/ea-calendar.c 16 Sep 2003 07:21:07 -0000 @@ -31,57 +31,65 @@ #include "calendar/ea-cal-view.h" #include "calendar/ea-cal-view-event.h" #include "calendar/ea-day-view.h" +#include "calendar/ea-day-view-main-item.h" #include "calendar/ea-week-view.h" #include "calendar/ea-gnome-calendar.h" -EA_FACTORY (EA_TYPE_CAL_VIEW, ea_cal_view, ea_cal_view_new); -EA_FACTORY (EA_TYPE_DAY_VIEW, ea_day_view, ea_day_view_new); -EA_FACTORY (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new); -EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new); +EA_FACTORY (EA_TYPE_CAL_VIEW, ea_cal_view, ea_cal_view_new) +EA_FACTORY (EA_TYPE_DAY_VIEW, ea_day_view, ea_day_view_new) +EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_MAIN_ITEM, ea_day_view_main_item, ea_day_view_main_item_new) +EA_FACTORY (EA_TYPE_WEEK_VIEW, ea_week_view, ea_week_view_new) +EA_FACTORY (EA_TYPE_GNOME_CALENDAR, ea_gnome_calendar, ea_gnome_calendar_new) static gboolean ea_calendar_focus_watcher (GSignalInvocationHint *ihint, - guint n_param_values, - const GValue *param_values, - gpointer data); + guint n_param_values, + const GValue *param_values, + gpointer data); void gnome_calendar_a11y_init (void) { - EA_SET_FACTORY (gnome_calendar_get_type(), ea_gnome_calendar); - /* we only add focus watcher when accessibility is enabled - */ - if (atk_get_root ()) - g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); + EA_SET_FACTORY (gnome_calendar_get_type(), ea_gnome_calendar); + /* we only add focus watcher when accessibility is enabled + */ + if (atk_get_root ()) { + g_signal_add_emission_hook (g_signal_lookup ("event", E_TYPE_TEXT), + 0, ea_calendar_focus_watcher, + NULL, (GDestroyNotify) NULL); + g_signal_add_emission_hook (g_signal_lookup ("event-after", + e_day_view_get_type()), + 0, ea_calendar_focus_watcher, + NULL, (GDestroyNotify) NULL); + g_signal_add_emission_hook (g_signal_lookup ("event", + e_day_view_main_item_get_type()), + 0, ea_calendar_focus_watcher, + NULL, (GDestroyNotify) NULL); + + } } void e_cal_view_a11y_init (void) { - EA_SET_FACTORY (e_cal_view_get_type(), ea_cal_view); - /* we only add focus watcher when accessibility is enabled - */ -#if 0 - if (atk_get_root ()) - g_signal_add_emission_hook (g_signal_lookup ("selection_time_changed", - e_cal_view_get_type ()), - 0, ea_calendar_focus_watcher, - NULL, (GDestroyNotify) NULL); -#endif + EA_SET_FACTORY (e_cal_view_get_type(), ea_cal_view); } void e_day_view_a11y_init (void) { - EA_SET_FACTORY (e_day_view_get_type(), ea_day_view); + EA_SET_FACTORY (e_day_view_get_type(), ea_day_view); +} + +void e_day_view_main_item_a11y_init (void) +{ + EA_SET_FACTORY (e_day_view_main_item_get_type (), ea_day_view_main_item); } void e_week_view_a11y_init (void) { - EA_SET_FACTORY (e_week_view_get_type(), ea_week_view); + EA_SET_FACTORY (e_week_view_get_type(), ea_week_view); } gboolean @@ -90,46 +98,53 @@ const GValue *param_values, gpointer data) { - GObject *object; - GdkEvent *event; - - object = g_value_get_object (param_values + 0); - event = g_value_get_boxed (param_values + 1); - - if (E_IS_TEXT (object)) { - /* "event" signal on canvas item - */ - GnomeCanvasItem *canvas_item; - AtkObject *ea_event; - - canvas_item = GNOME_CANVAS_ITEM (object); - if (event->type == GDK_FOCUS_CHANGE) { - if (event->focus_change.in) - ea_event = - ea_calendar_helpers_get_accessible_for (canvas_item); - else - /* focus out */ - ea_event = NULL; - atk_focus_tracker_notify (ea_event); - - } - } -#if 0 - else if (E_IS_DAY_VIEW (object)) { - /* "selection_time_changed" signal on day_view - */ - if (ATK_IS_SELECTION (object)) { - AtkSelection *atk_selection; - AtkObject *atk_obj; - atk_selection = ATK_SELECTION (object); - atk_obj = atk_selection_ref_selection (atk_selection, 0); - + GObject *object; + GdkEvent *event; + AtkObject *ea_event = NULL; + + object = g_value_get_object (param_values + 0); + event = g_value_get_boxed (param_values + 1); + + if (E_IS_TEXT (object)) { + /* "event" signal on canvas item + */ + GnomeCanvasItem *canvas_item; + + canvas_item = GNOME_CANVAS_ITEM (object); + if (event->type == GDK_FOCUS_CHANGE) { + if (event->focus_change.in) + ea_event = + ea_calendar_helpers_get_accessible_for (canvas_item); + else + /* focus out */ + ea_event = NULL; + atk_focus_tracker_notify (ea_event); + + } + } + else if (E_IS_DAY_VIEW (object)) { + EDayView *day_view = E_DAY_VIEW (object); + if (event->type == GDK_FOCUS_CHANGE) { + if (event->focus_change.in) { + /* give main item chance to emit focus */ + gnome_canvas_item_grab_focus (day_view->main_canvas_item); + } + } + } + else if (E_IS_DAY_VIEW_MAIN_ITEM (object)) { + if (event->type == GDK_FOCUS_CHANGE) { + if (event->focus_change.in) { + /* we should emit focus on main item */ + ea_event = atk_gobject_accessible_for_object (object); + } + else + /* focus out */ + ea_event = NULL; #ifdef ACC_DEBUG - printf ("EvoAcc: ref a selection %p\n", atk_selection); -#endif - atk_focus_tracker_notify (atk_obj); - } - } + printf ("EvoAcc: focus notify on day main item %p\n", (void *)object); #endif - return TRUE; + atk_focus_tracker_notify (ea_event); + } + } + return TRUE; } Index: a11y/calendar/ea-calendar.h =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-calendar.h,v retrieving revision 1.2 diff -u -r1.2 ea-calendar.h --- a11y/calendar/ea-calendar.h 20 Aug 2003 07:46:05 -0000 1.2 +++ a11y/calendar/ea-calendar.h 16 Sep 2003 07:21:07 -0000 @@ -32,6 +32,7 @@ void gnome_calendar_a11y_init (void); void e_cal_view_a11y_init (void); void e_day_view_a11y_init (void); +void e_day_view_main_item_a11y_init (void); void e_week_view_a11y_init (void); #endif /* _EA_CALENDAR_H__ */ Index: a11y/calendar/ea-day-view-cell.c =================================================================== RCS file: a11y/calendar/ea-day-view-cell.c diff -N a11y/calendar/ea-day-view-cell.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ a11y/calendar/ea-day-view-cell.c 16 Sep 2003 07:21:07 -0000 @@ -0,0 +1,211 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-day-view-cell.c + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Bolian Yin <bolian yin sun com> Sun Microsystem Inc., 2003 + * + */ + +#include "ea-day-view-cell.h" +#include "ea-day-view-main-item.h" +#include "ea-factory.h" + +/* EDayViewCell */ + +static void e_day_view_cell_class_init (EDayViewCellClass *class); + +EA_FACTORY_GOBJECT (EA_TYPE_DAY_VIEW_CELL, ea_day_view_cell, ea_day_view_cell_new) + +GType +e_day_view_cell_get_type (void) +{ + static GType type = 0; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EDayViewCellClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) e_day_view_cell_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EDayViewCell), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + type = g_type_register_static (G_TYPE_OBJECT, + "EDayViewCell", &tinfo, 0); + } + + return type; +} + +static void +e_day_view_cell_class_init (EDayViewCellClass *class) +{ + EA_SET_FACTORY (e_day_view_cell_get_type (), ea_day_view_cell); +} + +EDayViewCell * +e_day_view_cell_new (EDayView *day_view, gint row, gint column) +{ + GObject *object; + EDayViewCell *cell; + + g_return_val_if_fail (E_IS_DAY_VIEW (day_view), NULL); + + object = g_object_new (E_TYPE_DAY_VIEW_CELL, NULL); + cell = E_DAY_VIEW_CELL (object); + cell->day_view = day_view; + cell->row = row; + cell->column = column; + +#ifdef ACC_DEBUG + printf ("EvoAcc: e_day_view_cell created %p\n", (void *)cell); +#endif + + return cell; +} + +/* EaDayViewCell */ + +static void ea_day_view_cell_class_init (EaDayViewCellClass *klass); + +static G_CONST_RETURN gchar* ea_day_view_cell_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_day_view_cell_get_description (AtkObject *accessible); +static gpointer parent_class = NULL; + +#ifdef ACC_DEBUG +static gint n_ea_day_view_cell_created = 0, n_ea_day_view_cell_destroyed = 0; +static void ea_day_view_cell_finalize (GObject *object); +#endif + +GType +ea_day_view_cell_get_type (void) +{ + static GType type = 0; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaDayViewCellClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_day_view_cell_class_init, /* class init */ + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaDayViewCell), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + type = g_type_register_static (ATK_TYPE_GOBJECT_ACCESSIBLE, + "EaDayViewCell", &tinfo, 0); + } + + return type; +} + +static void +ea_day_view_cell_class_init (EaDayViewCellClass *klass) +{ + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + +#ifdef ACC_DEBUG + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = ea_day_view_cell_finalize; +#endif + + parent_class = g_type_class_peek_parent (klass); + + class->get_name = ea_day_view_cell_get_name; + class->get_description = ea_day_view_cell_get_description; +} + +AtkObject* +ea_day_view_cell_new (GObject *obj) +{ + gpointer object; + AtkObject *atk_object; + + g_return_val_if_fail (E_IS_DAY_VIEW_CELL (obj), NULL); + object = g_object_new (EA_TYPE_DAY_VIEW_CELL, NULL); + atk_object = ATK_OBJECT (object); + atk_object_initialize (atk_object, obj); + atk_object->role = ATK_ROLE_UNKNOWN; + +#ifdef ACC_DEBUG + ++n_ea_day_view_cell_created; + printf ("ACC_DEBUG: n_ea_day_view_cell_created = %d\n", + n_ea_day_view_cell_created); +#endif + return atk_object; +} + +#ifdef ACC_DEBUG +static void ea_day_view_cell_finalize (GObject *object) +{ + ++n_ea_day_view_cell_destroyed; + printf ("ACC_DEBUG: n_ea_day_view_cell_destroyed = %d\n", + n_ea_day_view_cell_destroyed); +} +#endif + +static G_CONST_RETURN gchar* +ea_day_view_cell_get_name (AtkObject *accessible) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewCell *cell; + + g_return_val_if_fail (EA_IS_DAY_VIEW_CELL (accessible), NULL); + + if (!accessible->name) { + AtkObject *ea_main_item; + GnomeCanvasItem *main_item; + gchar *new_name = g_strdup (""); + const gchar *row_label, *column_label; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + cell = E_DAY_VIEW_CELL (g_obj); + main_item = cell->day_view->main_canvas_item; + ea_main_item = atk_gobject_accessible_for_object (G_OBJECT (main_item)); + column_label = atk_table_get_column_description (ATK_TABLE (ea_main_item), + cell->column); + row_label = atk_table_get_row_description (ATK_TABLE (ea_main_item), + cell->row); + new_name = g_strconcat (column_label, " ", row_label, NULL); + ATK_OBJECT_CLASS (parent_class)->set_name (accessible, new_name); + g_free (new_name); + } + return accessible->name; +} + +static G_CONST_RETURN gchar* +ea_day_view_cell_get_description (AtkObject *accessible) +{ + return ea_day_view_cell_get_name (accessible); +} Index: a11y/calendar/ea-day-view-cell.h =================================================================== RCS file: a11y/calendar/ea-day-view-cell.h diff -N a11y/calendar/ea-day-view-cell.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ a11y/calendar/ea-day-view-cell.h 16 Sep 2003 07:21:07 -0000 @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-day-view-cell.h + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Bolian Yin <bolian yin sun com> Sun Microsystem Inc., 2003 + * + */ + +#ifndef __EA_DAY_VIEW_CELL_H__ +#define __EA_DAY_VIEW_CELL_H__ + +#include <atk/atkgobjectaccessible.h> +#include "e-day-view.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define E_TYPE_DAY_VIEW_CELL (e_day_view_cell_get_type ()) +#define E_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCell)) +#define E_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass)) +#define E_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DAY_VIEW_CELL)) +#define E_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DAY_VIEW_CELL)) +#define E_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_DAY_VIEW_CELL, EDayViewCellClass)) + +typedef struct _EDayViewCell EDayViewCell; +typedef struct _EDayViewCellClass EDayViewCellClass; + +struct _EDayViewCell +{ + GObject parent; + EDayView *day_view; + gint row; + gint column; +}; + +GType e_day_view_cell_get_type (void); + +struct _EDayViewCellClass +{ + GObjectClass parent_class; +}; + +EDayViewCell * e_day_view_cell_new (EDayView *day_view, gint row, gint column); + +#define EA_TYPE_DAY_VIEW_CELL (ea_day_view_cell_get_type ()) +#define EA_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCell)) +#define EA_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass)) +#define EA_IS_DAY_VIEW_CELL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_CELL)) +#define EA_IS_DAY_VIEW_CELL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_CELL)) +#define EA_DAY_VIEW_CELL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_CELL, EaDayViewCellClass)) + +typedef struct _EaDayViewCell EaDayViewCell; +typedef struct _EaDayViewCellClass EaDayViewCellClass; + +struct _EaDayViewCell +{ + AtkGObjectAccessible parent; +}; + +GType ea_day_view_cell_get_type (void); + +struct _EaDayViewCellClass +{ + AtkGObjectAccessibleClass parent_class; +}; + +AtkObject* ea_day_view_cell_new (GObject *gobj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EA_DAY_VIEW_CELL_H__ */ Index: a11y/calendar/ea-day-view-main-item.c =================================================================== RCS file: a11y/calendar/ea-day-view-main-item.c diff -N a11y/calendar/ea-day-view-main-item.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ a11y/calendar/ea-day-view-main-item.c 16 Sep 2003 07:21:08 -0000 @@ -0,0 +1,1343 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-day-view-main-item.c + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Bolian Yin <bolian yin sun com> Sun Microsystem Inc., 2003 + * + */ + +#include "ea-day-view-main-item.h" +#include "e-day-view-top-item.h" +#include "ea-day-view.h" +#include "ea-day-view-cell.h" + +/* DayViewCellData */ + +#define CELL_DATA_MAX_COLUMNS E_DAY_VIEW_MAX_DAYS +#define CELL_DATA_MAX_ROWS (12 * 24) /* when a row = 5 mins */ + +struct _DayViewCellData { + gint columns; + gint rows; + char *column_labels[CELL_DATA_MAX_COLUMNS]; + char *row_labels[CELL_DATA_MAX_ROWS]; + EDayViewCell **cells; +}; + +typedef struct _DayViewCellData DayViewCellData; + +DayViewCellData * day_view_cell_data_create (gint days, gint rows); +void day_view_cell_data_destroy (DayViewCellData * cell_data); +EDayViewCell * day_view_cell_data_get_cell (DayViewCellData * cell_data, + gint row, gint column); +void day_view_cell_data_set_cell (DayViewCellData * cell_data, + gint row, gint column, EDayViewCell *cell); +EDayViewCell * +day_view_cell_data_get_cell_at_index (DayViewCellData * cell_data, gint index); +G_CONST_RETURN gchar* +day_view_cell_data_get_column_label (DayViewCellData * cell_data, gint day); +void day_view_cell_data_set_column_label (DayViewCellData * cell_data, + gint day, const gchar *label); +G_CONST_RETURN gchar* +day_view_cell_data_get_row_label (DayViewCellData * cell_data, gint row); +void day_view_cell_data_set_row_label (DayViewCellData * cell_data, + gint row, const gchar *label); + +/* EaDayViewMainItem */ +static void ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass); + +static void ea_day_view_main_item_finalize (GObject *object); +static G_CONST_RETURN gchar* ea_day_view_main_item_get_name (AtkObject *accessible); +static G_CONST_RETURN gchar* ea_day_view_main_item_get_description (AtkObject *accessible); + +static gint ea_day_view_main_item_get_n_children (AtkObject *obj); +static AtkObject* ea_day_view_main_item_ref_child (AtkObject *obj, + gint i); +static AtkObject * ea_day_view_main_item_get_parent (AtkObject *accessible); +static gint ea_day_view_main_item_get_index_in_parent (AtkObject *accessible); + +/* callbacks */ +static void ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data); +static void ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data); + +/* atk table interface */ +static void atk_table_interface_init (AtkTableIface *iface); +static gint table_interface_get_index_at (AtkTable *table, + gint row, + gint column); +static gint table_interface_get_column_at_index (AtkTable *table, + gint index); +static gint table_interface_get_row_at_index (AtkTable *table, + gint index); +static AtkObject* table_interface_ref_at (AtkTable *table, + gint row, + gint column); +static gint table_interface_get_n_rows (AtkTable *table); +static gint table_interface_get_n_columns (AtkTable *table); +static gint table_interface_get_column_extent_at (AtkTable *table, + gint row, + gint column); +static gint table_interface_get_row_extent_at (AtkTable *table, + gint row, + gint column); + +static gboolean table_interface_is_row_selected (AtkTable *table, + gint row); +static gboolean table_interface_is_column_selected (AtkTable *table, + gint row); +static gboolean table_interface_is_selected (AtkTable *table, + gint row, + gint column); +static gint table_interface_get_selected_rows (AtkTable *table, + gint **rows_selected); +static gint table_interface_get_selected_columns (AtkTable *table, + gint **columns_selected); +static gboolean table_interface_add_row_selection (AtkTable *table, gint row); +static gboolean table_interface_remove_row_selection (AtkTable *table, + gint row); +static gboolean table_interface_add_column_selection (AtkTable *table, + gint column); +static gboolean table_interface_remove_column_selection (AtkTable *table, + gint column); +static AtkObject* table_interface_get_row_header (AtkTable *table, gint row); +static AtkObject* table_interface_get_column_header (AtkTable *table, + gint in_col); +static AtkObject* table_interface_get_caption (AtkTable *table); + +static G_CONST_RETURN gchar* +table_interface_get_column_description (AtkTable *table, gint in_col); + +static G_CONST_RETURN gchar* +table_interface_get_row_description (AtkTable *table, gint row); + +static AtkObject* table_interface_get_summary (AtkTable *table); + +/* atk selection interface */ +static void atk_selection_interface_init (AtkSelectionIface *iface); +static gboolean selection_interface_add_selection (AtkSelection *selection, + gint i); +static gboolean selection_interface_clear_selection (AtkSelection *selection); +static AtkObject* selection_interface_ref_selection (AtkSelection *selection, + gint i); +static gint selection_interface_get_selection_count (AtkSelection *selection); +static gboolean selection_interface_is_child_selected (AtkSelection *selection, + gint i); + +/* helpers */ +static DayViewCellData * +ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item); + +static void +ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item); + +static gint +ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item, + gint row, gint column); +static gint +ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item, + gint index); +static gint +ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item, + gint index); +static gint +ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, + gint row, gchar *buffer, + gint buffer_size); + +#ifdef ACC_DEBUG +static gint n_ea_day_view_main_item_created = 0; +static gint n_ea_day_view_main_item_destroyed = 0; +#endif + +static gpointer parent_class = NULL; + +GType +ea_day_view_main_item_get_type (void) +{ + static GType type = 0; + AtkObjectFactory *factory; + GTypeQuery query; + GType derived_atk_type; + + if (!type) { + static GTypeInfo tinfo = { + sizeof (EaDayViewMainItemClass), + (GBaseInitFunc) NULL, /* base init */ + (GBaseFinalizeFunc) NULL, /* base finalize */ + (GClassInitFunc) ea_day_view_main_item_class_init, + (GClassFinalizeFunc) NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EaDayViewMainItem), /* instance size */ + 0, /* nb preallocs */ + (GInstanceInitFunc) NULL, /* instance init */ + NULL /* value table */ + }; + + static const GInterfaceInfo atk_table_info = { + (GInterfaceInitFunc) atk_table_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + static const GInterfaceInfo atk_selection_info = { + (GInterfaceInitFunc) atk_selection_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + + /* + * Figure out the size of the class and instance + * we are run-time deriving from (GailCanvasItem, in this case) + * + */ + + factory = atk_registry_get_factory (atk_get_default_registry (), + e_day_view_main_item_get_type()); + derived_atk_type = atk_object_factory_get_accessible_type (factory); + g_type_query (derived_atk_type, &query); + + tinfo.class_size = query.class_size; + tinfo.instance_size = query.instance_size; + + type = g_type_register_static (derived_atk_type, + "EaDayViewMainItem", &tinfo, 0); + g_type_add_interface_static (type, ATK_TYPE_TABLE, + &atk_table_info); + g_type_add_interface_static (type, ATK_TYPE_SELECTION, + &atk_selection_info); + } + + return type; +} + +static void +ea_day_view_main_item_class_init (EaDayViewMainItemClass *klass) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + AtkObjectClass *class = ATK_OBJECT_CLASS (klass); + + gobject_class->finalize = ea_day_view_main_item_finalize; + parent_class = g_type_class_peek_parent (klass); + + class->get_name = ea_day_view_main_item_get_name; + class->get_description = ea_day_view_main_item_get_description; + + class->get_n_children = ea_day_view_main_item_get_n_children; + class->ref_child = ea_day_view_main_item_ref_child; + class->get_parent = ea_day_view_main_item_get_parent; + class->get_index_in_parent = ea_day_view_main_item_get_index_in_parent; +} + +AtkObject* +ea_day_view_main_item_new (GObject *obj) +{ + AtkObject *accessible; + GnomeCalendar *gcal; + EDayViewMainItem *main_item; + + g_return_val_if_fail (E_IS_DAY_VIEW_MAIN_ITEM (obj), NULL); + + accessible = ATK_OBJECT (g_object_new (EA_TYPE_DAY_VIEW_MAIN_ITEM, + NULL)); + + atk_object_initialize (accessible, obj); + +#ifdef ACC_DEBUG + ++n_ea_day_view_main_item_created; + printf ("ACC_DEBUG: n_ea_day_view_main_item_created = %d\n", + n_ea_day_view_main_item_created); +#endif + main_item = E_DAY_VIEW_MAIN_ITEM (obj); + g_signal_connect (main_item->day_view, "selected_time_changed", + G_CALLBACK (ea_day_view_main_item_time_change_cb), + accessible); + + /* listen for date changes of calendar */ + gcal = e_cal_view_get_calendar (E_CAL_VIEW (main_item->day_view)); + if (gcal) + g_signal_connect (gcal, "dates_shown_changed", + G_CALLBACK (ea_day_view_main_item_dates_change_cb), + accessible); + + return accessible; +} + +static void +ea_day_view_main_item_finalize (GObject *object) +{ + EaDayViewMainItem *ea_main_item; + + g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (object)); + + ea_main_item = EA_DAY_VIEW_MAIN_ITEM (object); + + /* Free the allocated cell data */ + ea_day_view_main_item_destory_cell_data (ea_main_item); + + G_OBJECT_CLASS (parent_class)->finalize (object); +#ifdef ACC_DEBUG + ++n_ea_day_view_main_item_destroyed; + printf ("ACC_DEBUG: n_ea_day_view_main_item_destroyed = %d\n", + n_ea_day_view_main_item_destroyed); +#endif +} + +static G_CONST_RETURN gchar* +ea_day_view_main_item_get_name (AtkObject *accessible) +{ + return "day view time table"; +} + +static G_CONST_RETURN gchar* +ea_day_view_main_item_get_description (AtkObject *accessible) +{ + return "a table to view and select the current time range"; +} + +static gint +ea_day_view_main_item_get_n_children (AtkObject *accessible) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + + g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + return day_view->rows * day_view->days_shown; +} + +static AtkObject * +ea_day_view_main_item_ref_child (AtkObject *accessible, gint index) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + gint n_children; + EDayViewCell *cell; + DayViewCellData *cell_data; + EaDayViewMainItem *ea_main_item; + gint row, column; + + g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + n_children = ea_day_view_main_item_get_n_children (accessible); + if (index < 0 || index >= n_children) + return NULL; + + ea_main_item = EA_DAY_VIEW_MAIN_ITEM (accessible); + cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); + if (!cell_data) + return NULL; + + row = ea_day_view_main_item_get_row_at_index (ea_main_item, index); + column = ea_day_view_main_item_get_column_at_index (ea_main_item, index); + + cell = day_view_cell_data_get_cell (cell_data, row, column); + if (!cell) { + cell = e_day_view_cell_new (day_view, row, column); + day_view_cell_data_set_cell (cell_data, row, column, cell); + } + return g_object_ref (atk_gobject_accessible_for_object (G_OBJECT(cell))); +} + +static AtkObject * +ea_day_view_main_item_get_parent (AtkObject *accessible) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + + g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), NULL); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + return gtk_widget_get_accessible (GTK_WIDGET (main_item->day_view)); +} + +static gint +ea_day_view_main_item_get_index_in_parent (AtkObject *accessible) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + + g_return_val_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (accessible), -1); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (accessible); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + /* always the first child of ea-day-view */ + return 0; +} + +/* callbacks */ + +static void +ea_day_view_main_item_dates_change_cb (GnomeCalendar *gcal, gpointer data) +{ + EaDayViewMainItem *ea_main_item; + + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (data); + g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data)); + + ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data); + +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_day_view_main_item update cb\n"); +#endif + + ea_day_view_main_item_destory_cell_data (ea_main_item); +} + +static void +ea_day_view_main_item_time_change_cb (EDayView *day_view, gpointer data) +{ + EaDayViewMainItem *ea_main_item; + + g_return_if_fail (E_IS_DAY_VIEW (day_view)); + g_return_if_fail (data); + g_return_if_fail (EA_IS_DAY_VIEW_MAIN_ITEM (data)); + + ea_main_item = EA_DAY_VIEW_MAIN_ITEM (data); + +#ifdef ACC_DEBUG + printf ("EvoAcc: ea_day_view_main_item time changed cb\n"); +#endif + g_signal_emit_by_name (data, "selection_changed"); +} + +/* helpers */ + +static gint +ea_day_view_main_item_get_child_index_at (EaDayViewMainItem *ea_main_item, + gint row, gint column) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + + g_return_val_if_fail (ea_main_item, -1); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (row >= 0 && row < day_view->rows && + column >= 0 && column < day_view->days_shown) + return column * day_view->rows + row; + return -1; +} + +static gint +ea_day_view_main_item_get_row_at_index (EaDayViewMainItem *ea_main_item, + gint index) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + gint n_children; + + g_return_val_if_fail (ea_main_item, -1); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); + if (index >= 0 && index < n_children) + return index % day_view->rows; + return -1; +} + +static gint +ea_day_view_main_item_get_column_at_index (EaDayViewMainItem *ea_main_item, + gint index) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + gint n_children; + + g_return_val_if_fail (ea_main_item, -1); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + n_children = ea_day_view_main_item_get_n_children (ATK_OBJECT (ea_main_item)); + if (index >= 0 && index < n_children) + return index / day_view->rows; + return -1; +} + +static gint +ea_day_view_main_item_get_row_label (EaDayViewMainItem *ea_main_item, + gint row, gchar *buffer, gint buffer_size) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + gchar *suffix; + gint hour, minute, suffix_width; + + g_return_val_if_fail (ea_main_item, 0); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return 0 ; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + hour = day_view->first_hour_shown; + minute = day_view->first_minute_shown; + minute += row * day_view->mins_per_row; + hour = (hour + minute / 60) % 24; + minute %= 60; + + e_day_view_convert_time_to_display (day_view, hour, &hour, + &suffix, &suffix_width); + return g_snprintf (buffer, buffer_size, "%i:%02i %s", + hour, minute, suffix); +} + +static DayViewCellData * +ea_day_view_main_item_get_cell_data (EaDayViewMainItem *ea_main_item) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + DayViewCellData *cell_data; + + g_return_val_if_fail (ea_main_item, NULL); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + cell_data = g_object_get_data (G_OBJECT(ea_main_item), + "ea-day-view-cell-data"); + if (!cell_data) { + cell_data = day_view_cell_data_create (day_view->days_shown, + day_view->rows); + g_object_set_data (G_OBJECT(ea_main_item), + "ea-day-view-cell-data", cell_data); + } + return cell_data; +} + +static void +ea_day_view_main_item_destory_cell_data (EaDayViewMainItem *ea_main_item) +{ + DayViewCellData *cell_data; + + g_return_if_fail (ea_main_item); + + cell_data = g_object_get_data (G_OBJECT(ea_main_item), + "ea-day-view-cell-data"); + if (cell_data) { + day_view_cell_data_destroy (cell_data); + g_object_set_data (G_OBJECT(ea_main_item), + "ea-day-view-cell-data", NULL); + } +} + +/* atk table interface */ + +static void +atk_table_interface_init (AtkTableIface *iface) +{ + g_return_if_fail (iface != NULL); + + iface->ref_at = table_interface_ref_at; + + iface->get_n_rows = table_interface_get_n_rows; + iface->get_n_columns = table_interface_get_n_columns; + iface->get_index_at = table_interface_get_index_at; + iface->get_column_at_index = table_interface_get_column_at_index; + iface->get_row_at_index = table_interface_get_row_at_index; + iface->get_column_extent_at = table_interface_get_column_extent_at; + iface->get_row_extent_at = table_interface_get_row_extent_at; + + iface->is_selected = table_interface_is_selected; + iface->get_selected_rows = table_interface_get_selected_rows; + iface->get_selected_columns = table_interface_get_selected_columns; + iface->is_row_selected = table_interface_is_row_selected; + iface->is_column_selected = table_interface_is_column_selected; + iface->add_row_selection = table_interface_add_row_selection; + iface->remove_row_selection = table_interface_remove_row_selection; + iface->add_column_selection = table_interface_add_column_selection; + iface->remove_column_selection = table_interface_remove_column_selection; + + iface->get_row_header = table_interface_get_row_header; + iface->get_column_header = table_interface_get_column_header; + iface->get_caption = table_interface_get_caption; + iface->get_summary = table_interface_get_summary; + iface->get_row_description = table_interface_get_row_description; + iface->get_column_description = table_interface_get_column_description; +} + +static AtkObject* +table_interface_ref_at (AtkTable *table, + gint row, + gint column) +{ + gint index; + + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + index = ea_day_view_main_item_get_child_index_at (ea_main_item, + row, column); + return ea_day_view_main_item_ref_child (ATK_OBJECT (ea_main_item), index); +} + +static gint +table_interface_get_n_rows (AtkTable *table) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + return day_view->rows; +} + +static gint +table_interface_get_n_columns (AtkTable *table) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + return day_view->days_shown; +} + +static gint +table_interface_get_index_at (AtkTable *table, + gint row, + gint column) +{ + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + return ea_day_view_main_item_get_child_index_at (ea_main_item, + row, column); +} + +static gint +table_interface_get_column_at_index (AtkTable *table, + gint index) +{ + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + return ea_day_view_main_item_get_column_at_index (ea_main_item, index); +} + +static gint +table_interface_get_row_at_index (AtkTable *table, + gint index) +{ + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + return ea_day_view_main_item_get_row_at_index (ea_main_item, index); +} + +static gint +table_interface_get_column_extent_at (AtkTable *table, + gint row, + gint column) +{ + /* FIXME: NOT IMPLEMENTED */ + return 0; +} + +static gint +table_interface_get_row_extent_at (AtkTable *table, + gint row, + gint column) +{ + /* FIXME: NOT IMPLEMENTED */ + return 0; +} + +static gboolean +table_interface_is_row_selected (AtkTable *table, + gint row) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (day_view->selection_start_day == -1) + /* no selection */ + return FALSE; + if (day_view->selection_start_day != day_view->selection_end_day) + /* all row is selected */ + return TRUE; + if (row >= day_view->selection_start_row && + row <= day_view->selection_end_row) + return TRUE; + return FALSE; +} + +static gboolean +table_interface_is_selected (AtkTable *table, + gint row, + gint column) +{ + return table_interface_is_row_selected (table, row); +} + +static gboolean +table_interface_is_column_selected (AtkTable *table, + gint column) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (column >= day_view->selection_start_day && + column <= day_view->selection_end_day) + return TRUE; + return FALSE; +} + +static gint +table_interface_get_selected_rows (AtkTable *table, + gint **rows_selected) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + gint start_row = -1, n_rows = 0; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (day_view->selection_start_day == -1) + return 0; + + if (day_view->selection_start_day != day_view->selection_end_day) { + /* all the rows should be selected */ + n_rows = day_view->rows; + start_row = 0; + } + else if (day_view->selection_start_row != -1) { + start_row = day_view->selection_start_row; + n_rows = day_view->selection_end_row - start_row + 1; + } + if (n_rows > 0 && start_row != -1 && rows_selected) { + gint index; + + *rows_selected = (gint *) g_malloc (n_rows * sizeof (gint)); + for (index = 0; index < n_rows; ++index) + (*rows_selected)[index] = start_row + index; + } + return n_rows; +} + +static gint +table_interface_get_selected_columns (AtkTable *table, + gint **columns_selected) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + gint start_column = -1, n_columns = 0; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (day_view->selection_start_day == -1) + return 0; + + start_column = day_view->selection_start_day; + n_columns = day_view->selection_end_day - start_column + 1; + if (n_columns > 0 && start_column != -1 && columns_selected) { + gint index; + + *columns_selected = (gint *) g_malloc (n_columns * sizeof (gint)); + for (index = 0; index < n_columns; ++index) + (*columns_selected)[index] = start_column + index; + } + return n_columns; +} + +static gboolean +table_interface_add_row_selection (AtkTable *table, + gint row) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + /* FIXME: we need multi-selection */ + + day_view->selection_start_day = 0; + day_view->selection_end_day = 0; + day_view->selection_start_row = row; + day_view->selection_end_row = row; + + e_day_view_ensure_rows_visible (day_view, + day_view->selection_start_row, + day_view->selection_end_row); + e_day_view_update_calendar_selection_time (day_view); + gtk_widget_queue_draw (day_view->main_canvas); + return TRUE; +} + +static gboolean +table_interface_remove_row_selection (AtkTable *table, + gint row) +{ + return FALSE; +} + +static gboolean +table_interface_add_column_selection (AtkTable *table, + gint column) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + /* FIXME: we need multi-selection */ + + day_view->selection_start_day = column; + day_view->selection_end_day = column; + day_view->selection_start_row = 0; + day_view->selection_end_row = day_view->rows; + + e_day_view_update_calendar_selection_time (day_view); + gtk_widget_queue_draw (day_view->main_canvas); + return TRUE; +} + +static gboolean +table_interface_remove_column_selection (AtkTable *table, + gint column) +{ + /* FIXME: NOT IMPLEMENTED */ + return FALSE; +} + +static AtkObject* +table_interface_get_row_header (AtkTable *table, + gint row) +{ + /* FIXME: NOT IMPLEMENTED */ + return NULL; +} + +static AtkObject* +table_interface_get_column_header (AtkTable *table, + gint in_col) +{ + /* FIXME: NOT IMPLEMENTED */ + return NULL; +} + +static AtkObject* +table_interface_get_caption (AtkTable *table) +{ + /* FIXME: NOT IMPLEMENTED */ + return NULL; +} + +static G_CONST_RETURN gchar* +table_interface_get_column_description (AtkTable *table, + gint in_col) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + const gchar *description; + DayViewCellData *cell_data; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (in_col < 0 || in_col >= day_view->days_shown) + return NULL; + cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); + if (!cell_data) + return NULL; + + description = day_view_cell_data_get_column_label (cell_data, in_col); + if (!description) { + gchar buffer[128]; + e_day_view_top_item_get_day_label (day_view, in_col, buffer, 128); + day_view_cell_data_set_column_label (cell_data, in_col, buffer); + description = day_view_cell_data_get_column_label (cell_data, in_col); + } + return description; +} + +static G_CONST_RETURN gchar* +table_interface_get_row_description (AtkTable *table, + gint row) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (table); + const gchar *description; + DayViewCellData *cell_data; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return NULL; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (row < 0 || row >= 12 * 24) + return NULL; + cell_data = ea_day_view_main_item_get_cell_data (ea_main_item); + if (!cell_data) + return NULL; + + description = day_view_cell_data_get_row_label (cell_data, row); + if (!description) { + gchar buffer[128]; + ea_day_view_main_item_get_row_label (ea_main_item, row, buffer, sizeof (buffer)); + day_view_cell_data_set_row_label (cell_data, row, buffer); + description = day_view_cell_data_get_row_label (cell_data, + row); + } + return description; +} + +static AtkObject* +table_interface_get_summary (AtkTable *table) +{ + /* FIXME: NOT IMPLEMENTED */ + return NULL; +} + +/* atkselection interface */ + +static void +atk_selection_interface_init (AtkSelectionIface *iface) +{ + g_return_if_fail (iface != NULL); + + iface->add_selection = selection_interface_add_selection; + iface->clear_selection = selection_interface_clear_selection; + iface->ref_selection = selection_interface_ref_selection; + iface->get_selection_count = selection_interface_get_selection_count; + iface->is_child_selected = selection_interface_is_child_selected; +} + +static gboolean +selection_interface_add_selection (AtkSelection *selection, gint i) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); + gint column, row; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + row = ea_day_view_main_item_get_row_at_index (ea_main_item, i); + column = ea_day_view_main_item_get_column_at_index (ea_main_item, i); + + if (row == -1 || column == -1) + return FALSE; + + /*FIXME: multi-selection is needed */ + day_view->selection_start_day = column; + day_view->selection_end_day = column; + day_view->selection_start_row = row; + day_view->selection_end_row = row; + + e_day_view_ensure_rows_visible (day_view, + day_view->selection_start_row, + day_view->selection_end_row); + e_day_view_update_calendar_selection_time (day_view); + gtk_widget_queue_draw (day_view->main_canvas); + return TRUE; +} + +static gboolean +selection_interface_clear_selection (AtkSelection *selection) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return -1; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + day_view->selection_start_row = -1; + day_view->selection_start_day = -1; + day_view->selection_end_row = -1; + day_view->selection_end_day = -1; + + e_day_view_update_calendar_selection_time (day_view); + gtk_widget_queue_draw (day_view->main_canvas); + + return TRUE; +} + +static AtkObject* +selection_interface_ref_selection (AtkSelection *selection, gint i) +{ + if (selection_interface_is_child_selected (selection, i)) + return ea_day_view_main_item_ref_child (ATK_OBJECT (selection), i); + return NULL; +} + +static gint +selection_interface_get_selection_count (AtkSelection *selection) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); + gint start_index, end_index; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return 0; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + if (day_view->selection_start_day == -1 || + day_view->selection_start_row == -1) + return 0; + start_index = ea_day_view_main_item_get_child_index_at (ea_main_item, + day_view->selection_start_row, + day_view->selection_start_day); + end_index = ea_day_view_main_item_get_child_index_at (ea_main_item, + day_view->selection_end_row, + day_view->selection_end_day); + + return end_index - start_index + 1; +} + +static gboolean +selection_interface_is_child_selected (AtkSelection *selection, gint i) +{ + AtkGObjectAccessible *atk_gobj; + GObject *g_obj; + EDayViewMainItem *main_item; + EDayView *day_view; + EaDayViewMainItem* ea_main_item = EA_DAY_VIEW_MAIN_ITEM (selection); + gint column, row; + + atk_gobj = ATK_GOBJECT_ACCESSIBLE (ea_main_item); + g_obj = atk_gobject_accessible_get_object (atk_gobj); + if (!g_obj) + return FALSE; + + main_item = E_DAY_VIEW_MAIN_ITEM (g_obj); + day_view = main_item->day_view; + + row = ea_day_view_main_item_get_row_at_index (ea_main_item, i); + column = ea_day_view_main_item_get_column_at_index (ea_main_item, i); + + if (column < day_view->selection_start_day || + column > day_view->selection_end_day) + return FALSE; + + if ((column == day_view->selection_start_day || + column == day_view->selection_end_day) && + (row < day_view->selection_start_row || + row > day_view->selection_end_row)) + return FALSE; + + /* if comes here, the cell is selected */ + return TRUE; +} + +/* DayViewCellData */ + +DayViewCellData * +day_view_cell_data_create (gint columns, gint rows) +{ + DayViewCellData * cell_data; + gint index; + + g_return_val_if_fail (((columns > 0) && (rows > 0)), NULL); + + cell_data = g_new0 (DayViewCellData, 1); + + cell_data->columns = columns; + cell_data->rows = rows; + + for (index = 0; index < CELL_DATA_MAX_COLUMNS; ++index) + cell_data->column_labels [index] =NULL; + + for (index = 0; index < CELL_DATA_MAX_ROWS; ++index) + cell_data->row_labels [index] = NULL; + + cell_data->cells = (EDayViewCell **)g_new0(gpointer, (columns * rows)); + + for (index = (columns * rows) -1; index >= 0; --index) + cell_data->cells [index] = NULL; + return cell_data; +} + +void +day_view_cell_data_destroy (DayViewCellData * cell_data) +{ + gint index; + g_return_if_fail (cell_data); + + for (index = 0; index < CELL_DATA_MAX_COLUMNS; ++index) + if (cell_data->column_labels [index]) + g_free (cell_data->column_labels [index]); + + for (index = 0; index < CELL_DATA_MAX_ROWS; ++index) + if (cell_data->row_labels [index]) + g_free (cell_data->row_labels [index]); + + for (index = (cell_data->columns * cell_data->rows) -1; index >= 0; --index) + if (cell_data->cells[index]) + g_object_unref (cell_data->cells[index]); + + g_free (cell_data->cells); +} + +EDayViewCell * +day_view_cell_data_get_cell (DayViewCellData * cell_data, + gint row, gint column) +{ + g_return_val_if_fail (cell_data, NULL); + + if (row >= 0 && row < cell_data->rows && + column >= 0 && column < cell_data->columns) + return cell_data->cells[column * cell_data->rows + row]; + return NULL; +} + +void +day_view_cell_data_set_cell (DayViewCellData * cell_data, + gint row, gint column, EDayViewCell *cell) +{ + g_return_if_fail (cell_data); + + if (row >= 0 && row < cell_data->rows && + column >= 0 && column < cell_data->columns) { + gint index = column * cell_data->rows + row; + if (cell) + g_object_ref (cell); + if (cell_data->cells[index]) + g_object_unref (cell_data->cells[index]); + cell_data->cells[index] = cell; + } +} + +EDayViewCell * +day_view_cell_data_get_cell_at_index (DayViewCellData * cell_data, + gint index) +{ + g_return_val_if_fail (cell_data, NULL); + + if (index >=0 && index < (cell_data->columns * cell_data->rows)) + return cell_data->cells [index]; + return NULL; +} + +G_CONST_RETURN gchar* +day_view_cell_data_get_column_label (DayViewCellData * cell_data, + gint day) +{ + g_return_val_if_fail (cell_data, NULL); + g_return_val_if_fail ((day >= 0 && day < cell_data->columns), NULL); + + return cell_data->column_labels[day]; +} + +void +day_view_cell_data_set_column_label (DayViewCellData * cell_data, + gint day, const gchar *label) +{ + g_return_if_fail (cell_data); + g_return_if_fail ((day >= 0 && day < cell_data->columns)); + + if (cell_data->column_labels[day]) + g_free (cell_data->column_labels[day]); + cell_data->column_labels[day] = g_strdup(label); +} + +G_CONST_RETURN gchar* +day_view_cell_data_get_row_label (DayViewCellData * cell_data, + gint row) +{ + g_return_val_if_fail (cell_data, NULL); + g_return_val_if_fail ((row >= 0 && row < cell_data->rows), NULL); + + return cell_data->row_labels[row]; +} + +void +day_view_cell_data_set_row_label (DayViewCellData * cell_data, + gint row, const gchar *label) +{ + g_return_if_fail (cell_data); + g_return_if_fail ((row >= 0 && row < cell_data->rows)); + + if (cell_data->row_labels[row]) + g_free (cell_data->row_labels[row]); + cell_data->row_labels[row] = g_strdup(label); +} Index: a11y/calendar/ea-day-view-main-item.h =================================================================== RCS file: a11y/calendar/ea-day-view-main-item.h diff -N a11y/calendar/ea-day-view-main-item.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ a11y/calendar/ea-day-view-main-item.h 16 Sep 2003 07:21:08 -0000 @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* vim:expandtab:shiftwidth=8:tabstop=8: + */ +/* Evolution Accessibility: ea-day-view-main-item.h + * + * Copyright (C) 2003 Ximian, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Bolian Yin <bolian yin sun com> Sun Microsystem Inc., 2003 + * + */ + +#ifndef __EA_DAY_VIEW_MAIN_ITEM_H__ +#define __EA_DAY_VIEW_MAIN_ITEM_H__ + +#include <atk/atkgobjectaccessible.h> +#include "e-day-view-main-item.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define EA_TYPE_DAY_VIEW_MAIN_ITEM (ea_day_view_main_item_get_type ()) +#define EA_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItem)) +#define EA_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass)) +#define EA_IS_DAY_VIEW_MAIN_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM)) +#define EA_IS_DAY_VIEW_MAIN_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_DAY_VIEW_MAIN_ITEM)) +#define EA_DAY_VIEW_MAIN_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EA_TYPE_DAY_VIEW_MAIN_ITEM, EaDayViewMainItemClass)) + +typedef struct _EaDayViewMainItem EaDayViewMainItem; +typedef struct _EaDayViewMainItemClass EaDayViewMainItemClass; + +struct _EaDayViewMainItem +{ + AtkGObjectAccessible parent; +}; + +GType ea_day_view_main_item_get_type (void); + +struct _EaDayViewMainItemClass +{ + AtkGObjectAccessibleClass parent_class; +}; + +AtkObject* ea_day_view_main_item_new (GObject *obj); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __EA_DAY_VIEW_MAIN_ITEM_H__ */ Index: a11y/calendar/ea-day-view.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-day-view.c,v retrieving revision 1.2 diff -u -r1.2 ea-day-view.c --- a11y/calendar/ea-day-view.c 20 Aug 2003 07:46:05 -0000 1.2 +++ a11y/calendar/ea-day-view.c 16 Sep 2003 07:21:09 -0000 @@ -112,7 +112,7 @@ atk_object_initialize (accessible, widget); #ifdef ACC_DEBUG - printf ("EvoAcc: ea_day_view created %p\n", accessible); + printf ("EvoAcc: ea_day_view created %p\n", (void *)accessible); #endif return accessible; @@ -196,7 +196,8 @@ child_num += day_view->events[day]->len; } - return child_num; + /* "+1" for the main item */ + return child_num + 1; } static AtkObject * @@ -218,28 +219,36 @@ return NULL; day_view = E_DAY_VIEW (GTK_ACCESSIBLE (accessible)->widget); - /* a long event */ - if (index < day_view->long_events->len) { - event = &g_array_index (day_view->long_events, - EDayViewEvent, index); + if (index == 0) { + /* index == 0 is the main item */ + atk_object = atk_gobject_accessible_for_object (G_OBJECT (day_view->main_canvas_item)); + g_object_ref (atk_object); } else { - index -= day_view->long_events->len; - day = 0; - while (index >= day_view->events[day]->len) { - index -= day_view->events[day]->len; - ++day; + --index; + /* a long event */ + if (index < day_view->long_events->len) { + event = &g_array_index (day_view->long_events, + EDayViewEvent, index); } + else { + index -= day_view->long_events->len; + day = 0; + while (index >= day_view->events[day]->len) { + index -= day_view->events[day]->len; + ++day; + } - event = &g_array_index (day_view->events[day], - EDayViewEvent, index); - } - if (event && event->canvas_item) { - /* Not use atk_gobject_accessible_for_object here, - * we need to do special thing here - */ - atk_object = ea_calendar_helpers_get_accessible_for (event->canvas_item); - g_object_ref (atk_object); + event = &g_array_index (day_view->events[day], + EDayViewEvent, index); + } + if (event && event->canvas_item) { + /* Not use atk_gobject_accessible_for_object here, + * we need to do special thing here + */ + atk_object = ea_calendar_helpers_get_accessible_for (event->canvas_item); + g_object_ref (atk_object); + } } return atk_object; } Index: a11y/calendar/ea-gnome-calendar.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-gnome-calendar.c,v retrieving revision 1.3 diff -u -r1.3 ea-gnome-calendar.c --- a11y/calendar/ea-gnome-calendar.c 27 Aug 2003 03:36:41 -0000 1.3 +++ a11y/calendar/ea-gnome-calendar.c 16 Sep 2003 07:21:09 -0000 @@ -128,7 +128,7 @@ } #ifdef ACC_DEBUG - printf ("EvoAcc: ea-gnome-calendar created: %p\n", accessible); + printf ("EvoAcc: ea-gnome-calendar created: %p\n", (void *)accessible); #endif return accessible; @@ -225,7 +225,7 @@ #ifdef ACC_DEBUG printf ("AccDebug: view switch to widget %p (index=%d) \n", - new_widget, index); + (void *)new_widget, index); #endif } Index: a11y/calendar/ea-week-view.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/calendar/ea-week-view.c,v retrieving revision 1.2 diff -u -r1.2 ea-week-view.c --- a11y/calendar/ea-week-view.c 20 Aug 2003 07:46:05 -0000 1.2 +++ a11y/calendar/ea-week-view.c 16 Sep 2003 07:21:09 -0000 @@ -28,6 +28,7 @@ #include "ea-cal-view-event.h" #include "ea-calendar-helpers.h" #include "calendar-commands.h" +#include <gal/e-text/e-text.h> static void ea_week_view_class_init (EaWeekViewClass *klass); @@ -37,6 +38,8 @@ static AtkObject* ea_week_view_ref_child (AtkObject *obj, gint i); +static void get_visible_text_item_count (GnomeCanvasItem *item, gpointer data); + static gpointer parent_class = NULL; GType @@ -113,7 +116,7 @@ atk_object_initialize (accessible, widget); #ifdef ACC_DEBUG - printf ("EvoAcc: ea_week_view created %p\n", accessible); + printf ("EvoAcc: ea_week_view created %p\n", (void *)accessible); #endif return accessible; @@ -139,8 +142,6 @@ label_text = calendar_get_text_for_folder_bar_label (gcal); view_type = gnome_calendar_get_view (gcal); - view_type = gnome_calendar_get_view (gcal); - if (view_type == GNOME_CAL_MONTH_VIEW) accessible->name = g_strconcat ("month view :", label_text, @@ -185,51 +186,102 @@ ea_week_view_get_n_children (AtkObject *accessible) { EWeekView *week_view; + GnomeCanvasGroup *canvas_group; + gint i, count = 0; g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), -1); if (!GTK_ACCESSIBLE (accessible)->widget) return -1; week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + canvas_group = GNOME_CANVAS_GROUP (GNOME_CANVAS (week_view->main_canvas)->root); + g_list_foreach (canvas_group->item_list, (GFunc)get_visible_text_item_count, + &count); + + /* add the number of visible jump buttons */ + for (i = 0; i < E_WEEK_VIEW_MAX_WEEKS * 7; i++) { + if (week_view->jump_buttons[i]->object.flags & GNOME_CANVAS_ITEM_VISIBLE) + ++count; + } - return week_view->events->len; +#ifdef ACC_DEBUG + printf("AccDebug: week view %p has %d children\n", (void *)week_view, count); +#endif + return count; } static AtkObject * ea_week_view_ref_child (AtkObject *accessible, gint index) { EWeekView *week_view; - gint child_num; + gint child_num, max_count; AtkObject *atk_object = NULL; - EWeekViewEvent *event; - EWeekViewEventSpan *span; + gint event_index; + gint jump_button = -1; gint span_num = 0; + gint count = 0; g_return_val_if_fail (EA_IS_WEEK_VIEW (accessible), NULL); child_num = atk_object_get_n_accessible_children (accessible); - if (child_num <= 0 || index < 0 || index >= child_num) + if (child_num <= 0 || index < 0 || index >= child_num) return NULL; if (!GTK_ACCESSIBLE (accessible)->widget) return NULL; week_view = E_WEEK_VIEW (GTK_ACCESSIBLE (accessible)->widget); + max_count = week_view->events->len; - event = &g_array_index (week_view->events, - EWeekViewEvent, index); - span = &g_array_index (week_view->spans, EWeekViewEventSpan, - event->spans_index + span_num); - - if (event) { - /* Not use atk_gobject_accessible_for_object here, - * we need to do special thing here - */ - atk_object = ea_calendar_helpers_get_accessible_for (span->text_item); - g_object_ref (atk_object); + for (event_index = 0; event_index < max_count; ++event_index) { + EWeekViewEvent *event; + EWeekViewEventSpan *span; + gint current_day; + + event = &g_array_index (week_view->events, + EWeekViewEvent, event_index); + span = &g_array_index (week_view->spans, EWeekViewEventSpan, + event->spans_index + span_num); + + if (!event || !span) + continue; + + current_day = span->start_day; + if (span->text_item) + ++count; + else if (current_day != jump_button) { + /* we should go to the jump button */ + jump_button = current_day; + ++count; + } + else + continue; + + if (count == (index + 1)) { + if (span->text_item) { + /* Not use atk_gobject_accessible_for_object for event + * text_item we need to do special thing here + */ + atk_object = ea_calendar_helpers_get_accessible_for (span->text_item); + } + else { + atk_object = atk_gobject_accessible_for_object (G_OBJECT(week_view->jump_buttons[current_day == -1 ? 0 : current_day])); + } + g_object_ref (atk_object); + break; + } } + #ifdef ACC_DEBUG printf ("EvoAcc: ea_week_view_ref_child [%d]=%p\n", - index, atk_object); + index, (void *)atk_object); #endif return atk_object; +} + +static void get_visible_text_item_count (GnomeCanvasItem *item, gpointer data) +{ + gint *count = (gint *)data; + + if (item && E_IS_TEXT (item)) + ++(*count); } Index: a11y/widgets/ea-calendar-item.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/widgets/ea-calendar-item.c,v retrieving revision 1.1 diff -u -r1.1 ea-calendar-item.c --- a11y/widgets/ea-calendar-item.c 27 Aug 2003 03:36:42 -0000 1.1 +++ a11y/widgets/ea-calendar-item.c 16 Sep 2003 07:21:09 -0000 @@ -102,7 +102,7 @@ atk_object_initialize (atk_object, obj); atk_object->role = ATK_ROLE_CALENDAR; #ifdef ACC_DEBUG - g_print ("ea_calendar_item created %p\n", atk_object); + g_print ("ea_calendar_item created %p\n", (void *)atk_object); #endif return atk_object; } Index: a11y/widgets/ea-widgets.c =================================================================== RCS file: /cvs/gnome/evolution/a11y/widgets/ea-widgets.c,v retrieving revision 1.1 diff -u -r1.1 ea-widgets.c --- a11y/widgets/ea-widgets.c 27 Aug 2003 03:36:42 -0000 1.1 +++ a11y/widgets/ea-widgets.c 16 Sep 2003 07:21:09 -0000 @@ -27,7 +27,7 @@ #include "widgets/ea-calendar-item.h" #include "ea-widgets.h" -EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new); +EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new) void e_calendar_item_a11y_init (void) {